Chromium Code Reviews| 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 0ee7f0b6320f07f2dafc1f3e97a0102ddd48b5cc..0a4ddd521a9e98684a5bf0c12d80bd0e2c61ee12 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 |
| @@ -12,6 +12,18 @@ |
| #include "base/threading/thread_task_runner_handle.h" |
| #include "components/gcm_driver/gcm_client.h" |
| +namespace { |
| + |
| +std::string MakeKey(const std::string& app_id, |
| + bool use_subtype, |
| + const std::string& authorized_entity, |
| + const std::string& scope) { |
| + return base::IntToString(use_subtype) + ',' + app_id + ',' + |
| + authorized_entity + ',' + scope; |
|
Peter Beverloo
2016/07/28 12:34:10
nit: consider using:
return base::StringPrintf(
johnme
2016/08/04 17:47:14
Done, though I had to use .c_str() x3 since String
|
| +} |
| + |
| +} // namespace |
| + |
| namespace instance_id { |
| FakeGCMDriverForInstanceID::FakeGCMDriverForInstanceID() |
| @@ -53,13 +65,14 @@ void FakeGCMDriverForInstanceID::GetInstanceIDData( |
| void FakeGCMDriverForInstanceID::GetToken( |
| const std::string& app_id, |
| + bool use_subtype, |
| 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; |
| + std::string key = MakeKey(app_id, use_subtype, authorized_entity, scope); |
| auto iter = tokens_.find(key); |
| + std::string token; |
| if (iter != tokens_.end()) { |
| token = iter->second; |
| } else { |
| @@ -73,10 +86,11 @@ void FakeGCMDriverForInstanceID::GetToken( |
| void FakeGCMDriverForInstanceID::DeleteToken( |
| const std::string& app_id, |
| + bool use_subtype, |
| const std::string& authorized_entity, |
| const std::string& scope, |
| const DeleteTokenCallback& callback) { |
| - std::string key = app_id + authorized_entity + scope; |
| + std::string key = MakeKey(app_id, use_subtype, authorized_entity, scope); |
| tokens_.erase(key); |
| base::ThreadTaskRunnerHandle::Get()->PostTask( |
| FROM_HERE, base::Bind(callback, gcm::GCMClient::SUCCESS)); |