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

Unified Diff: components/gcm_driver/instance_id/fake_gcm_driver_for_instance_id.cc

Issue 1137463003: Support getting and deleting token for Instance ID. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add new files 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 side-by-side diff with in-line comments
Download patch
Index: components/gcm_driver/instance_id/fake_gcm_driver_for_instance_id.cc
diff --git a/components/gcm_driver/instance_id/fake_gcm_driver_for_instance_id.cc b/components/gcm_driver/instance_id/fake_gcm_driver_for_instance_id.cc
index 2a50a03ce7686f521fd21d828874e28d9935135c..4a28747ce664c539cd2bf8438042bba2054a3988 100644
--- a/components/gcm_driver/instance_id/fake_gcm_driver_for_instance_id.cc
+++ b/components/gcm_driver/instance_id/fake_gcm_driver_for_instance_id.cc
@@ -6,6 +6,9 @@
#include "base/bind.h"
#include "base/message_loop/message_loop.h"
+#include "base/rand_util.h"
+#include "base/strings/string_number_conversions.h"
+#include "components/gcm_driver/gcm_client.h"
namespace instance_id {
@@ -15,7 +18,7 @@ FakeGCMDriverForInstanceID::FakeGCMDriverForInstanceID() {
FakeGCMDriverForInstanceID::~FakeGCMDriverForInstanceID() {
}
-gcm::InstanceIDStore* FakeGCMDriverForInstanceID::GetInstanceIDStore() {
+gcm::InstanceIDHandler* FakeGCMDriverForInstanceID::GetInstanceIDHandler() {
return this;
}
@@ -32,7 +35,7 @@ void FakeGCMDriverForInstanceID::RemoveInstanceIDData(
void FakeGCMDriverForInstanceID::GetInstanceIDData(
const std::string& app_id,
- const gcm::InstanceIDStore::GetInstanceIDDataCallback& callback) {
+ const GetInstanceIDDataCallback& callback) {
std::string data;
auto iter = instance_id_data_.find(app_id);
if (iter != instance_id_data_.end())
@@ -42,4 +45,37 @@ void FakeGCMDriverForInstanceID::GetInstanceIDData(
base::Bind(callback, data));
}
+void FakeGCMDriverForInstanceID::GetToken(
+ const std::string& app_id,
+ const std::string& authorized_entity,
+ const std::string& scope,
+ const std::map<std::string, std::string>& options,
+ const GetTokenCallback& callback) {
+ std::string token;
+ std::string key = app_id + authorized_entity + scope;
+ auto iter = tokens_.find(key);
+ if (iter != tokens_.end()) {
+ token = iter->second;
+ } else {
+ token = base::Uint64ToString(base::RandUint64());
+ tokens_[key] = token;
+ }
+
+ base::MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(callback, token, gcm::GCMClient::SUCCESS));
+}
+
+void FakeGCMDriverForInstanceID::DeleteToken(
+ const std::string& app_id,
+ const std::string& authorized_entity,
+ const std::string& scope,
+ const DeleteTokenCallback& callback) {
+ std::string key = app_id + authorized_entity + scope;
+ tokens_.erase(key);
+ base::MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(callback, gcm::GCMClient::SUCCESS));
+}
+
} // namespace instance_id

Powered by Google App Engine
This is Rietveld 408576698