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

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

Issue 1231613005: Hook up the Push API with GCM's new ability to own encryption keys. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gcm-encryption
Patch Set: Created 5 years, 4 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 9
10 #include "base/callback_forward.h" 10 #include "base/callback_forward.h"
(...skipping 18 matching lines...) Expand all
29 // a background task runner. For this reason, all public APIs take a callback 29 // a background task runner. For this reason, all public APIs take a callback
30 // rather than returning the result. Do not rely on the timing of the callbacks. 30 // rather than returning the result. Do not rely on the timing of the callbacks.
31 // 31 //
32 // Started operations will be completed even after the reference to the store 32 // Started operations will be completed even after the reference to the store
33 // has been freed (asynchronous operations increase reference count to |this|). 33 // has been freed (asynchronous operations increase reference count to |this|).
34 class GCMKeyStore : public base::RefCounted<GCMKeyStore> { 34 class GCMKeyStore : public base::RefCounted<GCMKeyStore> {
35 public: 35 public:
36 using KeysCallback = base::Callback<void(const KeyPair& pair)>; 36 using KeysCallback = base::Callback<void(const KeyPair& pair)>;
37 using DeleteCallback = base::Callback<void(bool success)>; 37 using DeleteCallback = base::Callback<void(bool success)>;
38 38
39 GCMKeyStore(const base::FilePath& key_store_path, 39 GCMKeyStore(
40 scoped_refptr<base::SequencedTaskRunner> background_task_runner); 40 const base::FilePath& key_store_path,
41 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner);
41 42
42 // Retrieves the public/private key-pair associated with |app_id|, and 43 // Retrieves the public/private key-pair associated with |app_id|, and
43 // invokes |callback| when they are available, or when an error occurred. 44 // invokes |callback| when they are available, or when an error occurred.
44 void GetKeys(const std::string& app_id, const KeysCallback& callback); 45 void GetKeys(const std::string& app_id, const KeysCallback& callback);
45 46
46 // Creates a new public/private key-pair for |app_id|, and invokes 47 // Creates a new public/private key-pair for |app_id|, and invokes
47 // |callback| when they are available, or when an error occurred. 48 // |callback| when they are available, or when an error occurred.
48 void CreateKeys(const std::string& app_id, const KeysCallback& callback); 49 void CreateKeys(const std::string& app_id, const KeysCallback& callback);
49 50
50 // Deletes the keys associated with |app_id|, and invokes |callback| when 51 // Deletes the keys associated with |app_id|, and invokes |callback| when
(...skipping 27 matching lines...) Expand all
78 void GetKeysAfterInitialize(const std::string& app_id, 79 void GetKeysAfterInitialize(const std::string& app_id,
79 const KeysCallback& callback); 80 const KeysCallback& callback);
80 void CreateKeysAfterInitialize(const std::string& app_id, 81 void CreateKeysAfterInitialize(const std::string& app_id,
81 const KeysCallback& callback); 82 const KeysCallback& callback);
82 void DeleteKeysAfterInitialize(const std::string& app_id, 83 void DeleteKeysAfterInitialize(const std::string& app_id,
83 const DeleteCallback& callback); 84 const DeleteCallback& callback);
84 85
85 // Path in which the key store database will be saved. 86 // Path in which the key store database will be saved.
86 base::FilePath key_store_path_; 87 base::FilePath key_store_path_;
87 88
89 // Blocking task runner which the database will do I/O operations on.
90 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
91
88 // Instance of the ProtoDatabase backing the key store. 92 // Instance of the ProtoDatabase backing the key store.
89 scoped_ptr<leveldb_proto::ProtoDatabase<EncryptionData>> database_; 93 scoped_ptr<leveldb_proto::ProtoDatabase<EncryptionData>> database_;
90 94
91 enum class State; 95 enum class State;
92 96
93 // The current state of the database. It has to be initialized before use. 97 // The current state of the database. It has to be initialized before use.
94 State state_; 98 State state_;
95 99
96 // Controller for tasks that should be executed once the key store has 100 // Controller for tasks that should be executed once the key store has
97 // finished initializing. 101 // finished initializing.
98 GCMDelayedTaskController delayed_task_controller_; 102 GCMDelayedTaskController delayed_task_controller_;
99 103
100 // Mapping of an app id to the loaded EncryptedData structure. 104 // Mapping of an app id to the loaded EncryptedData structure.
101 std::map<std::string, KeyPair> key_pairs_; 105 std::map<std::string, KeyPair> key_pairs_;
102 106
103 DISALLOW_COPY_AND_ASSIGN(GCMKeyStore); 107 DISALLOW_COPY_AND_ASSIGN(GCMKeyStore);
104 }; 108 };
105 109
106 } // namespace gcm 110 } // namespace gcm
107 111
108 #endif // COMPONENTS_GCM_DRIVER_CRYPTO_GCM_KEY_STORE_H_ 112 #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