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

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

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 #include "components/gcm_driver/crypto/gcm_key_store.h" 5 #include "components/gcm_driver/crypto/gcm_key_store.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "components/leveldb_proto/proto_database_impl.h" 10 #include "components/leveldb_proto/proto_database_impl.h"
11 #include "crypto/curve25519.h" 11 #include "crypto/curve25519.h"
12 #include "crypto/random.h" 12 #include "crypto/random.h"
13 13
14 namespace gcm { 14 namespace gcm {
15 15
16 enum class GCMKeyStore::State { 16 enum class GCMKeyStore::State {
17 UNINITIALIZED, 17 UNINITIALIZED,
18 INITIALIZING, 18 INITIALIZING,
19 INITIALIZED, 19 INITIALIZED,
20 FAILED 20 FAILED
21 }; 21 };
22 22
23 GCMKeyStore::GCMKeyStore( 23 GCMKeyStore::GCMKeyStore(
24 const base::FilePath& key_store_path, 24 const base::FilePath& key_store_path,
25 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner) 25 scoped_refptr<base::SequencedTaskRunner> background_task_runner)
26 : key_store_path_(key_store_path), 26 : key_store_path_(key_store_path),
27 blocking_task_runner_(blocking_task_runner), 27 database_(new leveldb_proto::ProtoDatabaseImpl<EncryptionData>(
28 background_task_runner)),
28 state_(State::UNINITIALIZED) { 29 state_(State::UNINITIALIZED) {
29 DCHECK(blocking_task_runner);
30 } 30 }
31 31
32 GCMKeyStore::~GCMKeyStore() {} 32 GCMKeyStore::~GCMKeyStore() {}
33 33
34 void GCMKeyStore::GetKeys(const std::string& app_id, 34 void GCMKeyStore::GetKeys(const std::string& app_id,
35 const KeysCallback& callback) { 35 const KeysCallback& callback) {
36 LazyInitialize(base::Bind(&GCMKeyStore::GetKeysAfterInitialize, this, app_id, 36 LazyInitialize(base::Bind(&GCMKeyStore::GetKeysAfterInitialize, this, app_id,
37 callback)); 37 callback));
38 } 38 }
39 39
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 done_closure.Run(); 161 done_closure.Run();
162 return; 162 return;
163 } 163 }
164 164
165 delayed_task_controller_.AddTask(done_closure); 165 delayed_task_controller_.AddTask(done_closure);
166 if (state_ == State::INITIALIZING) 166 if (state_ == State::INITIALIZING)
167 return; 167 return;
168 168
169 state_ = State::INITIALIZING; 169 state_ = State::INITIALIZING;
170 170
171 database_.reset(new leveldb_proto::ProtoDatabaseImpl<EncryptionData>(
172 blocking_task_runner_));
173
174 database_->Init(key_store_path_, 171 database_->Init(key_store_path_,
175 base::Bind(&GCMKeyStore::DidInitialize, this)); 172 base::Bind(&GCMKeyStore::DidInitialize, this));
176 } 173 }
177 174
178 void GCMKeyStore::DidInitialize(bool success) { 175 void GCMKeyStore::DidInitialize(bool success) {
179 if (!success) { 176 if (!success) {
180 DVLOG(1) << "Unable to initialize the GCM Key Store."; 177 DVLOG(1) << "Unable to initialize the GCM Key Store.";
181 state_ = State::FAILED; 178 state_ = State::FAILED;
182 179
183 delayed_task_controller_.SetReady(); 180 delayed_task_controller_.SetReady();
(...skipping 17 matching lines...) Expand all
201 DCHECK_EQ(1, entry.keys_size()); 198 DCHECK_EQ(1, entry.keys_size());
202 key_pairs_[entry.app_id()] = entry.keys(0); 199 key_pairs_[entry.app_id()] = entry.keys(0);
203 } 200 }
204 201
205 state_ = State::INITIALIZED; 202 state_ = State::INITIALIZED;
206 203
207 delayed_task_controller_.SetReady(); 204 delayed_task_controller_.SetReady();
208 } 205 }
209 206
210 } // namespace gcm 207 } // namespace gcm
OLDNEW
« no previous file with comments | « components/gcm_driver/crypto/gcm_key_store.h ('k') | components/gcm_driver/crypto/gcm_key_store_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698