| 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/bind.h" | 10 #include "base/bind.h" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 virtual void Start(remoting::ChromotingHost* host) OVERRIDE; | 148 virtual void Start(remoting::ChromotingHost* host) OVERRIDE; |
| 149 virtual void Stop() OVERRIDE; | 149 virtual void Stop() OVERRIDE; |
| 150 | 150 |
| 151 private: | 151 private: |
| 152 remoting::ChromotingHost* host_; | 152 remoting::ChromotingHost* host_; |
| 153 DISALLOW_COPY_AND_ASSIGN(LocalInputMonitorMac); | 153 DISALLOW_COPY_AND_ASSIGN(LocalInputMonitorMac); |
| 154 }; | 154 }; |
| 155 | 155 |
| 156 base::LazyInstance<base::Lock, | 156 base::LazyInstance<base::Lock, |
| 157 base::LeakyLazyInstanceTraits<base::Lock> > | 157 base::LeakyLazyInstanceTraits<base::Lock> > |
| 158 monitor_lock(base::LINKER_INITIALIZED); | 158 monitor_lock = LAZY_INSTANCE_INITIALIZER; |
| 159 LocalInputMonitorImpl* local_input_monitor = NULL; | 159 LocalInputMonitorImpl* local_input_monitor = NULL; |
| 160 | 160 |
| 161 } // namespace | 161 } // namespace |
| 162 | 162 |
| 163 LocalInputMonitorMac::~LocalInputMonitorMac() { | 163 LocalInputMonitorMac::~LocalInputMonitorMac() { |
| 164 Stop(); | 164 Stop(); |
| 165 } | 165 } |
| 166 | 166 |
| 167 void LocalInputMonitorMac::Start(remoting::ChromotingHost* host) { | 167 void LocalInputMonitorMac::Start(remoting::ChromotingHost* host) { |
| 168 base::AutoLock lock(monitor_lock.Get()); | 168 base::AutoLock lock(monitor_lock.Get()); |
| 169 if (!local_input_monitor) | 169 if (!local_input_monitor) |
| 170 local_input_monitor = [[LocalInputMonitorImpl alloc] init]; | 170 local_input_monitor = [[LocalInputMonitorImpl alloc] init]; |
| 171 CHECK(local_input_monitor); | 171 CHECK(local_input_monitor); |
| 172 [local_input_monitor addHost:host]; | 172 [local_input_monitor addHost:host]; |
| 173 host_ = host; | 173 host_ = host; |
| 174 } | 174 } |
| 175 | 175 |
| 176 void LocalInputMonitorMac::Stop() { | 176 void LocalInputMonitorMac::Stop() { |
| 177 base::AutoLock lock(monitor_lock.Get()); | 177 base::AutoLock lock(monitor_lock.Get()); |
| 178 if ([local_input_monitor removeHost:host_]) { | 178 if ([local_input_monitor removeHost:host_]) { |
| 179 [local_input_monitor invalidate]; | 179 [local_input_monitor invalidate]; |
| 180 [local_input_monitor release]; | 180 [local_input_monitor release]; |
| 181 local_input_monitor = nil; | 181 local_input_monitor = nil; |
| 182 } | 182 } |
| 183 } | 183 } |
| 184 | 184 |
| 185 remoting::LocalInputMonitor* remoting::LocalInputMonitor::Create() { | 185 remoting::LocalInputMonitor* remoting::LocalInputMonitor::Create() { |
| 186 return new LocalInputMonitorMac; | 186 return new LocalInputMonitorMac; |
| 187 } | 187 } |
| OLD | NEW |