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

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: Created 4 years, 8 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
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();
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();
61 67
62 static MessageQueueManager* instance_; 68 static MessageQueueManager* instance_;
63 // This list contains all live MessageQueues. 69 // This list contains all live MessageQueues.
64 std::vector<MessageQueue *> message_queues_; 70 std::vector<MessageQueue *> message_queues_;
65 CriticalSection crit_; 71 CriticalSection crit_;
66 }; 72 };
67 73
68 // Derive from this for specialized data 74 // Derive from this for specialized data
69 // App manages lifetime, except when messages are purged 75 // App manages lifetime, except when messages are purged
70 76
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 // If a server isn't supplied in the constructor, use this one. 286 // If a server isn't supplied in the constructor, use this one.
281 scoped_ptr<SocketServer> default_ss_; 287 scoped_ptr<SocketServer> default_ss_;
282 SharedExclusiveLock ss_lock_; 288 SharedExclusiveLock ss_lock_;
283 289
284 RTC_DISALLOW_COPY_AND_ASSIGN(MessageQueue); 290 RTC_DISALLOW_COPY_AND_ASSIGN(MessageQueue);
285 }; 291 };
286 292
287 } // namespace rtc 293 } // namespace rtc
288 294
289 #endif // WEBRTC_BASE_MESSAGEQUEUE_H_ 295 #endif // WEBRTC_BASE_MESSAGEQUEUE_H_
OLDNEW
« no previous file with comments | « webrtc/base/base.gyp ('k') | webrtc/base/messagequeue.cc » ('j') | webrtc/base/simulatedclock.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698