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

Side by Side Diff: components/gcm_driver/crypto/gcm_key_store.h

Issue 1701973003: Remove associated keying material when unregistering from GCM (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 COMPONENTS_GCM_DRIVER_CRYPTO_GCM_KEY_STORE_H_ 5 #ifndef COMPONENTS_GCM_DRIVER_CRYPTO_GCM_KEY_STORE_H_
6 #define COMPONENTS_GCM_DRIVER_CRYPTO_GCM_KEY_STORE_H_ 6 #define COMPONENTS_GCM_DRIVER_CRYPTO_GCM_KEY_STORE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 22 matching lines...) Expand all
33 // Messaging. It provides the ability to create and store a key-pair for a given 33 // Messaging. It provides the ability to create and store a key-pair for a given
34 // app id, as well as retrieving and deleting key-pairs. 34 // app id, as well as retrieving and deleting key-pairs.
35 // 35 //
36 // This class is backed by a proto database and might end up doing file I/O on 36 // This class is backed by a proto database and might end up doing file I/O on
37 // a background task runner. For this reason, all public APIs take a callback 37 // a background task runner. For this reason, all public APIs take a callback
38 // rather than returning the result. Do not rely on the timing of the callbacks. 38 // rather than returning the result. Do not rely on the timing of the callbacks.
39 class GCMKeyStore { 39 class GCMKeyStore {
40 public: 40 public:
41 using KeysCallback = base::Callback<void(const KeyPair& pair, 41 using KeysCallback = base::Callback<void(const KeyPair& pair,
42 const std::string& auth_secret)>; 42 const std::string& auth_secret)>;
43 using DeleteCallback = base::Callback<void(bool success)>;
44 43
45 GCMKeyStore( 44 GCMKeyStore(
46 const base::FilePath& key_store_path, 45 const base::FilePath& key_store_path,
47 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner); 46 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner);
48 ~GCMKeyStore(); 47 ~GCMKeyStore();
49 48
50 // Retrieves the public/private key-pair associated with |app_id|, and 49 // Retrieves the public/private key-pair associated with |app_id|, and
51 // invokes |callback| when they are available, or when an error occurred. 50 // invokes |callback| when they are available, or when an error occurred.
52 void GetKeys(const std::string& app_id, const KeysCallback& callback); 51 void GetKeys(const std::string& app_id, const KeysCallback& callback);
53 52
54 // Creates a new public/private key-pair for |app_id|, and invokes 53 // Creates a new public/private key-pair for |app_id|, and invokes
55 // |callback| when they are available, or when an error occurred. 54 // |callback| when they are available, or when an error occurred.
56 void CreateKeys(const std::string& app_id, const KeysCallback& callback); 55 void CreateKeys(const std::string& app_id, const KeysCallback& callback);
57 56
58 // Deletes the keys associated with |app_id|, and invokes |callback| when 57 // Removes the keys associated with |app_id|, and invokes |callback| when
59 // the deletion has finished, or when an error occurred. 58 // the operation has finished.
60 void DeleteKeys(const std::string& app_id, const DeleteCallback& callback); 59 void RemoveKeys(const std::string& app_id, const base::Closure& callback);
61 60
62 private: 61 private:
63 // Initializes the database if necessary, and runs |done_closure| when done. 62 // Initializes the database if necessary, and runs |done_closure| when done.
64 void LazyInitialize(const base::Closure& done_closure); 63 void LazyInitialize(const base::Closure& done_closure);
65 64
66 void DidInitialize(bool success); 65 void DidInitialize(bool success);
67 void DidLoadKeys(bool success, 66 void DidLoadKeys(bool success,
68 scoped_ptr<std::vector<EncryptionData>> entries); 67 scoped_ptr<std::vector<EncryptionData>> entries);
69 68
70 void DidStoreKeys(const std::string& app_id, 69 void DidStoreKeys(const std::string& app_id,
71 const KeyPair& pair, 70 const KeyPair& pair,
72 const std::string& auth_secret, 71 const std::string& auth_secret,
73 const KeysCallback& callback, 72 const KeysCallback& callback,
74 bool success); 73 bool success);
75 74
76 void DidDeleteKeys(const std::string& app_id, 75 void DidRemoveKeys(const std::string& app_id,
77 const DeleteCallback& callback, 76 const base::Closure& callback,
78 bool success); 77 bool success);
79 78
80 // Private implementations of the API that will be executed when the database 79 // Private implementations of the API that will be executed when the database
81 // has either been successfully loaded, or failed to load. 80 // has either been successfully loaded, or failed to load.
82 81
83 void GetKeysAfterInitialize(const std::string& app_id, 82 void GetKeysAfterInitialize(const std::string& app_id,
84 const KeysCallback& callback); 83 const KeysCallback& callback);
85 void CreateKeysAfterInitialize(const std::string& app_id, 84 void CreateKeysAfterInitialize(const std::string& app_id,
86 const KeysCallback& callback); 85 const KeysCallback& callback);
87 void DeleteKeysAfterInitialize(const std::string& app_id, 86 void RemoveKeysAfterInitialize(const std::string& app_id,
88 const DeleteCallback& callback); 87 const base::Closure& callback);
89 88
90 // Path in which the key store database will be saved. 89 // Path in which the key store database will be saved.
91 base::FilePath key_store_path_; 90 base::FilePath key_store_path_;
92 91
93 // Blocking task runner which the database will do I/O operations on. 92 // Blocking task runner which the database will do I/O operations on.
94 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; 93 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
95 94
96 // Instance of the ProtoDatabase backing the key store. 95 // Instance of the ProtoDatabase backing the key store.
97 scoped_ptr<leveldb_proto::ProtoDatabase<EncryptionData>> database_; 96 scoped_ptr<leveldb_proto::ProtoDatabase<EncryptionData>> database_;
98 97
(...skipping 12 matching lines...) Expand all
111 std::map<std::string, std::string> auth_secrets_; 110 std::map<std::string, std::string> auth_secrets_;
112 111
113 base::WeakPtrFactory<GCMKeyStore> weak_factory_; 112 base::WeakPtrFactory<GCMKeyStore> weak_factory_;
114 113
115 DISALLOW_COPY_AND_ASSIGN(GCMKeyStore); 114 DISALLOW_COPY_AND_ASSIGN(GCMKeyStore);
116 }; 115 };
117 116
118 } // namespace gcm 117 } // namespace gcm
119 118
120 #endif // COMPONENTS_GCM_DRIVER_CRYPTO_GCM_KEY_STORE_H_ 119 #endif // COMPONENTS_GCM_DRIVER_CRYPTO_GCM_KEY_STORE_H_
OLDNEW
« no previous file with comments | « components/gcm_driver/crypto/gcm_encryption_provider.cc ('k') | components/gcm_driver/crypto/gcm_key_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698