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

Side by Side Diff: chrome/browser/extensions/api/instance_id/instance_id_api.cc

Issue 1126233004: Persist Instance ID data to GCM store. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix mac Created 5 years, 7 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 "chrome/browser/extensions/api/instance_id/instance_id_api.h" 5 #include "chrome/browser/extensions/api/instance_id/instance_id_api.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/services/gcm/instance_id/instance_id_profile_service.h" 9 #include "chrome/browser/services/gcm/instance_id/instance_id_profile_service.h"
10 #include "chrome/browser/services/gcm/instance_id/instance_id_profile_service_fa ctory.h" 10 #include "chrome/browser/services/gcm/instance_id/instance_id_profile_service_fa ctory.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 return instance_id::InstanceIDProfileServiceFactory::GetForProfile( 74 return instance_id::InstanceIDProfileServiceFactory::GetForProfile(
75 Profile::FromBrowserContext(browser_context()))->driver()-> 75 Profile::FromBrowserContext(browser_context()))->driver()->
76 GetInstanceID(extension()->id()); 76 GetInstanceID(extension()->id());
77 } 77 }
78 78
79 InstanceIDGetIDFunction::InstanceIDGetIDFunction() {} 79 InstanceIDGetIDFunction::InstanceIDGetIDFunction() {}
80 80
81 InstanceIDGetIDFunction::~InstanceIDGetIDFunction() {} 81 InstanceIDGetIDFunction::~InstanceIDGetIDFunction() {}
82 82
83 ExtensionFunction::ResponseAction InstanceIDGetIDFunction::DoWork() { 83 ExtensionFunction::ResponseAction InstanceIDGetIDFunction::DoWork() {
84 return RespondNow( 84 GetInstanceID()->GetID(
85 OneArgument(new base::StringValue(GetInstanceID()->GetID()))); 85 base::Bind(&InstanceIDGetIDFunction::GetIDCompleted, this));
86 return RespondLater();
87 }
88
89 void InstanceIDGetIDFunction::GetIDCompleted(const std::string& id) {
90 Respond(OneArgument(new base::StringValue(id)));
86 } 91 }
87 92
88 InstanceIDGetCreationTimeFunction::InstanceIDGetCreationTimeFunction() {} 93 InstanceIDGetCreationTimeFunction::InstanceIDGetCreationTimeFunction() {}
89 94
90 InstanceIDGetCreationTimeFunction::~InstanceIDGetCreationTimeFunction() {} 95 InstanceIDGetCreationTimeFunction::~InstanceIDGetCreationTimeFunction() {}
91 96
92 ExtensionFunction::ResponseAction InstanceIDGetCreationTimeFunction::DoWork() { 97 ExtensionFunction::ResponseAction InstanceIDGetCreationTimeFunction::DoWork() {
93 return RespondNow(OneArgument( 98 GetInstanceID()->GetCreationTime(
94 new base::FundamentalValue( 99 base::Bind(&InstanceIDGetCreationTimeFunction::GetCreationTimeCompleted,
95 GetInstanceID()->GetCreationTime().ToDoubleT()))); 100 this));
101 return RespondLater();
102 }
103
104 void InstanceIDGetCreationTimeFunction::GetCreationTimeCompleted(
105 const base::Time& creation_time) {
106 Respond(OneArgument(new base::FundamentalValue(creation_time.ToDoubleT())));
96 } 107 }
97 108
98 InstanceIDGetTokenFunction::InstanceIDGetTokenFunction() {} 109 InstanceIDGetTokenFunction::InstanceIDGetTokenFunction() {}
99 110
100 InstanceIDGetTokenFunction::~InstanceIDGetTokenFunction() {} 111 InstanceIDGetTokenFunction::~InstanceIDGetTokenFunction() {}
101 112
102 ExtensionFunction::ResponseAction InstanceIDGetTokenFunction::DoWork() { 113 ExtensionFunction::ResponseAction InstanceIDGetTokenFunction::DoWork() {
103 scoped_ptr<api::instance_id::GetToken::Params> params = 114 scoped_ptr<api::instance_id::GetToken::Params> params =
104 api::instance_id::GetToken::Params::Create(*args_); 115 api::instance_id::GetToken::Params::Create(*args_);
105 EXTENSION_FUNCTION_VALIDATE(params.get()); 116 EXTENSION_FUNCTION_VALIDATE(params.get());
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 185
175 void InstanceIDDeleteIDFunction::DeleteIDCompleted( 186 void InstanceIDDeleteIDFunction::DeleteIDCompleted(
176 instance_id::InstanceID::Result result) { 187 instance_id::InstanceID::Result result) {
177 if (result == instance_id::InstanceID::SUCCESS) 188 if (result == instance_id::InstanceID::SUCCESS)
178 Respond(NoArguments()); 189 Respond(NoArguments());
179 else 190 else
180 Respond(Error(InstanceIDResultToError(result))); 191 Respond(Error(InstanceIDResultToError(result)));
181 } 192 }
182 193
183 } // namespace extensions 194 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698