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