| 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/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 | 105 |
| 106 // static | 106 // static |
| 107 KeyedService* FakeGCMProfileService::Build(content::BrowserContext* context) { | 107 KeyedService* FakeGCMProfileService::Build(content::BrowserContext* context) { |
| 108 Profile* profile = static_cast<Profile*>(context); | 108 Profile* profile = static_cast<Profile*>(context); |
| 109 FakeGCMProfileService* service = new FakeGCMProfileService(profile); | 109 FakeGCMProfileService* service = new FakeGCMProfileService(profile); |
| 110 service->SetDriverForTesting(new CustomFakeGCMDriver(service)); | 110 service->SetDriverForTesting(new CustomFakeGCMDriver(service)); |
| 111 return service; | 111 return service; |
| 112 } | 112 } |
| 113 | 113 |
| 114 FakeGCMProfileService::FakeGCMProfileService(Profile* profile) | 114 FakeGCMProfileService::FakeGCMProfileService(Profile* profile) |
| 115 : collect_(false) {} | 115 : collect_(false) { |
| 116 static_cast<PushMessagingServiceImpl*>(push_messaging_service()) |
| 117 ->SetProfileForTesting(profile); |
| 118 } |
| 116 | 119 |
| 117 FakeGCMProfileService::~FakeGCMProfileService() {} | 120 FakeGCMProfileService::~FakeGCMProfileService() {} |
| 118 | 121 |
| 119 void FakeGCMProfileService::RegisterFinished( | 122 void FakeGCMProfileService::RegisterFinished( |
| 120 const std::string& app_id, | 123 const std::string& app_id, |
| 121 const std::vector<std::string>& sender_ids) { | 124 const std::vector<std::string>& sender_ids) { |
| 122 if (collect_) { | 125 if (collect_) { |
| 123 last_registered_app_id_ = app_id; | 126 last_registered_app_id_ = app_id; |
| 124 last_registered_sender_ids_ = sender_ids; | 127 last_registered_sender_ids_ = sender_ids; |
| 125 } | 128 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 156 static_cast<CustomFakeGCMDriver*>(driver()); | 159 static_cast<CustomFakeGCMDriver*>(driver()); |
| 157 custom_driver->OnSendFinished(app_id, message.id, GCMClient::SUCCESS); | 160 custom_driver->OnSendFinished(app_id, message.id, GCMClient::SUCCESS); |
| 158 } | 161 } |
| 159 | 162 |
| 160 void FakeGCMProfileService::AddExpectedUnregisterResponse( | 163 void FakeGCMProfileService::AddExpectedUnregisterResponse( |
| 161 GCMClient::Result result) { | 164 GCMClient::Result result) { |
| 162 unregister_responses_.push_back(result); | 165 unregister_responses_.push_back(result); |
| 163 } | 166 } |
| 164 | 167 |
| 165 } // namespace gcm | 168 } // namespace gcm |
| OLD | NEW |