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

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

Issue 7891021: Use stub impl when libcros fails to load (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase with power library changes 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/cros_library.h" 5 #include "chrome/browser/chromeos/cros/cros_library.h"
6 6
7 #include "chrome/browser/chromeos/cros/brightness_library.h" 7 #include "chrome/browser/chromeos/cros/brightness_library.h"
8 #include "chrome/browser/chromeos/cros/burn_library.h" 8 #include "chrome/browser/chromeos/cros/burn_library.h"
9 #include "chrome/browser/chromeos/cros/cert_library.h" 9 #include "chrome/browser/chromeos/cros/cert_library.h"
10 #include "chrome/browser/chromeos/cros/cryptohome_library.h" 10 #include "chrome/browser/chromeos/cros/cryptohome_library.h"
11 #include "chrome/browser/chromeos/cros/library_loader.h" 11 #include "chrome/browser/chromeos/cros/library_loader.h"
12 #include "chrome/browser/chromeos/cros/login_library.h" 12 #include "chrome/browser/chromeos/cros/login_library.h"
13 #include "chrome/browser/chromeos/cros/mount_library.h" 13 #include "chrome/browser/chromeos/cros/mount_library.h"
14 #include "chrome/browser/chromeos/cros/network_library.h" 14 #include "chrome/browser/chromeos/cros/network_library.h"
15 #include "chrome/browser/chromeos/cros/power_library.h" 15 #include "chrome/browser/chromeos/cros/power_library.h"
16 #include "chrome/browser/chromeos/cros/screen_lock_library.h" 16 #include "chrome/browser/chromeos/cros/screen_lock_library.h"
17 #include "chrome/browser/chromeos/cros/speech_synthesis_library.h" 17 #include "chrome/browser/chromeos/cros/speech_synthesis_library.h"
18 #include "chrome/browser/chromeos/cros/update_library.h" 18 #include "chrome/browser/chromeos/cros/update_library.h"
19 #include "third_party/cros/chromeos_cros_api.h" 19 #include "third_party/cros/chromeos_cros_api.h"
20 20
21 // Pass !libcros_loaded_ to GetDefaultImpl instead of use_stub_impl_ so that
22 // we load the stub impl regardless of whether use_stub was specified or the
23 // library failed to load.
21 #define DEFINE_GET_LIBRARY_METHOD(class_prefix, var_prefix) \ 24 #define DEFINE_GET_LIBRARY_METHOD(class_prefix, var_prefix) \
22 class_prefix##Library* CrosLibrary::Get##class_prefix##Library() { \ 25 class_prefix##Library* CrosLibrary::Get##class_prefix##Library() { \
23 return var_prefix##_lib_.GetDefaultImpl(use_stub_impl_); \ 26 return var_prefix##_lib_.GetDefaultImpl(!libcros_loaded_); \
24 } 27 }
25 28
26 #define DEFINE_SET_LIBRARY_METHOD(class_prefix, var_prefix) \ 29 #define DEFINE_SET_LIBRARY_METHOD(class_prefix, var_prefix) \
27 void CrosLibrary::TestApi::Set##class_prefix##Library( \ 30 void CrosLibrary::TestApi::Set##class_prefix##Library( \
28 class_prefix##Library* library, bool own) { \ 31 class_prefix##Library* library, bool own) { \
29 library_->var_prefix##_lib_.SetImpl(library, own); \ 32 library_->var_prefix##_lib_.SetImpl(library, own); \
30 } 33 }
31 34
32 namespace chromeos { 35 namespace chromeos {
33 36
(...skipping 16 matching lines...) Expand all
50 // static 53 // static
51 void CrosLibrary::Initialize(bool use_stub) { 54 void CrosLibrary::Initialize(bool use_stub) {
52 CHECK(!g_cros_library) << "CrosLibrary: Multiple calls to Initialize()."; 55 CHECK(!g_cros_library) << "CrosLibrary: Multiple calls to Initialize().";
53 g_cros_library = new CrosLibrary(use_stub); 56 g_cros_library = new CrosLibrary(use_stub);
54 if (use_stub) { 57 if (use_stub) {
55 VLOG(1) << "CrosLibrary Initialized with Stub Impl."; 58 VLOG(1) << "CrosLibrary Initialized with Stub Impl.";
56 return; 59 return;
57 } 60 }
58 // Attempt to load libcros here, so that we can log, show warnings, and 61 // Attempt to load libcros here, so that we can log, show warnings, and
59 // set load_error_string_ immediately. 62 // set load_error_string_ immediately.
60 if (g_cros_library->LoadLibcros()) 63 if (g_cros_library->LoadLibcros()) {
61 VLOG(1) << "CrosLibrary Initialized, version = " << kCrosAPIVersion; 64 VLOG(1) << "CrosLibrary Initialized, version = " << kCrosAPIVersion;
62 else 65 } else {
63 LOG(WARNING) << "CrosLibrary failed to Initialize."; 66 LOG(WARNING) << "CrosLibrary failed to Initialize."
67 << " Will use stub implementations.";
68 }
64 } 69 }
65 70
66 // static 71 // static
67 void CrosLibrary::Shutdown() { 72 void CrosLibrary::Shutdown() {
68 CHECK(g_cros_library) << "CrosLibrary::Shutdown() called with NULL library"; 73 CHECK(g_cros_library) << "CrosLibrary::Shutdown() called with NULL library";
69 VLOG(1) << "CrosLibrary Shutting down..."; 74 VLOG(1) << "CrosLibrary Shutting down...";
70 delete g_cros_library; 75 delete g_cros_library;
71 g_cros_library = NULL; 76 g_cros_library = NULL;
72 VLOG(1) << " CrosLibrary Shutdown completed."; 77 VLOG(1) << " CrosLibrary Shutdown completed.";
73 } 78 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 DEFINE_SET_LIBRARY_METHOD(Cryptohome, crypto); 137 DEFINE_SET_LIBRARY_METHOD(Cryptohome, crypto);
133 DEFINE_SET_LIBRARY_METHOD(Login, login); 138 DEFINE_SET_LIBRARY_METHOD(Login, login);
134 DEFINE_SET_LIBRARY_METHOD(Mount, mount); 139 DEFINE_SET_LIBRARY_METHOD(Mount, mount);
135 DEFINE_SET_LIBRARY_METHOD(Network, network); 140 DEFINE_SET_LIBRARY_METHOD(Network, network);
136 DEFINE_SET_LIBRARY_METHOD(Power, power); 141 DEFINE_SET_LIBRARY_METHOD(Power, power);
137 DEFINE_SET_LIBRARY_METHOD(ScreenLock, screen_lock); 142 DEFINE_SET_LIBRARY_METHOD(ScreenLock, screen_lock);
138 DEFINE_SET_LIBRARY_METHOD(SpeechSynthesis, speech_synthesis); 143 DEFINE_SET_LIBRARY_METHOD(SpeechSynthesis, speech_synthesis);
139 DEFINE_SET_LIBRARY_METHOD(Update, update); 144 DEFINE_SET_LIBRARY_METHOD(Update, update);
140 145
141 } // namespace chromeos 146 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/cros/burn_library.cc ('k') | chrome/browser/chromeos/cros/cryptohome_library.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698