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

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

Issue 1765443002: Added log messages for important call setup events: first packet sent/received (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Corrected naming 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
« no previous file with comments | « webrtc/base/base_tests.gyp ('k') | webrtc/base/onetimeevent_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #ifndef WEBRTC_BASE_ONETIMEEVENT_H_
12 #define WEBRTC_BASE_ONETIMEEVENT_H_
13
14 #include "webrtc/base/scoped_ptr.h"
15 #include "webrtc/base/criticalsection.h"
16 #include "webrtc/typedefs.h"
17
18 namespace webrtc {
19 // Provides a simple way to perform an operation (such as logging) one
20 // time in a certain scope.
21 // Example:
22 // OneTimeEvent firstFrame;
23 // ...
24 // if (firstFrame()) {
25 // LOG(LS_INFO) << "This is the first frame".
26 // }
27 class OneTimeEvent {
28 public:
29 OneTimeEvent() {}
30 bool operator()() {
31 rtc::CritScope cs(&critsect_);
32 if (happened_) {
33 return false;
34 }
35 happened_ = true;
36 return true;
37 }
38
39 private:
40 bool happened_ = false;
41 rtc::CriticalSection critsect_;
42 };
43
44 // A non-thread-safe, ligher-weight version of the OneTimeEvent class.
45 class ThreadUnsafeOneTimeEvent {
46 public:
47 ThreadUnsafeOneTimeEvent() {}
48 bool operator()() {
49 if (happened_) {
50 return false;
51 }
52 happened_ = true;
53 return true;
54 }
55
56 private:
57 bool happened_ = false;
58 };
59
60 } // namespace webrtc
61
62 #endif // WEBRTC_BASE_ONETIMEEVENT_H_
OLDNEW
« no previous file with comments | « webrtc/base/base_tests.gyp ('k') | webrtc/base/onetimeevent_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698