| OLD | NEW |
| 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/fake_gcm_driver_for_instance_id.h" | 5 #include "components/gcm_driver/instance_id/fake_gcm_driver_for_instance_id.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/rand_util.h" | 9 #include "base/rand_util.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 tokens_[key] = token; | 71 tokens_[key] = token; |
| 72 } | 72 } |
| 73 | 73 |
| 74 last_gettoken_app_id_ = app_id; | 74 last_gettoken_app_id_ = app_id; |
| 75 last_gettoken_authorized_entity_ = authorized_entity; | 75 last_gettoken_authorized_entity_ = authorized_entity; |
| 76 | 76 |
| 77 base::ThreadTaskRunnerHandle::Get()->PostTask( | 77 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 78 FROM_HERE, base::Bind(callback, token, gcm::GCMClient::SUCCESS)); | 78 FROM_HERE, base::Bind(callback, token, gcm::GCMClient::SUCCESS)); |
| 79 } | 79 } |
| 80 | 80 |
| 81 void FakeGCMDriverForInstanceID::ValidateToken( |
| 82 const std::string& app_id, |
| 83 const std::string& authorized_entity, |
| 84 const std::string& scope, |
| 85 const std::string& token, |
| 86 const ValidateTokenCallback& callback) { |
| 87 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 88 FROM_HERE, base::Bind(callback, true /* is_valid */)); |
| 89 } |
| 90 |
| 81 void FakeGCMDriverForInstanceID::DeleteToken( | 91 void FakeGCMDriverForInstanceID::DeleteToken( |
| 82 const std::string& app_id, | 92 const std::string& app_id, |
| 83 const std::string& authorized_entity, | 93 const std::string& authorized_entity, |
| 84 const std::string& scope, | 94 const std::string& scope, |
| 85 const DeleteTokenCallback& callback) { | 95 const DeleteTokenCallback& callback) { |
| 86 std::string key = app_id + authorized_entity + scope; | 96 std::string key = app_id + authorized_entity + scope; |
| 87 tokens_.erase(key); | 97 tokens_.erase(key); |
| 88 | 98 |
| 89 last_deletetoken_app_id_ = app_id; | 99 last_deletetoken_app_id_ = app_id; |
| 90 | 100 |
| 91 base::ThreadTaskRunnerHandle::Get()->PostTask( | 101 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 92 FROM_HERE, base::Bind(callback, gcm::GCMClient::SUCCESS)); | 102 FROM_HERE, base::Bind(callback, gcm::GCMClient::SUCCESS)); |
| 93 } | 103 } |
| 94 | 104 |
| 95 } // namespace instance_id | 105 } // namespace instance_id |
| OLD | NEW |