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

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

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
« 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"
10 #include "base/logging.h" 11 #include "base/logging.h"
11 #include "components/gcm_driver/gcm_app_handler.h" 12 #include "components/gcm_driver/gcm_app_handler.h"
12 13
13 namespace gcm { 14 namespace gcm {
14 15
15 namespace {
16 const size_t kMaxSenders = 100; 16 const size_t kMaxSenders = 100;
17 } // namespace
18 17
19 InstanceIDHandler::InstanceIDHandler() { 18 InstanceIDHandler::InstanceIDHandler() {
20 } 19 }
21 20
22 InstanceIDHandler::~InstanceIDHandler() { 21 InstanceIDHandler::~InstanceIDHandler() {
23 } 22 }
24 23
25 void InstanceIDHandler::DeleteAllTokensForApp( 24 void InstanceIDHandler::DeleteAllTokensForApp(
26 const std::string& app_id, const DeleteTokenCallback& callback) { 25 const std::string& app_id, const DeleteTokenCallback& callback) {
27 DeleteToken(app_id, "*", "*", callback); 26 DeleteToken(app_id, "*", "*", callback);
28 } 27 }
29 28
30 GCMDriver::GCMDriver() : weak_ptr_factory_(this) { 29 GCMDriver::GCMDriver(
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);
31 } 37 }
32 38
33 GCMDriver::~GCMDriver() { 39 GCMDriver::~GCMDriver() {
34 } 40 }
35 41
36 void GCMDriver::Register(const std::string& app_id, 42 void GCMDriver::Register(const std::string& app_id,
37 const std::vector<std::string>& sender_ids, 43 const std::vector<std::string>& sender_ids,
38 const RegisterCallback& callback) { 44 const RegisterCallback& callback) {
39 DCHECK(!app_id.empty()); 45 DCHECK(!app_id.empty());
40 DCHECK(!sender_ids.empty() && sender_ids.size() <= kMaxSenders); 46 DCHECK(!sender_ids.empty() && sender_ids.size() <= kMaxSenders);
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 if (send_callbacks_.find(key) != send_callbacks_.end()) { 148 if (send_callbacks_.find(key) != send_callbacks_.end()) {
143 callback.Run(message.id, GCMClient::INVALID_PARAMETER); 149 callback.Run(message.id, GCMClient::INVALID_PARAMETER);
144 return; 150 return;
145 } 151 }
146 152
147 send_callbacks_[key] = callback; 153 send_callbacks_[key] = callback;
148 154
149 SendImpl(app_id, receiver_id, message); 155 SendImpl(app_id, receiver_id, message);
150 } 156 }
151 157
158 void GCMDriver::GetPublicKey(
159 const std::string& app_id,
160 const GetPublicKeyCallback& callback) {
161 encryption_provider_.GetPublicKey(app_id, callback);
162 }
163
152 void GCMDriver::UnregisterWithSenderIdImpl(const std::string& app_id, 164 void GCMDriver::UnregisterWithSenderIdImpl(const std::string& app_id,
153 const std::string& sender_id) { 165 const std::string& sender_id) {
154 NOTREACHED(); 166 NOTREACHED();
155 } 167 }
156 168
157 void GCMDriver::RegisterFinished(const std::string& app_id, 169 void GCMDriver::RegisterFinished(const std::string& app_id,
158 const std::string& registration_id, 170 const std::string& registration_id,
159 GCMClient::Result result) { 171 GCMClient::Result result) {
160 std::map<std::string, RegisterCallback>::iterator callback_iter = 172 std::map<std::string, RegisterCallback>::iterator callback_iter =
161 register_callbacks_.find(app_id); 173 register_callbacks_.find(app_id);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 GCMClient::Result result) { 265 GCMClient::Result result) {
254 // Invoke the original unregister callback. 266 // Invoke the original unregister callback.
255 unregister_callback.Run(result); 267 unregister_callback.Run(result);
256 268
257 // Trigger the pending registration. 269 // Trigger the pending registration.
258 DCHECK(register_callbacks_.find(app_id) != register_callbacks_.end()); 270 DCHECK(register_callbacks_.find(app_id) != register_callbacks_.end());
259 RegisterImpl(app_id, normalized_sender_ids); 271 RegisterImpl(app_id, normalized_sender_ids);
260 } 272 }
261 273
262 } // namespace gcm 274 } // 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