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

Side by Side Diff: chrome/browser/chromeos/cros/libcros_service_library.cc

Issue 7891021: Use stub impl when libcros fails to load (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix power manager stub impl Created 9 years, 3 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 | 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 "chrome/browser/chromeos/cros/libcros_service_library.h" 5 #include "chrome/browser/chromeos/cros/libcros_service_library.h"
6 6
7 #include "base/synchronization/lock.h" 7 #include "base/synchronization/lock.h"
8 #include "chrome/browser/chromeos/cros/cros_library.h" 8 #include "chrome/browser/chromeos/cros/cros_library.h"
9 #include "chrome/browser/profiles/profile_manager.h" 9 #include "chrome/browser/profiles/profile_manager.h"
10 #include "content/browser/browser_thread.h" 10 #include "content/browser/browser_thread.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 // Libraries that form LibCrosService. 101 // Libraries that form LibCrosService.
102 scoped_ptr<NetworkProxyLibrary> network_proxy_lib_; 102 scoped_ptr<NetworkProxyLibrary> network_proxy_lib_;
103 103
104 DISALLOW_COPY_AND_ASSIGN(LibCrosServiceLibraryImpl); 104 DISALLOW_COPY_AND_ASSIGN(LibCrosServiceLibraryImpl);
105 }; 105 };
106 106
107 //---------------- LibCrosServiceLibraryImpl: public --------------------------- 107 //---------------- LibCrosServiceLibraryImpl: public ---------------------------
108 108
109 LibCrosServiceLibraryImpl::LibCrosServiceLibraryImpl() 109 LibCrosServiceLibraryImpl::LibCrosServiceLibraryImpl()
110 : service_connection_(NULL) { 110 : service_connection_(NULL) {
111 if (!CrosLibrary::Get()->EnsureLoaded()) {
112 LOG(ERROR) << "Cros library has not been loaded.";
113 }
114 } 111 }
115 112
116 LibCrosServiceLibraryImpl::~LibCrosServiceLibraryImpl() { 113 LibCrosServiceLibraryImpl::~LibCrosServiceLibraryImpl() {
117 if (service_connection_) { 114 if (service_connection_) {
118 // Clear service connections in servicing libraries which held the former 115 // Clear service connections in servicing libraries which held the former
119 // as weak pointers. 116 // as weak pointers.
120 if (network_proxy_lib_.get()) 117 if (network_proxy_lib_.get())
121 network_proxy_lib_->ClearServiceConnection(); 118 network_proxy_lib_->ClearServiceConnection();
122 119
123 StopLibCrosService(service_connection_); 120 StopLibCrosService(service_connection_);
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 // LibCrosServiceLibrary overrides. 297 // LibCrosServiceLibrary overrides.
301 virtual void StartService() {} 298 virtual void StartService() {}
302 299
303 DISALLOW_COPY_AND_ASSIGN(LibCrosServiceLibraryStubImpl); 300 DISALLOW_COPY_AND_ASSIGN(LibCrosServiceLibraryStubImpl);
304 }; 301 };
305 302
306 //--------------------------- LibCrosServiceLibrary ---------------------------- 303 //--------------------------- LibCrosServiceLibrary ----------------------------
307 304
308 // Static. 305 // Static.
309 LibCrosServiceLibrary* LibCrosServiceLibrary::GetImpl(bool stub) { 306 LibCrosServiceLibrary* LibCrosServiceLibrary::GetImpl(bool stub) {
307 LibCrosServiceLibrary* impl;
310 if (stub) 308 if (stub)
311 return new LibCrosServiceLibraryStubImpl(); 309 impl = new LibCrosServiceLibraryStubImpl();
312 return new LibCrosServiceLibraryImpl(); 310 else
311 impl = new LibCrosServiceLibraryImpl();
312 return impl;
313 } 313 }
314 314
315 } // namespace chromeos 315 } // namespace chromeos
316 316
317 // Allows InvokeLater without adding refcounting. This class is a Singleton and 317 // Allows InvokeLater without adding refcounting. This class is a Singleton and
318 // won't be deleted until it's last InvokeLater is run, so are all its 318 // won't be deleted until it's last InvokeLater is run, so are all its
319 // scoped_ptred class members. 319 // scoped_ptred class members.
320 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::LibCrosServiceLibraryImpl); 320 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::LibCrosServiceLibraryImpl);
321 DISABLE_RUNNABLE_METHOD_REFCOUNT( 321 DISABLE_RUNNABLE_METHOD_REFCOUNT(
322 chromeos::LibCrosServiceLibraryImpl::NetworkProxyLibrary); 322 chromeos::LibCrosServiceLibraryImpl::NetworkProxyLibrary);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698