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

Side by Side Diff: chromeos/dbus/fake_cryptohome_client.h

Issue 34303002: chromeos: Wait for service to be available when getting system salt (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add test Created 7 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
« no previous file with comments | « chromeos/dbus/cryptohome_client.cc ('k') | chromeos/dbus/fake_cryptohome_client.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 CHROMEOS_DBUS_FAKE_CRYPTOHOME_CLIENT_H_ 5 #ifndef CHROMEOS_DBUS_FAKE_CRYPTOHOME_CLIENT_H_
6 #define CHROMEOS_DBUS_FAKE_CRYPTOHOME_CLIENT_H_ 6 #define CHROMEOS_DBUS_FAKE_CRYPTOHOME_CLIENT_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "chromeos/dbus/cryptohome_client.h" 12 #include "chromeos/dbus/cryptohome_client.h"
13 13
14 namespace chromeos { 14 namespace chromeos {
15 15
16 class CHROMEOS_EXPORT FakeCryptohomeClient : public CryptohomeClient { 16 class CHROMEOS_EXPORT FakeCryptohomeClient : public CryptohomeClient {
17 public: 17 public:
18 FakeCryptohomeClient(); 18 FakeCryptohomeClient();
19 virtual ~FakeCryptohomeClient(); 19 virtual ~FakeCryptohomeClient();
20 20
21 virtual void Init(dbus::Bus* bus) OVERRIDE; 21 virtual void Init(dbus::Bus* bus) OVERRIDE;
22 virtual void SetAsyncCallStatusHandlers( 22 virtual void SetAsyncCallStatusHandlers(
23 const AsyncCallStatusHandler& handler, 23 const AsyncCallStatusHandler& handler,
24 const AsyncCallStatusWithDataHandler& data_handler) OVERRIDE; 24 const AsyncCallStatusWithDataHandler& data_handler) OVERRIDE;
25 virtual void ResetAsyncCallStatusHandlers() OVERRIDE; 25 virtual void ResetAsyncCallStatusHandlers() OVERRIDE;
26 virtual void WaitForServiceToBeAvailable(
27 const WaitForServiceToBeAvailableCallback& callback) OVERRIDE;
26 virtual void IsMounted(const BoolDBusMethodCallback& callback) OVERRIDE; 28 virtual void IsMounted(const BoolDBusMethodCallback& callback) OVERRIDE;
27 virtual bool Unmount(bool* success) OVERRIDE; 29 virtual bool Unmount(bool* success) OVERRIDE;
28 virtual void AsyncCheckKey(const std::string& username, 30 virtual void AsyncCheckKey(const std::string& username,
29 const std::string& key, 31 const std::string& key,
30 const AsyncMethodCallback& callback) OVERRIDE; 32 const AsyncMethodCallback& callback) OVERRIDE;
31 virtual void AsyncMigrateKey(const std::string& username, 33 virtual void AsyncMigrateKey(const std::string& username,
32 const std::string& from_key, 34 const std::string& from_key,
33 const std::string& to_key, 35 const std::string& to_key,
34 const AsyncMethodCallback& callback) OVERRIDE; 36 const AsyncMethodCallback& callback) OVERRIDE;
35 virtual void AsyncRemove(const std::string& username, 37 virtual void AsyncRemove(const std::string& username,
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 const std::string& user_id, 146 const std::string& user_id,
145 const std::string& key_name, 147 const std::string& key_name,
146 const DataMethodCallback& callback) OVERRIDE; 148 const DataMethodCallback& callback) OVERRIDE;
147 virtual void TpmAttestationSetKeyPayload( 149 virtual void TpmAttestationSetKeyPayload(
148 attestation::AttestationKeyType key_type, 150 attestation::AttestationKeyType key_type,
149 const std::string& user_id, 151 const std::string& user_id,
150 const std::string& key_name, 152 const std::string& key_name,
151 const std::string& payload, 153 const std::string& payload,
152 const BoolDBusMethodCallback& callback) OVERRIDE; 154 const BoolDBusMethodCallback& callback) OVERRIDE;
153 155
156 // Changes the behavior of WaitForServiceToBeAvailable().
satorux1 2013/10/22 05:08:10 Please document that setting this true runs pendin
hashimoto 2013/10/22 05:11:53 Done.
157 void SetServiceIsAvailable(bool is_available);
158
154 // Sets the unmount result of Unmount() call. 159 // Sets the unmount result of Unmount() call.
155 void set_unmount_result(bool result) { 160 void set_unmount_result(bool result) {
156 unmount_result_= result; 161 unmount_result_= result;
157 } 162 }
158 163
159 // Returns the stub system salt as raw bytes. (not as a string encoded in the 164 // Returns the stub system salt as raw bytes. (not as a string encoded in the
160 // format used by SystemSaltGetter::ConvertRawSaltToHexString()). 165 // format used by SystemSaltGetter::ConvertRawSaltToHexString()).
161 static std::vector<uint8> GetStubSystemSalt(); 166 static std::vector<uint8> GetStubSystemSalt();
162 167
163 private: 168 private:
164 // Posts tasks which return fake results to the UI thread. 169 // Posts tasks which return fake results to the UI thread.
165 void ReturnAsyncMethodResult(const AsyncMethodCallback& callback, 170 void ReturnAsyncMethodResult(const AsyncMethodCallback& callback,
166 bool returns_data); 171 bool returns_data);
167 172
168 // This method is used to implement ReturnAsyncMethodResult. 173 // This method is used to implement ReturnAsyncMethodResult.
169 void ReturnAsyncMethodResultInternal(const AsyncMethodCallback& callback, 174 void ReturnAsyncMethodResultInternal(const AsyncMethodCallback& callback,
170 bool returns_data); 175 bool returns_data);
171 176
177 bool service_is_available_;
172 int async_call_id_; 178 int async_call_id_;
173 AsyncCallStatusHandler async_call_status_handler_; 179 AsyncCallStatusHandler async_call_status_handler_;
174 AsyncCallStatusWithDataHandler async_call_status_data_handler_; 180 AsyncCallStatusWithDataHandler async_call_status_data_handler_;
175 int tpm_is_ready_counter_; 181 int tpm_is_ready_counter_;
176 bool unmount_result_; 182 bool unmount_result_;
177 183
184 std::vector<WaitForServiceToBeAvailableCallback>
185 pending_wait_for_service_to_be_available_callbacks_;
186
178 // A stub store for InstallAttributes, mapping an attribute name to the 187 // A stub store for InstallAttributes, mapping an attribute name to the
179 // associated data blob. Used to implement InstallAttributesSet and -Get. 188 // associated data blob. Used to implement InstallAttributesSet and -Get.
180 std::map<std::string, std::vector<uint8> > install_attrs_; 189 std::map<std::string, std::vector<uint8> > install_attrs_;
181 bool locked_; 190 bool locked_;
182 base::WeakPtrFactory<FakeCryptohomeClient> weak_ptr_factory_; 191 base::WeakPtrFactory<FakeCryptohomeClient> weak_ptr_factory_;
183 192
184 DISALLOW_COPY_AND_ASSIGN(FakeCryptohomeClient); 193 DISALLOW_COPY_AND_ASSIGN(FakeCryptohomeClient);
185 }; 194 };
186 195
187 } // namespace chromeos 196 } // namespace chromeos
188 197
189 #endif // CHROMEOS_DBUS_FAKE_CRYPTOHOME_CLIENT_H_ 198 #endif // CHROMEOS_DBUS_FAKE_CRYPTOHOME_CLIENT_H_
OLDNEW
« no previous file with comments | « chromeos/dbus/cryptohome_client.cc ('k') | chromeos/dbus/fake_cryptohome_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698