OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 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_MESSAGEQUEUE_H_ | 11 #ifndef WEBRTC_BASE_MESSAGEQUEUE_H_ |
12 #define WEBRTC_BASE_MESSAGEQUEUE_H_ | 12 #define WEBRTC_BASE_MESSAGEQUEUE_H_ |
13 | 13 |
14 #include <string.h> | 14 #include <string.h> |
15 | 15 |
16 #include <algorithm> | 16 #include <algorithm> |
17 #include <list> | 17 #include <list> |
18 #include <memory> | 18 #include <memory> |
19 #include <queue> | 19 #include <queue> |
| 20 #include <utility> |
20 #include <vector> | 21 #include <vector> |
21 | 22 |
22 #include "webrtc/base/basictypes.h" | 23 #include "webrtc/base/basictypes.h" |
23 #include "webrtc/base/constructormagic.h" | 24 #include "webrtc/base/constructormagic.h" |
24 #include "webrtc/base/criticalsection.h" | 25 #include "webrtc/base/criticalsection.h" |
25 #include "webrtc/base/location.h" | 26 #include "webrtc/base/location.h" |
26 #include "webrtc/base/messagehandler.h" | 27 #include "webrtc/base/messagehandler.h" |
27 #include "webrtc/base/scoped_ref_ptr.h" | 28 #include "webrtc/base/scoped_ref_ptr.h" |
28 #include "webrtc/base/sharedexclusivelock.h" | 29 #include "webrtc/base/sharedexclusivelock.h" |
29 #include "webrtc/base/sigslot.h" | 30 #include "webrtc/base/sigslot.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 const T& data() const { return data_; } | 92 const T& data() const { return data_; } |
92 T& data() { return data_; } | 93 T& data() { return data_; } |
93 private: | 94 private: |
94 T data_; | 95 T data_; |
95 }; | 96 }; |
96 | 97 |
97 // Like TypedMessageData, but for pointers that require a delete. | 98 // Like TypedMessageData, but for pointers that require a delete. |
98 template <class T> | 99 template <class T> |
99 class ScopedMessageData : public MessageData { | 100 class ScopedMessageData : public MessageData { |
100 public: | 101 public: |
101 explicit ScopedMessageData(T* data) : data_(data) { } | 102 explicit ScopedMessageData(std::unique_ptr<T> data) |
| 103 : data_(std::move(data)) {} |
| 104 // Deprecated. |
| 105 // TODO(deadbeef): Remove this once downstream applications stop using it. |
| 106 explicit ScopedMessageData(T* data) : data_(data) {} |
| 107 // Deprecated. |
| 108 // TODO(deadbeef): Returning a reference to a unique ptr? Why. Get rid of |
| 109 // this once downstream applications stop using it, then rename inner_data to |
| 110 // just data. |
102 const std::unique_ptr<T>& data() const { return data_; } | 111 const std::unique_ptr<T>& data() const { return data_; } |
103 std::unique_ptr<T>& data() { return data_; } | 112 std::unique_ptr<T>& data() { return data_; } |
104 | 113 |
| 114 const T& inner_data() const { return *data_; } |
| 115 T& inner_data() { return *data_; } |
| 116 |
105 private: | 117 private: |
106 std::unique_ptr<T> data_; | 118 std::unique_ptr<T> data_; |
107 }; | 119 }; |
108 | 120 |
109 // Like ScopedMessageData, but for reference counted pointers. | 121 // Like ScopedMessageData, but for reference counted pointers. |
110 template <class T> | 122 template <class T> |
111 class ScopedRefMessageData : public MessageData { | 123 class ScopedRefMessageData : public MessageData { |
112 public: | 124 public: |
113 explicit ScopedRefMessageData(T* data) : data_(data) { } | 125 explicit ScopedRefMessageData(T* data) : data_(data) { } |
114 const scoped_refptr<T>& data() const { return data_; } | 126 const scoped_refptr<T>& data() const { return data_; } |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 // Used if SocketServer ownership lies with |this|. | 321 // Used if SocketServer ownership lies with |this|. |
310 std::unique_ptr<SocketServer> own_ss_; | 322 std::unique_ptr<SocketServer> own_ss_; |
311 SharedExclusiveLock ss_lock_; | 323 SharedExclusiveLock ss_lock_; |
312 | 324 |
313 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(MessageQueue); | 325 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(MessageQueue); |
314 }; | 326 }; |
315 | 327 |
316 } // namespace rtc | 328 } // namespace rtc |
317 | 329 |
318 #endif // WEBRTC_BASE_MESSAGEQUEUE_H_ | 330 #endif // WEBRTC_BASE_MESSAGEQUEUE_H_ |
OLD | NEW |