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

Side by Side Diff: components/gcm_driver/gcm_driver.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, 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
« no previous file with comments | « components/gcm_driver/gcm_driver.h ('k') | components/gcm_driver/gcm_driver_android.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/gcm_driver.h" 5 #include "components/gcm_driver/gcm_driver.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file_path.h"
11 #include "base/logging.h" 10 #include "base/logging.h"
12 #include "components/gcm_driver/gcm_app_handler.h" 11 #include "components/gcm_driver/gcm_app_handler.h"
13 12
14 namespace gcm { 13 namespace gcm {
15 14
15 namespace {
16 const size_t kMaxSenders = 100; 16 const size_t kMaxSenders = 100;
17 } // namespace
17 18
18 InstanceIDHandler::InstanceIDHandler() { 19 InstanceIDHandler::InstanceIDHandler() {
19 } 20 }
20 21
21 InstanceIDHandler::~InstanceIDHandler() { 22 InstanceIDHandler::~InstanceIDHandler() {
22 } 23 }
23 24
24 void InstanceIDHandler::DeleteAllTokensForApp( 25 void InstanceIDHandler::DeleteAllTokensForApp(
25 const std::string& app_id, const DeleteTokenCallback& callback) { 26 const std::string& app_id, const DeleteTokenCallback& callback) {
26 DeleteToken(app_id, "*", "*", callback); 27 DeleteToken(app_id, "*", "*", callback);
27 } 28 }
28 29
29 GCMDriver::GCMDriver( 30 GCMDriver::GCMDriver() : weak_ptr_factory_(this) {
30 const base::FilePath& store_path,
31 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner)
32 : weak_ptr_factory_(this) {
33 // The |blocking_task_runner| can be NULL for tests that do not need the
34 // encryption capabilities of the GCMDriver class.
35 if (blocking_task_runner)
36 encryption_provider_.Init(store_path, blocking_task_runner);
37 } 31 }
38 32
39 GCMDriver::~GCMDriver() { 33 GCMDriver::~GCMDriver() {
40 } 34 }
41 35
42 void GCMDriver::Register(const std::string& app_id, 36 void GCMDriver::Register(const std::string& app_id,
43 const std::vector<std::string>& sender_ids, 37 const std::vector<std::string>& sender_ids,
44 const RegisterCallback& callback) { 38 const RegisterCallback& callback) {
45 DCHECK(!app_id.empty()); 39 DCHECK(!app_id.empty());
46 DCHECK(!sender_ids.empty() && sender_ids.size() <= kMaxSenders); 40 DCHECK(!sender_ids.empty() && sender_ids.size() <= kMaxSenders);
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 if (send_callbacks_.find(key) != send_callbacks_.end()) { 142 if (send_callbacks_.find(key) != send_callbacks_.end()) {
149 callback.Run(message.id, GCMClient::INVALID_PARAMETER); 143 callback.Run(message.id, GCMClient::INVALID_PARAMETER);
150 return; 144 return;
151 } 145 }
152 146
153 send_callbacks_[key] = callback; 147 send_callbacks_[key] = callback;
154 148
155 SendImpl(app_id, receiver_id, message); 149 SendImpl(app_id, receiver_id, message);
156 } 150 }
157 151
158 void GCMDriver::GetPublicKey(
159 const std::string& app_id,
160 const GetPublicKeyCallback& callback) {
161 encryption_provider_.GetPublicKey(app_id, callback);
162 }
163
164 void GCMDriver::UnregisterWithSenderIdImpl(const std::string& app_id, 152 void GCMDriver::UnregisterWithSenderIdImpl(const std::string& app_id,
165 const std::string& sender_id) { 153 const std::string& sender_id) {
166 NOTREACHED(); 154 NOTREACHED();
167 } 155 }
168 156
169 void GCMDriver::RegisterFinished(const std::string& app_id, 157 void GCMDriver::RegisterFinished(const std::string& app_id,
170 const std::string& registration_id, 158 const std::string& registration_id,
171 GCMClient::Result result) { 159 GCMClient::Result result) {
172 std::map<std::string, RegisterCallback>::iterator callback_iter = 160 std::map<std::string, RegisterCallback>::iterator callback_iter =
173 register_callbacks_.find(app_id); 161 register_callbacks_.find(app_id);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 GCMClient::Result result) { 253 GCMClient::Result result) {
266 // Invoke the original unregister callback. 254 // Invoke the original unregister callback.
267 unregister_callback.Run(result); 255 unregister_callback.Run(result);
268 256
269 // Trigger the pending registration. 257 // Trigger the pending registration.
270 DCHECK(register_callbacks_.find(app_id) != register_callbacks_.end()); 258 DCHECK(register_callbacks_.find(app_id) != register_callbacks_.end());
271 RegisterImpl(app_id, normalized_sender_ids); 259 RegisterImpl(app_id, normalized_sender_ids);
272 } 260 }
273 261
274 } // namespace gcm 262 } // namespace gcm
OLDNEW
« no previous file with comments | « components/gcm_driver/gcm_driver.h ('k') | components/gcm_driver/gcm_driver_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698