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

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

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