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

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

Issue 8430019: Make LazyInstance managed Locks leaky. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: 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/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
OLDNEW
« no previous file with comments | « content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.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