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

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: First changes based on feedback from tommi 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
torbjorng (webrtc) 2015/11/16 14:05:03 Nit: "transitionss" is misspelled.
joachim 2015/11/16 21:30:16 No longer applies (removed).
+// 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;
+ BufferEventData(int ev) : events(ev) { }
+};
+
+class BufferQueue : public MessageHandler {
public:
+ enum {
torbjorng (webrtc) 2015/11/16 14:05:03 Nit: Define enum on one line for consistency. Plea
joachim 2015/11/16 21:30:15 No longer applies (removed).
+ MSG_POST_EVENT = 0x1
+ };
+
// 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
torbjorng (webrtc) 2015/11/16 14:05:03 Nit: "queue queue"
joachim 2015/11/16 21:30:15 Done.
+ // 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;
+
+ // Like calling SignalEvent, but posts a message to the specified thread,
+ // which will call SignalEvent. This helps unroll the stack and prevent
+ // re-entrancy.
torbjorng (webrtc) 2015/11/16 14:05:03 I don't understand the 2nd sentence here. What doe
joachim 2015/11/16 21:30:15 By posting the event to a different (or the same)
+ void PostEvent(Thread* t, int events);
+ // Like the aforementioned method, but posts to the current thread.
+ void PostEvent(int events);
+
+ protected:
+ // MessageHandler Interface
torbjorng (webrtc) 2015/11/16 14:05:03 Nit: The code style asks for a full stop after eve
joachim 2015/11/16 21:30:16 Done.
+ void OnMessage(Message* msg) override;
+
private:
size_t capacity_;
size_t default_size_;
+ Thread* owner_;
std::deque<Buffer*> queue_;
std::vector<Buffer*> free_list_;
mutable CriticalSection crit_; // object lock
torbjorng (webrtc) 2015/11/16 14:05:03 Consider using GUARDED_BY here. See e.g. webrtc/ca
joachim 2015/11/16 21:30:16 Done.
« 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