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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/base/bufferqueue.cc » ('j') | webrtc/base/bufferqueue.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2015 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #ifndef WEBRTC_BASE_BUFFERQUEUE_H_ 11 #ifndef WEBRTC_BASE_BUFFERQUEUE_H_
12 #define WEBRTC_BASE_BUFFERQUEUE_H_ 12 #define WEBRTC_BASE_BUFFERQUEUE_H_
13 13
14 #include <deque> 14 #include <deque>
15 #include <vector> 15 #include <vector>
16 16
17 #include "webrtc/base/buffer.h" 17 #include "webrtc/base/buffer.h"
18 #include "webrtc/base/criticalsection.h" 18 #include "webrtc/base/criticalsection.h"
19 #include "webrtc/base/messagehandler.h"
20 #include "webrtc/base/messagequeue.h"
21 #include "webrtc/base/sigslot.h"
22 #include "webrtc/base/thread.h"
19 23
20 namespace rtc { 24 namespace rtc {
21 25
22 class BufferQueue { 26 // BufferEvents are used to asynchronously signal state transitionss. The flags
27 // may be combined.
28 // BQ_READ: Data is available
29 // BQ_WRITE: Data can be written
30 enum BufferEvent { BQ_READ = 1, BQ_WRITE = 2 };
31
32 struct BufferEventData : public MessageData {
33 int events;
tommi 2015/11/13 08:38:12 for consistency keep members below methods
34 BufferEventData(int ev) : events(ev) { }
35 };
36
37 class BufferQueue : public MessageHandler {
23 public: 38 public:
39 enum {
40 MSG_POST_EVENT = 0x1
tommi 2015/11/13 08:38:12 private?
41 };
42
24 // Creates a buffer queue queue with a given capacity and default buffer size. 43 // Creates a buffer queue queue with a given capacity and default buffer size.
25 BufferQueue(size_t capacity, size_t default_size); 44 BufferQueue(size_t capacity, size_t default_size);
45 // Creates a buffer queue queue with a given capacity, default buffer size
46 // and owner.
47 BufferQueue(size_t capacity, size_t default_size, Thread* owner);
26 ~BufferQueue(); 48 ~BufferQueue();
27 49
28 // Return number of queued buffers. 50 // Return number of queued buffers.
29 size_t size() const; 51 size_t size() const;
30 52
31 // ReadFront will only read one buffer at a time and will truncate buffers 53 // ReadFront will only read one buffer at a time and will truncate buffers
32 // that don't fit in the passed memory. 54 // that don't fit in the passed memory.
33 bool ReadFront(void* data, size_t bytes, size_t* bytes_read); 55 bool ReadFront(void* data, size_t bytes, size_t* bytes_read);
34 56
35 // WriteBack always writes either the complete memory or nothing. 57 // WriteBack always writes either the complete memory or nothing.
36 bool WriteBack(const void* data, size_t bytes, size_t* bytes_written); 58 bool WriteBack(const void* data, size_t bytes, size_t* bytes_written);
37 59
60 // BufferQueues may signal one or more BufferEvents to indicate state changes.
61 // The first argument identifies the buffer on which the state change occured.
62 // The second argument is a bit-wise combination of BufferEvents.
63 sigslot::signal2<BufferQueue*, int> SignalEvent;
tommi 2015/11/13 08:38:12 can we use rtc::Bind instead? If not, can we make
64
65 // Like calling SignalEvent, but posts a message to the specified thread,
66 // which will call SignalEvent. This helps unroll the stack and prevent
67 // re-entrancy.
68 void PostEvent(Thread* t, int events);
tommi 2015/11/13 08:38:12 nit: t -> thread Should this be private?
69 // Like the aforementioned method, but posts to the current thread.
70 void PostEvent(int events);
71
72 protected:
73 // MessageHandler Interface
74 void OnMessage(Message* msg) override;
75
38 private: 76 private:
39 size_t capacity_; 77 size_t capacity_;
40 size_t default_size_; 78 size_t default_size_;
79 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"
41 std::deque<Buffer*> queue_; 80 std::deque<Buffer*> queue_;
42 std::vector<Buffer*> free_list_; 81 std::vector<Buffer*> free_list_;
43 mutable CriticalSection crit_; // object lock 82 mutable CriticalSection crit_; // object lock
44 83
45 RTC_DISALLOW_COPY_AND_ASSIGN(BufferQueue); 84 RTC_DISALLOW_COPY_AND_ASSIGN(BufferQueue);
46 }; 85 };
47 86
48 } // namespace rtc 87 } // namespace rtc
49 88
50 #endif // WEBRTC_BASE_BUFFERQUEUE_H_ 89 #endif // WEBRTC_BASE_BUFFERQUEUE_H_
OLDNEW
« 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