OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "components/gcm_driver/instance_id/fake_gcm_driver_for_instance_id.h" |
| 6 |
| 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" |
| 9 |
| 10 namespace instance_id { |
| 11 |
| 12 FakeGCMDriverForInstanceID::FakeGCMDriverForInstanceID() { |
| 13 } |
| 14 |
| 15 FakeGCMDriverForInstanceID::~FakeGCMDriverForInstanceID() { |
| 16 } |
| 17 |
| 18 gcm::InstanceIDStore* FakeGCMDriverForInstanceID::GetInstanceIDStore() { |
| 19 return this; |
| 20 } |
| 21 |
| 22 void FakeGCMDriverForInstanceID::AddInstanceIDData( |
| 23 const std::string& app_id, |
| 24 const std::string& instance_id_data) { |
| 25 instance_id_data_[app_id] = instance_id_data; |
| 26 } |
| 27 |
| 28 void FakeGCMDriverForInstanceID::RemoveInstanceIDData( |
| 29 const std::string& app_id) { |
| 30 instance_id_data_.erase(app_id); |
| 31 } |
| 32 |
| 33 void FakeGCMDriverForInstanceID::GetInstanceIDData( |
| 34 const std::string& app_id, |
| 35 const gcm::InstanceIDStore::GetInstanceIDDataCallback& callback) { |
| 36 std::string data; |
| 37 auto iter = instance_id_data_.find(app_id); |
| 38 if (iter != instance_id_data_.end()) |
| 39 data = iter->second; |
| 40 base::MessageLoop::current()->PostTask( |
| 41 FROM_HERE, |
| 42 base::Bind(callback, data)); |
| 43 } |
| 44 |
| 45 } // namespace instance_id |
OLD | NEW |