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

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

Issue 2024813004: Improving the fake clock and using it to fix a flaky STUN timeout test. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixing another TSan warning. WebRtcSession wasn't completely shut down. 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
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 : public MessageHandler { 40 class MessageQueueManager {
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. 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 53 // Ensures that all message queues have processed delayed messages
54 // socket server select() and process messages again. 54 // up until the current point in time.
55 static void WakeAllMessageQueues(); 55 static void ProcessAllMessageQueues();
56 56
57 private: 57 private:
58 static MessageQueueManager* Instance(); 58 static MessageQueueManager* Instance();
59 59
60 MessageQueueManager(); 60 MessageQueueManager();
61 ~MessageQueueManager() override; 61 ~MessageQueueManager();
62 62
63 void AddInternal(MessageQueue *message_queue); 63 void AddInternal(MessageQueue *message_queue);
64 void RemoveInternal(MessageQueue *message_queue); 64 void RemoveInternal(MessageQueue *message_queue);
65 void ClearInternal(MessageHandler *handler); 65 void ClearInternal(MessageHandler *handler);
66 void WakeAllMessageQueuesInternal(); 66 void ProcessAllMessageQueuesInternal();
67 void OnMessage(Message* pmsg) override;
68 67
69 static MessageQueueManager* instance_; 68 static MessageQueueManager* instance_;
70 // This list contains all live MessageQueues. 69 // This list contains all live MessageQueues.
71 std::vector<MessageQueue *> message_queues_; 70 std::vector<MessageQueue *> message_queues_;
72 CriticalSection crit_; 71 CriticalSection crit_;
73 }; 72 };
74 73
75 // Derive from this for specialized data 74 // Derive from this for specialized data
76 // App manages lifetime, except when messages are purged 75 // App manages lifetime, except when messages are purged
77 76
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 // Used if SocketServer ownership lies with |this|. 295 // Used if SocketServer ownership lies with |this|.
297 std::unique_ptr<SocketServer> own_ss_; 296 std::unique_ptr<SocketServer> own_ss_;
298 SharedExclusiveLock ss_lock_; 297 SharedExclusiveLock ss_lock_;
299 298
300 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(MessageQueue); 299 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(MessageQueue);
301 }; 300 };
302 301
303 } // namespace rtc 302 } // namespace rtc
304 303
305 #endif // WEBRTC_BASE_MESSAGEQUEUE_H_ 304 #endif // WEBRTC_BASE_MESSAGEQUEUE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698