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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: components/gcm_driver/instance_id/instance_id_impl.cc
diff --git a/components/gcm_driver/instance_id/instance_id_impl.cc b/components/gcm_driver/instance_id/instance_id_impl.cc
index b10451fe0f7e41ede15a901481317a30710b07a9..013ddbff354b17dbb939a99a5990cfd39a905bab 100644
--- a/components/gcm_driver/instance_id/instance_id_impl.cc
+++ b/components/gcm_driver/instance_id/instance_id_impl.cc
@@ -134,6 +134,36 @@ void InstanceIDImpl::DoGetToken(
weak_ptr_factory_.GetWeakPtr(), callback));
}
+void InstanceIDImpl::ValidateToken(const std::string& authorized_entity,
+ const std::string& scope,
+ const std::string& token,
+ const ValidateTokenCallback& callback) {
+ DCHECK(!authorized_entity.empty());
+ DCHECK(!scope.empty());
+ DCHECK(!token.empty());
+
+ if (!delayed_task_controller_.CanRunTaskWithoutDelay()) {
+ delayed_task_controller_.AddTask(base::Bind(
+ &InstanceIDImpl::DoValidateToken, weak_ptr_factory_.GetWeakPtr(),
+ authorized_entity, scope, token, callback));
+ return;
+ }
+
+ DoValidateToken(authorized_entity, scope, token, callback);
+}
+
+void InstanceIDImpl::DoValidateToken(const std::string& authorized_entity,
+ const std::string& scope,
+ const std::string& token,
+ const ValidateTokenCallback& callback) {
+ if (id_.empty()) {
+ 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
+ return;
+ }
+
+ Handler()->ValidateToken(app_id(), authorized_entity, scope, token, callback);
+}
+
void InstanceIDImpl::DeleteTokenImpl(const std::string& authorized_entity,
const std::string& scope,
const DeleteTokenCallback& callback) {

Powered by Google App Engine
This is Rietveld 408576698