OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "remoting/host/local_input_monitor.h" | 5 #include "remoting/host/local_input_monitor.h" |
6 | 6 |
7 #import <AppKit/AppKit.h> | 7 #import <AppKit/AppKit.h> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 LocalInputMonitorMac() : host_(NULL) {} | 145 LocalInputMonitorMac() : host_(NULL) {} |
146 virtual ~LocalInputMonitorMac(); | 146 virtual ~LocalInputMonitorMac(); |
147 virtual void Start(remoting::ChromotingHost* host) OVERRIDE; | 147 virtual void Start(remoting::ChromotingHost* host) OVERRIDE; |
148 virtual void Stop() OVERRIDE; | 148 virtual void Stop() OVERRIDE; |
149 | 149 |
150 private: | 150 private: |
151 remoting::ChromotingHost* host_; | 151 remoting::ChromotingHost* host_; |
152 DISALLOW_COPY_AND_ASSIGN(LocalInputMonitorMac); | 152 DISALLOW_COPY_AND_ASSIGN(LocalInputMonitorMac); |
153 }; | 153 }; |
154 | 154 |
155 base::LazyInstance<base::Lock> monitor_lock(base::LINKER_INITIALIZED); | 155 base::LazyInstance<base::Lock, |
| 156 base::LeakyLazyInstanceTraits<base::Lock> > |
| 157 monitor_lock(base::LINKER_INITIALIZED); |
156 LocalInputMonitorImpl* local_input_monitor = NULL; | 158 LocalInputMonitorImpl* local_input_monitor = NULL; |
157 | 159 |
158 } // namespace | 160 } // namespace |
159 | 161 |
160 LocalInputMonitorMac::~LocalInputMonitorMac() { | 162 LocalInputMonitorMac::~LocalInputMonitorMac() { |
161 Stop(); | 163 Stop(); |
162 } | 164 } |
163 | 165 |
164 void LocalInputMonitorMac::Start(remoting::ChromotingHost* host) { | 166 void LocalInputMonitorMac::Start(remoting::ChromotingHost* host) { |
165 base::AutoLock lock(monitor_lock.Get()); | 167 base::AutoLock lock(monitor_lock.Get()); |
166 if (!local_input_monitor) | 168 if (!local_input_monitor) |
167 local_input_monitor = [[LocalInputMonitorImpl alloc] init]; | 169 local_input_monitor = [[LocalInputMonitorImpl alloc] init]; |
168 CHECK(local_input_monitor); | 170 CHECK(local_input_monitor); |
169 [local_input_monitor addHost:host]; | 171 [local_input_monitor addHost:host]; |
170 host_ = host; | 172 host_ = host; |
171 } | 173 } |
172 | 174 |
173 void LocalInputMonitorMac::Stop() { | 175 void LocalInputMonitorMac::Stop() { |
174 base::AutoLock lock(monitor_lock.Get()); | 176 base::AutoLock lock(monitor_lock.Get()); |
175 if ([local_input_monitor removeHost:host_]) { | 177 if ([local_input_monitor removeHost:host_]) { |
176 [local_input_monitor invalidate]; | 178 [local_input_monitor invalidate]; |
177 [local_input_monitor release]; | 179 [local_input_monitor release]; |
178 local_input_monitor = nil; | 180 local_input_monitor = nil; |
179 } | 181 } |
180 } | 182 } |
181 | 183 |
182 remoting::LocalInputMonitor* remoting::LocalInputMonitor::Create() { | 184 remoting::LocalInputMonitor* remoting::LocalInputMonitor::Create() { |
183 return new LocalInputMonitorMac; | 185 return new LocalInputMonitorMac; |
184 } | 186 } |
OLD | NEW |