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

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: Small cleanup 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') | no next file with comments »
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..94c964df25b045d5cfe9a1abaf073ae07f0588ae 100644
--- a/webrtc/base/bufferqueue.h
+++ b/webrtc/base/bufferqueue.h
@@ -16,13 +16,19 @@
#include "webrtc/base/buffer.h"
#include "webrtc/base/criticalsection.h"
+#include "webrtc/base/messagehandler.h"
+#include "webrtc/base/messagequeue.h"
+#include "webrtc/base/stream.h"
+#include "webrtc/base/thread.h"
namespace rtc {
-class BufferQueue {
+class BufferQueue : public StreamInterface {
tommi 2015/11/18 10:10:45 I'm not sure about this change. It adds a lot of
joachim 2015/11/18 10:33:58 Yes. With this change, StreamInterfaceChannel coul
joachim 2015/11/18 11:26:06 What about I add empty methods to the BufferQueue
tommi 2015/11/18 12:20:04 If these methods are only needed for testing purpo
joachim 2015/11/18 13:57:00 Done.
public:
- // 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 with a given capacity, default buffer size
+ // and owner thread.
+ BufferQueue(size_t capacity, size_t default_size,
+ Thread* owner = Thread::Current());
~BufferQueue();
// Return number of queued buffers.
@@ -30,17 +36,46 @@ class BufferQueue {
// ReadFront will only read one buffer at a time and will truncate buffers
// that don't fit in the passed memory.
+ // Returns true unless no data could be returned.
bool ReadFront(void* data, size_t bytes, size_t* bytes_read);
// WriteBack always writes either the complete memory or nothing.
+ // Returns true unless no data could be written.
bool WriteBack(const void* data, size_t bytes, size_t* bytes_written);
+ // Implementation of abstract StreamInterface methods.
+
+ // A buffer queue is always "open".
+ StreamState GetState() const override { return SS_OPEN; }
+
+ // Reading a buffer queue will either succeed or block.
+ StreamResult Read(void* buffer, size_t buffer_len,
+ size_t* read, int* error) override {
+ if (!ReadFront(buffer, buffer_len, read)) {
+ return SR_BLOCK;
+ }
+ return SR_SUCCESS;
+ }
+
+ // Writing to a buffer queue will either succeed or block.
+ StreamResult Write(const void* data, size_t data_len,
+ size_t* written, int* error) override {
+ if (!WriteBack(data, data_len, written)) {
+ return SR_BLOCK;
+ }
+ return SR_SUCCESS;
+ }
+
+ // A buffer queue can not be closed.
+ void Close() override {}
+
private:
size_t capacity_;
size_t default_size_;
- std::deque<Buffer*> queue_;
- std::vector<Buffer*> free_list_;
- mutable CriticalSection crit_; // object lock
+ Thread* owner_thread_;
+ mutable CriticalSection crit_;
+ std::deque<Buffer*> queue_ GUARDED_BY(crit_);
+ std::vector<Buffer*> free_list_ GUARDED_BY(crit_);
RTC_DISALLOW_COPY_AND_ASSIGN(BufferQueue);
};
« no previous file with comments | « no previous file | webrtc/base/bufferqueue.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698