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

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, 5 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 19 matching lines...) Expand all
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(const base::FilePath& key_store_path,
40 scoped_refptr<base::SequencedTaskRunner> background_task_runner); 40 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner);
41 41
42 // Retrieves the public/private key-pair associated with |app_id|, and 42 // Retrieves the public/private key-pair associated with |app_id|, and
43 // invokes |callback| when they are available, or when an error occurred. 43 // invokes |callback| when they are available, or when an error occurred.
44 void GetKeys(const std::string& app_id, const KeysCallback& callback); 44 void GetKeys(const std::string& app_id, const KeysCallback& callback);
45 45
46 // Creates a new public/private key-pair for |app_id|, and invokes 46 // Creates a new public/private key-pair for |app_id|, and invokes
47 // |callback| when they are available, or when an error occurred. 47 // |callback| when they are available, or when an error occurred.
48 void CreateKeys(const std::string& app_id, const KeysCallback& callback); 48 void CreateKeys(const std::string& app_id, const KeysCallback& callback);
49 49
50 // Deletes the keys associated with |app_id|, and invokes |callback| when 50 // 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, 78 void GetKeysAfterInitialize(const std::string& app_id,
79 const KeysCallback& callback); 79 const KeysCallback& callback);
80 void CreateKeysAfterInitialize(const std::string& app_id, 80 void CreateKeysAfterInitialize(const std::string& app_id,
81 const KeysCallback& callback); 81 const KeysCallback& callback);
82 void DeleteKeysAfterInitialize(const std::string& app_id, 82 void DeleteKeysAfterInitialize(const std::string& app_id,
83 const DeleteCallback& callback); 83 const DeleteCallback& callback);
84 84
85 // Path in which the key store database will be saved. 85 // Path in which the key store database will be saved.
86 base::FilePath key_store_path_; 86 base::FilePath key_store_path_;
87 87
88 // Blocking task runner which the database will do I/O operations on.
89 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
90
88 // Instance of the ProtoDatabase backing the key store. 91 // Instance of the ProtoDatabase backing the key store.
89 scoped_ptr<leveldb_proto::ProtoDatabase<EncryptionData>> database_; 92 scoped_ptr<leveldb_proto::ProtoDatabase<EncryptionData>> database_;
90 93
91 enum class State; 94 enum class State;
92 95
93 // The current state of the database. It has to be initialized before use. 96 // The current state of the database. It has to be initialized before use.
94 State state_; 97 State state_;
95 98
96 // Controller for tasks that should be executed once the key store has 99 // Controller for tasks that should be executed once the key store has
97 // finished initializing. 100 // finished initializing.
98 GCMDelayedTaskController delayed_task_controller_; 101 GCMDelayedTaskController delayed_task_controller_;
99 102
100 // Mapping of an app id to the loaded EncryptedData structure. 103 // Mapping of an app id to the loaded EncryptedData structure.
101 std::map<std::string, KeyPair> key_pairs_; 104 std::map<std::string, KeyPair> key_pairs_;
102 105
103 DISALLOW_COPY_AND_ASSIGN(GCMKeyStore); 106 DISALLOW_COPY_AND_ASSIGN(GCMKeyStore);
104 }; 107 };
105 108
106 } // namespace gcm 109 } // namespace gcm
107 110
108 #endif // COMPONENTS_GCM_DRIVER_CRYPTO_GCM_KEY_STORE_H_ 111 #endif // COMPONENTS_GCM_DRIVER_CRYPTO_GCM_KEY_STORE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698