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

Side by Side Diff: remoting/host/local_input_monitor_mac.mm

Issue 8491043: Allow linker initialization of lazy instance (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: willchan comments + rebase Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
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
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 }
OLDNEW
« no previous file with comments | « remoting/client/plugin/chromoting_instance.cc ('k') | remoting/host/local_input_monitor_thread_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698