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

Side by Side Diff: webrtc/base/messagequeue.h

Issue 1895933003: Adding the ability to use a simulated clock for unit tests. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixing compile warning. Created 4 years, 6 months 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 | « webrtc/base/fakeclock.cc ('k') | webrtc/base/messagequeue.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
(...skipping 19 matching lines...) Expand all
30 #include "webrtc/base/timeutils.h" 30 #include "webrtc/base/timeutils.h"
31 #include "webrtc/base/thread_annotations.h" 31 #include "webrtc/base/thread_annotations.h"
32 32
33 namespace rtc { 33 namespace rtc {
34 34
35 struct Message; 35 struct Message;
36 class MessageQueue; 36 class MessageQueue;
37 37
38 // MessageQueueManager does cleanup of of message queues 38 // MessageQueueManager does cleanup of of message queues
39 39
40 class MessageQueueManager { 40 class MessageQueueManager : public MessageHandler {
41 public: 41 public:
42 static void Add(MessageQueue *message_queue); 42 static void Add(MessageQueue *message_queue);
43 static void Remove(MessageQueue *message_queue); 43 static void Remove(MessageQueue *message_queue);
44 static void Clear(MessageHandler *handler); 44 static void Clear(MessageHandler *handler);
45 45
46 // For testing purposes, we expose whether or not the MessageQueueManager 46 // For testing purposes, we expose whether or not the MessageQueueManager
47 // instance has been initialized. It has no other use relative to the rest of 47 // instance has been initialized. It has no other use relative to the rest of
48 // the functions of this class, which auto-initialize the underlying 48 // the functions of this class, which auto-initialize the underlying
49 // MessageQueueManager instance when necessary. 49 // MessageQueueManager instance when necessary.
50 static bool IsInitialized(); 50 static bool IsInitialized();
51 51
52 // Mainly for testing purposes, for use with a simulated clock.
53 // Posts a no-op event on all message queues so they will wake from the
54 // socket server select() and process messages again.
55 static void WakeAllMessageQueues();
56
52 private: 57 private:
53 static MessageQueueManager* Instance(); 58 static MessageQueueManager* Instance();
54 59
55 MessageQueueManager(); 60 MessageQueueManager();
56 ~MessageQueueManager(); 61 ~MessageQueueManager() override;
57 62
58 void AddInternal(MessageQueue *message_queue); 63 void AddInternal(MessageQueue *message_queue);
59 void RemoveInternal(MessageQueue *message_queue); 64 void RemoveInternal(MessageQueue *message_queue);
60 void ClearInternal(MessageHandler *handler); 65 void ClearInternal(MessageHandler *handler);
66 void WakeAllMessageQueuesInternal();
67 void OnMessage(Message* pmsg) override;
61 68
62 static MessageQueueManager* instance_; 69 static MessageQueueManager* instance_;
63 // This list contains all live MessageQueues. 70 // This list contains all live MessageQueues.
64 std::vector<MessageQueue *> message_queues_; 71 std::vector<MessageQueue *> message_queues_;
65 CriticalSection crit_; 72 CriticalSection crit_;
66 }; 73 };
67 74
68 // Derive from this for specialized data 75 // Derive from this for specialized data
69 // App manages lifetime, except when messages are purged 76 // App manages lifetime, except when messages are purged
70 77
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 // Used if SocketServer ownership lies with |this|. 296 // Used if SocketServer ownership lies with |this|.
290 std::unique_ptr<SocketServer> own_ss_; 297 std::unique_ptr<SocketServer> own_ss_;
291 SharedExclusiveLock ss_lock_; 298 SharedExclusiveLock ss_lock_;
292 299
293 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(MessageQueue); 300 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(MessageQueue);
294 }; 301 };
295 302
296 } // namespace rtc 303 } // namespace rtc
297 304
298 #endif // WEBRTC_BASE_MESSAGEQUEUE_H_ 305 #endif // WEBRTC_BASE_MESSAGEQUEUE_H_
OLDNEW
« no previous file with comments | « webrtc/base/fakeclock.cc ('k') | webrtc/base/messagequeue.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698