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" |
11 #include "components/gcm_driver/fake_gcm_client_factory.h" | 11 #include "components/gcm_driver/fake_gcm_client_factory.h" |
12 #include "components/gcm_driver/fake_gcm_driver.h" | 12 #include "components/gcm_driver/fake_gcm_driver.h" |
13 #include "components/gcm_driver/gcm_driver.h" | 13 #include "components/gcm_driver/gcm_driver.h" |
14 #include "content/public/browser/browser_context.h" | 14 #include "content/public/browser/browser_context.h" |
15 | 15 |
16 namespace gcm { | 16 namespace gcm { |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
20 class CustomFakeGCMDriver : public FakeGCMDriver { | 20 class CustomFakeGCMDriver : public FakeGCMDriver { |
21 public: | 21 public: |
22 explicit CustomFakeGCMDriver(FakeGCMProfileService* service); | 22 explicit CustomFakeGCMDriver(FakeGCMProfileService* service); |
23 virtual ~CustomFakeGCMDriver(); | 23 ~CustomFakeGCMDriver() override; |
24 | 24 |
25 void OnRegisterFinished(const std::string& app_id, | 25 void OnRegisterFinished(const std::string& app_id, |
26 const std::string& registration_id, | 26 const std::string& registration_id, |
27 GCMClient::Result result); | 27 GCMClient::Result result); |
28 void OnUnregisterFinished(const std::string& app_id, | 28 void OnUnregisterFinished(const std::string& app_id, |
29 GCMClient::Result result); | 29 GCMClient::Result result); |
30 void OnSendFinished(const std::string& app_id, | 30 void OnSendFinished(const std::string& app_id, |
31 const std::string& message_id, | 31 const std::string& message_id, |
32 GCMClient::Result result); | 32 GCMClient::Result result); |
33 | 33 |
34 protected: | 34 protected: |
35 // FakeGCMDriver overrides: | 35 // FakeGCMDriver overrides: |
36 virtual void RegisterImpl( | 36 void RegisterImpl(const std::string& app_id, |
37 const std::string& app_id, | 37 const std::vector<std::string>& sender_ids) override; |
38 const std::vector<std::string>& sender_ids) override; | 38 void UnregisterImpl(const std::string& app_id) override; |
39 virtual void UnregisterImpl(const std::string& app_id) override; | 39 void SendImpl(const std::string& app_id, |
40 virtual void SendImpl(const std::string& app_id, | 40 const std::string& receiver_id, |
41 const std::string& receiver_id, | 41 const GCMClient::OutgoingMessage& message) override; |
42 const GCMClient::OutgoingMessage& message) override; | |
43 | 42 |
44 private: | 43 private: |
45 FakeGCMProfileService* service_; | 44 FakeGCMProfileService* service_; |
46 | 45 |
47 DISALLOW_COPY_AND_ASSIGN(CustomFakeGCMDriver); | 46 DISALLOW_COPY_AND_ASSIGN(CustomFakeGCMDriver); |
48 }; | 47 }; |
49 | 48 |
50 CustomFakeGCMDriver::CustomFakeGCMDriver(FakeGCMProfileService* service) | 49 CustomFakeGCMDriver::CustomFakeGCMDriver(FakeGCMProfileService* service) |
51 : service_(service) { | 50 : service_(service) { |
52 } | 51 } |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 static_cast<CustomFakeGCMDriver*>(driver()); | 155 static_cast<CustomFakeGCMDriver*>(driver()); |
157 custom_driver->OnSendFinished(app_id, message.id, GCMClient::SUCCESS); | 156 custom_driver->OnSendFinished(app_id, message.id, GCMClient::SUCCESS); |
158 } | 157 } |
159 | 158 |
160 void FakeGCMProfileService::AddExpectedUnregisterResponse( | 159 void FakeGCMProfileService::AddExpectedUnregisterResponse( |
161 GCMClient::Result result) { | 160 GCMClient::Result result) { |
162 unregister_responses_.push_back(result); | 161 unregister_responses_.push_back(result); |
163 } | 162 } |
164 | 163 |
165 } // namespace gcm | 164 } // namespace gcm |
OLD | NEW |