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

Side by Side Diff: webrtc/modules/desktop_capture/mac/desktop_configuration_monitor.h

Issue 1347793005: Replace Atomic32 with webrtc/base/atomicops.h. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: fix typo Created 5 years, 2 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 (c) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 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_MODULES_DESKTOP_CAPTURE_MAC_DESKTOP_CONFIGURATION_MONITOR_H_ 11 #ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_MAC_DESKTOP_CONFIGURATION_MONITOR_H_
12 #define WEBRTC_MODULES_DESKTOP_CAPTURE_MAC_DESKTOP_CONFIGURATION_MONITOR_H_ 12 #define WEBRTC_MODULES_DESKTOP_CAPTURE_MAC_DESKTOP_CONFIGURATION_MONITOR_H_
13 13
14 #include <ApplicationServices/ApplicationServices.h> 14 #include <ApplicationServices/ApplicationServices.h>
15 15
16 #include <set> 16 #include <set>
17 17
18 #include "webrtc/base/atomicops.h"
18 #include "webrtc/base/scoped_ptr.h" 19 #include "webrtc/base/scoped_ptr.h"
19 #include "webrtc/modules/desktop_capture/mac/desktop_configuration.h" 20 #include "webrtc/modules/desktop_capture/mac/desktop_configuration.h"
20 #include "webrtc/system_wrappers/interface/atomic32.h"
21 21
22 namespace webrtc { 22 namespace webrtc {
23 23
24 class EventWrapper; 24 class EventWrapper;
25 25
26 // The class provides functions to synchronize capturing and display 26 // The class provides functions to synchronize capturing and display
27 // reconfiguring across threads, and the up-to-date MacDesktopConfiguration. 27 // reconfiguring across threads, and the up-to-date MacDesktopConfiguration.
28 class DesktopConfigurationMonitor { 28 class DesktopConfigurationMonitor {
29 public: 29 public:
30 DesktopConfigurationMonitor(); 30 DesktopConfigurationMonitor();
31 // Acquires a lock on the current configuration. 31 // Acquires a lock on the current configuration.
32 void Lock(); 32 void Lock();
33 // Releases the lock previously acquired. 33 // Releases the lock previously acquired.
34 void Unlock(); 34 void Unlock();
35 // Returns the current desktop configuration. Should only be called when the 35 // Returns the current desktop configuration. Should only be called when the
36 // lock has been acquired. 36 // lock has been acquired.
37 const MacDesktopConfiguration& desktop_configuration() { 37 const MacDesktopConfiguration& desktop_configuration() {
38 return desktop_configuration_; 38 return desktop_configuration_;
39 } 39 }
40 40
41 void AddRef() { ++ref_count_; } 41 void AddRef() { rtc::AtomicOps::Increment(&ref_count_); }
42 void Release() { 42 void Release() {
43 if (--ref_count_ == 0) 43 if (rtc::AtomicOps::Decrement(&ref_count_) == 0)
44 delete this; 44 delete this;
45 } 45 }
46 46
47 private: 47 private:
48 static void DisplaysReconfiguredCallback(CGDirectDisplayID display, 48 static void DisplaysReconfiguredCallback(CGDirectDisplayID display,
49 CGDisplayChangeSummaryFlags flags, 49 CGDisplayChangeSummaryFlags flags,
50 void *user_parameter); 50 void *user_parameter);
51 ~DesktopConfigurationMonitor(); 51 ~DesktopConfigurationMonitor();
52 52
53 void DisplaysReconfigured(CGDirectDisplayID display, 53 void DisplaysReconfigured(CGDirectDisplayID display,
54 CGDisplayChangeSummaryFlags flags); 54 CGDisplayChangeSummaryFlags flags);
55 55
56 Atomic32 ref_count_; 56 volatile int ref_count_;
57 std::set<CGDirectDisplayID> reconfiguring_displays_; 57 std::set<CGDirectDisplayID> reconfiguring_displays_;
58 MacDesktopConfiguration desktop_configuration_; 58 MacDesktopConfiguration desktop_configuration_;
59 rtc::scoped_ptr<EventWrapper> display_configuration_capture_event_; 59 rtc::scoped_ptr<EventWrapper> display_configuration_capture_event_;
60 60
61 RTC_DISALLOW_COPY_AND_ASSIGN(DesktopConfigurationMonitor); 61 RTC_DISALLOW_COPY_AND_ASSIGN(DesktopConfigurationMonitor);
62 }; 62 };
63 63
64 } // namespace webrtc 64 } // namespace webrtc
65 65
66 #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_MAC_DESKTOP_CONFIGURATION_MONITOR_H_ 66 #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_MAC_DESKTOP_CONFIGURATION_MONITOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698