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

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

Issue 8934019: chromeos: Remove ScreenLockLibrary. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 9 years 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/cros/cros_library.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef CHROME_BROWSER_CHROMEOS_CROS_CROS_LIBRARY_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_CROS_CROS_LIBRARY_H_
6 #define CHROME_BROWSER_CHROMEOS_CROS_CROS_LIBRARY_H_ 6 #define CHROME_BROWSER_CHROMEOS_CROS_CROS_LIBRARY_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 12
13 namespace base { 13 namespace base {
14 template <typename T> struct DefaultLazyInstanceTraits; 14 template <typename T> struct DefaultLazyInstanceTraits;
15 } 15 }
16 16
17 namespace chromeos { 17 namespace chromeos {
18 18
19 class BurnLibrary; 19 class BurnLibrary;
20 class CertLibrary; 20 class CertLibrary;
21 class CryptohomeLibrary; 21 class CryptohomeLibrary;
22 class LibraryLoader; 22 class LibraryLoader;
23 class NetworkLibrary; 23 class NetworkLibrary;
24 class ScreenLockLibrary;
25 24
26 // This class handles access to sub-parts of ChromeOS library. it provides 25 // This class handles access to sub-parts of ChromeOS library. it provides
27 // a level of indirection so individual libraries that it exposes can 26 // a level of indirection so individual libraries that it exposes can
28 // be mocked for testing. 27 // be mocked for testing.
29 class CrosLibrary { 28 class CrosLibrary {
30 public: 29 public:
31 // This class provides access to internal members of CrosLibrary class for 30 // This class provides access to internal members of CrosLibrary class for
32 // purpose of testing (i.e. replacement of members' implementation with 31 // purpose of testing (i.e. replacement of members' implementation with
33 // mock objects). 32 // mock objects).
34 class TestApi { 33 class TestApi {
35 public: 34 public:
36 // Resets the stub implementation of the library and loads libcros. 35 // Resets the stub implementation of the library and loads libcros.
37 // Used by tests that need to run with libcros (i.e. on a device). 36 // Used by tests that need to run with libcros (i.e. on a device).
38 void ResetUseStubImpl(); 37 void ResetUseStubImpl();
39 38
40 // Passing true for own for these setters will cause them to be deleted 39 // Passing true for own for these setters will cause them to be deleted
41 // when the CrosLibrary is deleted (or other mocks are set). 40 // when the CrosLibrary is deleted (or other mocks are set).
42 // Setter for LibraryLoader. 41 // Setter for LibraryLoader.
43 void SetLibraryLoader(LibraryLoader* loader, bool own); 42 void SetLibraryLoader(LibraryLoader* loader, bool own);
44 void SetCertLibrary(CertLibrary* library, bool own); 43 void SetCertLibrary(CertLibrary* library, bool own);
45 void SetBurnLibrary(BurnLibrary* library, bool own); 44 void SetBurnLibrary(BurnLibrary* library, bool own);
46 void SetCryptohomeLibrary(CryptohomeLibrary* library, bool own); 45 void SetCryptohomeLibrary(CryptohomeLibrary* library, bool own);
47 void SetNetworkLibrary(NetworkLibrary* library, bool own); 46 void SetNetworkLibrary(NetworkLibrary* library, bool own);
48 void SetScreenLockLibrary(ScreenLockLibrary* library, bool own);
49 47
50 private: 48 private:
51 friend class CrosLibrary; 49 friend class CrosLibrary;
52 explicit TestApi(CrosLibrary* library) : library_(library) {} 50 explicit TestApi(CrosLibrary* library) : library_(library) {}
53 CrosLibrary* library_; 51 CrosLibrary* library_;
54 }; 52 };
55 53
56 // Sets the global instance. Must be called before any calls to Get(). 54 // Sets the global instance. Must be called before any calls to Get().
57 static void Initialize(bool use_stub); 55 static void Initialize(bool use_stub);
58 56
59 // Destroys the global instance. Must be called before AtExitManager is 57 // Destroys the global instance. Must be called before AtExitManager is
60 // destroyed to ensure a clean shutdown. 58 // destroyed to ensure a clean shutdown.
61 static void Shutdown(); 59 static void Shutdown();
62 60
63 // Gets the global instance. Returns NULL if Initialize() has not been 61 // Gets the global instance. Returns NULL if Initialize() has not been
64 // called (or Shutdown() has been called). 62 // called (or Shutdown() has been called).
65 static CrosLibrary* Get(); 63 static CrosLibrary* Get();
66 64
67 BurnLibrary* GetBurnLibrary(); 65 BurnLibrary* GetBurnLibrary();
68 CertLibrary* GetCertLibrary(); 66 CertLibrary* GetCertLibrary();
69 CryptohomeLibrary* GetCryptohomeLibrary(); 67 CryptohomeLibrary* GetCryptohomeLibrary();
70 NetworkLibrary* GetNetworkLibrary(); 68 NetworkLibrary* GetNetworkLibrary();
71 ScreenLockLibrary* GetScreenLockLibrary();
72 69
73 // Getter for Test API that gives access to internal members of this class. 70 // Getter for Test API that gives access to internal members of this class.
74 TestApi* GetTestApi(); 71 TestApi* GetTestApi();
75 72
76 bool libcros_loaded() { return libcros_loaded_; } 73 bool libcros_loaded() { return libcros_loaded_; }
77 74
78 // Returns an unlocalized string describing the last load error (if any). 75 // Returns an unlocalized string describing the last load error (if any).
79 const std::string& load_error_string() { 76 const std::string& load_error_string() {
80 return load_error_string_; 77 return load_error_string_;
81 } 78 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 121
125 private: 122 private:
126 L* library_; 123 L* library_;
127 bool own_; 124 bool own_;
128 }; 125 };
129 126
130 Library<BurnLibrary> burn_lib_; 127 Library<BurnLibrary> burn_lib_;
131 Library<CertLibrary> cert_lib_; 128 Library<CertLibrary> cert_lib_;
132 Library<CryptohomeLibrary> crypto_lib_; 129 Library<CryptohomeLibrary> crypto_lib_;
133 Library<NetworkLibrary> network_lib_; 130 Library<NetworkLibrary> network_lib_;
134 Library<ScreenLockLibrary> screen_lock_lib_;
135 131
136 // Stub implementations of the libraries should be used. 132 // Stub implementations of the libraries should be used.
137 bool use_stub_impl_; 133 bool use_stub_impl_;
138 // True if libcros was successfully loaded. 134 // True if libcros was successfully loaded.
139 bool libcros_loaded_; 135 bool libcros_loaded_;
140 // True if the last load attempt had an error. 136 // True if the last load attempt had an error.
141 bool load_error_; 137 bool load_error_;
142 // Contains the error string from the last load attempt. 138 // Contains the error string from the last load attempt.
143 std::string load_error_string_; 139 std::string load_error_string_;
144 scoped_ptr<TestApi> test_api_; 140 scoped_ptr<TestApi> test_api_;
(...skipping 13 matching lines...) Expand all
158 chromeos::CrosLibrary::Shutdown(); 154 chromeos::CrosLibrary::Shutdown();
159 } 155 }
160 156
161 private: 157 private:
162 DISALLOW_COPY_AND_ASSIGN(ScopedStubCrosEnabler); 158 DISALLOW_COPY_AND_ASSIGN(ScopedStubCrosEnabler);
163 }; 159 };
164 160
165 } // namespace chromeos 161 } // namespace chromeos
166 162
167 #endif // CHROME_BROWSER_CHROMEOS_CROS_CROS_LIBRARY_H_ 163 #endif // CHROME_BROWSER_CHROMEOS_CROS_CROS_LIBRARY_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/cros/cros_library.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698