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 #ifndef CHROME_BROWSER_SERVICES_GCM_FAKE_GCM_PROFILE_SERVICE_H_ | 5 #ifndef COMPONENTS_GCM_DRIVER_GCM_FAKE_PROFILE_SERVICE_H_ |
6 #define CHROME_BROWSER_SERVICES_GCM_FAKE_GCM_PROFILE_SERVICE_H_ | 6 #define COMPONENTS_GCM_DRIVER_GCM_FAKE_PROFILE_SERVICE_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <memory> | 9 #include <memory> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "components/gcm_driver/gcm_driver.h" | 13 #include "components/gcm_driver/gcm_driver.h" |
14 #include "components/gcm_driver/gcm_profile_service.h" | 14 #include "components/gcm_driver/gcm_profile_service.h" |
15 | 15 |
16 class Profile; | 16 class Profile; |
17 | 17 |
18 namespace content { | 18 namespace content { |
19 class BrowserContext; | 19 class BrowserContext; |
20 } // namespace content | 20 } // namespace content |
21 | 21 |
22 namespace gcm { | 22 namespace gcm { |
23 | 23 |
24 // Acts as a bridge between GCM API and GCMClient layer for testing purposes. | 24 // Acts as a bridge between GCM API and GCMClient layer for testing purposes. |
25 class FakeGCMProfileService : public GCMProfileService { | 25 class FakeGCMProfileService : public GCMProfileService { |
26 public: | 26 public: |
27 typedef base::Callback<void(const std::string&)> UnregisterCallback; | 27 typedef base::Callback<void(const std::string&)> UnregisterCallback; |
28 | 28 |
29 // Helper function to be used with | 29 // Helper function to be used with |
30 // KeyedService::SetTestingFactory(). | 30 // KeyedService::SetTestingFactory(). |
31 static std::unique_ptr<KeyedService> Build(content::BrowserContext* context); | 31 static std::unique_ptr<KeyedService> Build(content::BrowserContext* context); |
32 | 32 |
33 explicit FakeGCMProfileService(Profile* profile); | 33 FakeGCMProfileService(); |
34 ~FakeGCMProfileService() override; | 34 ~FakeGCMProfileService() override; |
35 | 35 |
36 void RegisterFinished(const std::string& app_id, | 36 void RegisterFinished(const std::string& app_id, |
37 const std::vector<std::string>& sender_ids); | 37 const std::vector<std::string>& sender_ids); |
38 void UnregisterFinished(const std::string& app_id); | 38 void UnregisterFinished(const std::string& app_id); |
39 void SendFinished(const std::string& app_id, | 39 void SendFinished(const std::string& app_id, |
40 const std::string& receiver_id, | 40 const std::string& receiver_id, |
41 const OutgoingMessage& message); | 41 const OutgoingMessage& message); |
42 | 42 |
43 void AddExpectedUnregisterResponse(GCMClient::Result result); | 43 void AddExpectedUnregisterResponse(GCMClient::Result result); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 std::list<GCMClient::Result> unregister_responses_; | 79 std::list<GCMClient::Result> unregister_responses_; |
80 OutgoingMessage last_sent_message_; | 80 OutgoingMessage last_sent_message_; |
81 std::string last_receiver_id_; | 81 std::string last_receiver_id_; |
82 UnregisterCallback unregister_callback_; | 82 UnregisterCallback unregister_callback_; |
83 | 83 |
84 DISALLOW_COPY_AND_ASSIGN(FakeGCMProfileService); | 84 DISALLOW_COPY_AND_ASSIGN(FakeGCMProfileService); |
85 }; | 85 }; |
86 | 86 |
87 } // namespace gcm | 87 } // namespace gcm |
88 | 88 |
89 #endif // CHROME_BROWSER_SERVICES_GCM_FAKE_GCM_PROFILE_SERVICE_H_ | 89 #endif // COMPONENTS_GCM_DRIVER_GCM_FAKE_PROFILE_SERVICE_H_ |
OLD | NEW |