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

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

Issue 2697793004: Push API: Validate storage before returning cached subscriptions (Closed)
Patch Set: Comment out PUSH_GETREGISTRATION_STATUS_PUBLIC_KEY_UNAVAILABLE Created 3 years, 10 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/instance_id/instance_id_impl.h" 5 #include "components/gcm_driver/instance_id/instance_id_impl.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 const std::string& scope, 127 const std::string& scope,
128 const std::map<std::string, std::string>& options, 128 const std::map<std::string, std::string>& options,
129 const GetTokenCallback& callback) { 129 const GetTokenCallback& callback) {
130 EnsureIDGenerated(); 130 EnsureIDGenerated();
131 131
132 Handler()->GetToken(app_id(), authorized_entity, scope, options, 132 Handler()->GetToken(app_id(), authorized_entity, scope, options,
133 base::Bind(&InstanceIDImpl::OnGetTokenCompleted, 133 base::Bind(&InstanceIDImpl::OnGetTokenCompleted,
134 weak_ptr_factory_.GetWeakPtr(), callback)); 134 weak_ptr_factory_.GetWeakPtr(), callback));
135 } 135 }
136 136
137 void InstanceIDImpl::ValidateToken(const std::string& authorized_entity,
138 const std::string& scope,
139 const std::string& token,
140 const ValidateTokenCallback& callback) {
141 DCHECK(!authorized_entity.empty());
142 DCHECK(!scope.empty());
143 DCHECK(!token.empty());
144
145 if (!delayed_task_controller_.CanRunTaskWithoutDelay()) {
146 delayed_task_controller_.AddTask(base::Bind(
147 &InstanceIDImpl::DoValidateToken, weak_ptr_factory_.GetWeakPtr(),
148 authorized_entity, scope, token, callback));
149 return;
150 }
151
152 DoValidateToken(authorized_entity, scope, token, callback);
153 }
154
155 void InstanceIDImpl::DoValidateToken(const std::string& authorized_entity,
156 const std::string& scope,
157 const std::string& token,
158 const ValidateTokenCallback& callback) {
159 if (id_.empty()) {
160 callback.Run(false /* is_valid */);
Peter Beverloo 2017/03/20 23:50:13 nit: this potentially is a synchronous return path
johnme 2017/03/30 18:36:38 The convention in this file seems to be for synchr
161 return;
162 }
163
164 Handler()->ValidateToken(app_id(), authorized_entity, scope, token, callback);
165 }
166
137 void InstanceIDImpl::DeleteTokenImpl(const std::string& authorized_entity, 167 void InstanceIDImpl::DeleteTokenImpl(const std::string& authorized_entity,
138 const std::string& scope, 168 const std::string& scope,
139 const DeleteTokenCallback& callback) { 169 const DeleteTokenCallback& callback) {
140 DCHECK(!authorized_entity.empty()); 170 DCHECK(!authorized_entity.empty());
141 DCHECK(!scope.empty()); 171 DCHECK(!scope.empty());
142 172
143 if (!delayed_task_controller_.CanRunTaskWithoutDelay()) { 173 if (!delayed_task_controller_.CanRunTaskWithoutDelay()) {
144 delayed_task_controller_.AddTask( 174 delayed_task_controller_.AddTask(
145 base::Bind(&InstanceIDImpl::DoDeleteToken, 175 base::Bind(&InstanceIDImpl::DoDeleteToken,
146 weak_ptr_factory_.GetWeakPtr(), 176 weak_ptr_factory_.GetWeakPtr(),
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 } 299 }
270 300
271 gcm::InstanceIDHandler* InstanceIDImpl::Handler() { 301 gcm::InstanceIDHandler* InstanceIDImpl::Handler() {
272 gcm::InstanceIDHandler* handler = 302 gcm::InstanceIDHandler* handler =
273 gcm_driver()->GetInstanceIDHandlerInternal(); 303 gcm_driver()->GetInstanceIDHandlerInternal();
274 DCHECK(handler); 304 DCHECK(handler);
275 return handler; 305 return handler;
276 } 306 }
277 307
278 } // namespace instance_id 308 } // namespace instance_id
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698