| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/services/gcm/fake_gcm_profile_service.h" | 5 #include "chrome/browser/services/gcm/fake_gcm_profile_service.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/format_macros.h" | 8 #include "base/format_macros.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 void OnUnregisterFinished(const std::string& app_id, | 30 void OnUnregisterFinished(const std::string& app_id, |
| 31 GCMClient::Result result); | 31 GCMClient::Result result); |
| 32 void OnSendFinished(const std::string& app_id, | 32 void OnSendFinished(const std::string& app_id, |
| 33 const std::string& message_id, | 33 const std::string& message_id, |
| 34 GCMClient::Result result); | 34 GCMClient::Result result); |
| 35 | 35 |
| 36 protected: | 36 protected: |
| 37 // FakeGCMDriver overrides: | 37 // FakeGCMDriver overrides: |
| 38 void RegisterImpl(const std::string& app_id, | 38 void RegisterImpl(const std::string& app_id, |
| 39 const std::vector<std::string>& sender_ids) override; | 39 const std::vector<std::string>& sender_ids) override; |
| 40 void UnregisterImpl(const std::string& app_id) override; | 40 void UnregisterImpl(const std::string& app_id, |
| 41 const std::vector<std::string>& sender_ids) override; |
| 41 void SendImpl(const std::string& app_id, | 42 void SendImpl(const std::string& app_id, |
| 42 const std::string& receiver_id, | 43 const std::string& receiver_id, |
| 43 const GCMClient::OutgoingMessage& message) override; | 44 const GCMClient::OutgoingMessage& message) override; |
| 44 | 45 |
| 45 private: | 46 private: |
| 46 FakeGCMProfileService* service_; | 47 FakeGCMProfileService* service_; |
| 47 | 48 |
| 48 DISALLOW_COPY_AND_ASSIGN(CustomFakeGCMDriver); | 49 DISALLOW_COPY_AND_ASSIGN(CustomFakeGCMDriver); |
| 49 }; | 50 }; |
| 50 | 51 |
| 51 CustomFakeGCMDriver::CustomFakeGCMDriver(FakeGCMProfileService* service) | 52 CustomFakeGCMDriver::CustomFakeGCMDriver(FakeGCMProfileService* service) |
| 52 : service_(service) { | 53 : service_(service) { |
| 53 } | 54 } |
| 54 | 55 |
| 55 CustomFakeGCMDriver::~CustomFakeGCMDriver() { | 56 CustomFakeGCMDriver::~CustomFakeGCMDriver() { |
| 56 } | 57 } |
| 57 | 58 |
| 58 void CustomFakeGCMDriver::RegisterImpl( | 59 void CustomFakeGCMDriver::RegisterImpl( |
| 59 const std::string& app_id, | 60 const std::string& app_id, |
| 60 const std::vector<std::string>& sender_ids) { | 61 const std::vector<std::string>& sender_ids) { |
| 61 base::MessageLoop::current()->PostTask( | 62 base::MessageLoop::current()->PostTask( |
| 62 FROM_HERE, | 63 FROM_HERE, |
| 63 base::Bind(&FakeGCMProfileService::RegisterFinished, | 64 base::Bind(&FakeGCMProfileService::RegisterFinished, |
| 64 base::Unretained(service_), | 65 base::Unretained(service_), |
| 65 app_id, | 66 app_id, |
| 66 sender_ids)); | 67 sender_ids)); |
| 67 } | 68 } |
| 68 | 69 |
| 69 void CustomFakeGCMDriver::UnregisterImpl(const std::string& app_id) { | 70 void CustomFakeGCMDriver::UnregisterImpl( |
| 71 const std::string& app_id, |
| 72 const std::vector<std::string>& sender_ids) { |
| 70 base::MessageLoop::current()->PostTask( | 73 base::MessageLoop::current()->PostTask( |
| 71 FROM_HERE, base::Bind( | 74 FROM_HERE, base::Bind( |
| 72 &FakeGCMProfileService::UnregisterFinished, | 75 &FakeGCMProfileService::UnregisterFinished, |
| 73 base::Unretained(service_), | 76 base::Unretained(service_), |
| 74 app_id)); | 77 app_id)); |
| 75 } | 78 } |
| 76 | 79 |
| 77 void CustomFakeGCMDriver::SendImpl(const std::string& app_id, | 80 void CustomFakeGCMDriver::SendImpl(const std::string& app_id, |
| 78 const std::string& receiver_id, | 81 const std::string& receiver_id, |
| 79 const GCMClient::OutgoingMessage& message) { | 82 const GCMClient::OutgoingMessage& message) { |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 GCMClient::Result result) { | 179 GCMClient::Result result) { |
| 177 unregister_responses_.push_back(result); | 180 unregister_responses_.push_back(result); |
| 178 } | 181 } |
| 179 | 182 |
| 180 void FakeGCMProfileService::SetUnregisterCallback( | 183 void FakeGCMProfileService::SetUnregisterCallback( |
| 181 const UnregisterCallback& callback) { | 184 const UnregisterCallback& callback) { |
| 182 unregister_callback_ = callback; | 185 unregister_callback_ = callback; |
| 183 } | 186 } |
| 184 | 187 |
| 185 } // namespace gcm | 188 } // namespace gcm |
| OLD | NEW |