Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(256)

Unified Diff: webrtc/base/bufferqueue.h

Issue 1440193002: Fix DTLS packet boundary handling in SSLStreamAdapterTests. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | webrtc/base/bufferqueue.cc » ('j') | webrtc/base/bufferqueue.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/bufferqueue.h
diff --git a/webrtc/base/bufferqueue.h b/webrtc/base/bufferqueue.h
index 4941fccf2e1c6233584c21588e34991a312e41e3..4adfa29648a18d51f193d242dd06abdd0e950cbc 100644
--- a/webrtc/base/bufferqueue.h
+++ b/webrtc/base/bufferqueue.h
@@ -16,13 +16,35 @@
#include "webrtc/base/buffer.h"
#include "webrtc/base/criticalsection.h"
+#include "webrtc/base/messagehandler.h"
+#include "webrtc/base/messagequeue.h"
+#include "webrtc/base/sigslot.h"
+#include "webrtc/base/thread.h"
namespace rtc {
-class BufferQueue {
+// BufferEvents are used to asynchronously signal state transitionss. The flags
+// may be combined.
+// BQ_READ: Data is available
+// BQ_WRITE: Data can be written
+enum BufferEvent { BQ_READ = 1, BQ_WRITE = 2 };
+
+struct BufferEventData : public MessageData {
+ int events;
tommi 2015/11/13 08:38:12 for consistency keep members below methods
+ BufferEventData(int ev) : events(ev) { }
+};
+
+class BufferQueue : public MessageHandler {
public:
+ enum {
+ MSG_POST_EVENT = 0x1
tommi 2015/11/13 08:38:12 private?
+ };
+
// Creates a buffer queue queue with a given capacity and default buffer size.
BufferQueue(size_t capacity, size_t default_size);
+ // Creates a buffer queue queue with a given capacity, default buffer size
+ // and owner.
+ BufferQueue(size_t capacity, size_t default_size, Thread* owner);
~BufferQueue();
// Return number of queued buffers.
@@ -35,9 +57,26 @@ class BufferQueue {
// WriteBack always writes either the complete memory or nothing.
bool WriteBack(const void* data, size_t bytes, size_t* bytes_written);
+ // BufferQueues may signal one or more BufferEvents to indicate state changes.
+ // The first argument identifies the buffer on which the state change occured.
+ // The second argument is a bit-wise combination of BufferEvents.
+ sigslot::signal2<BufferQueue*, int> SignalEvent;
tommi 2015/11/13 08:38:12 can we use rtc::Bind instead? If not, can we make
+
+ // Like calling SignalEvent, but posts a message to the specified thread,
+ // which will call SignalEvent. This helps unroll the stack and prevent
+ // re-entrancy.
+ void PostEvent(Thread* t, int events);
tommi 2015/11/13 08:38:12 nit: t -> thread Should this be private?
+ // Like the aforementioned method, but posts to the current thread.
+ void PostEvent(int events);
+
+ protected:
+ // MessageHandler Interface
+ void OnMessage(Message* msg) override;
+
private:
size_t capacity_;
size_t default_size_;
+ Thread* owner_;
tommi 2015/11/13 08:38:12 if the value of this never changes, lets make it T
joachim 2015/11/16 21:30:15 Renamed, but can't change to "const" ("PostEvent"
std::deque<Buffer*> queue_;
std::vector<Buffer*> free_list_;
mutable CriticalSection crit_; // object lock
« no previous file with comments | « no previous file | webrtc/base/bufferqueue.cc » ('j') | webrtc/base/bufferqueue.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698