| 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 CHROME_BROWSER_SERVICES_GCM_FAKE_GCM_PROFILE_SERVICE_H_ |
| 6 #define CHROME_BROWSER_SERVICES_GCM_FAKE_GCM_PROFILE_SERVICE_H_ | 6 #define CHROME_BROWSER_SERVICES_GCM_FAKE_GCM_PROFILE_SERVICE_H_ |
| 7 | 7 |
| 8 #include "chrome/browser/services/gcm/gcm_profile_service.h" | 8 #include "chrome/browser/services/gcm/gcm_profile_service.h" |
| 9 | 9 |
| 10 namespace content { | 10 namespace content { |
| 11 class BrowserContext; | 11 class BrowserContext; |
| 12 } // namespace content | 12 } // namespace content |
| 13 | 13 |
| 14 namespace gcm { | 14 namespace gcm { |
| 15 | 15 |
| 16 // Acts as a bridge between GCM API and GCMClient layer for testing purposes. | 16 // Acts as a bridge between GCM API and GCMClient layer for testing purposes. |
| 17 class FakeGCMProfileService : public GCMProfileService { | 17 class FakeGCMProfileService : public GCMProfileService { |
| 18 public: | 18 public: |
| 19 // Helper function to be used with | 19 // Helper function to be used with |
| 20 // BrowserContextKeyedService::SetTestingFactory(). | 20 // BrowserContextKeyedService::SetTestingFactory(). |
| 21 static BrowserContextKeyedService* Build(content::BrowserContext* context); | 21 static BrowserContextKeyedService* Build(content::BrowserContext* context); |
| 22 | 22 |
| 23 explicit FakeGCMProfileService(Profile* profile); | 23 explicit FakeGCMProfileService(Profile* profile); |
| 24 virtual ~FakeGCMProfileService(); | 24 virtual ~FakeGCMProfileService(); |
| 25 | 25 |
| 26 // GCMProfileService overrides. | 26 // GCMProfileService overrides. |
| 27 virtual void Register(const std::string& app_id, | 27 virtual void Register(const std::string& app_id, |
| 28 const std::vector<std::string>& sender_ids, | 28 const std::string& sender_id, |
| 29 const std::string& cert, | 29 const std::string& cert, |
| 30 RegisterCallback callback) OVERRIDE; | 30 RegisterCallback callback) OVERRIDE; |
| 31 virtual void Send(const std::string& app_id, | 31 virtual void Send(const std::string& app_id, |
| 32 const std::string& receiver_id, | 32 const std::string& receiver_id, |
| 33 const GCMClient::OutgoingMessage& message, | 33 const GCMClient::OutgoingMessage& message, |
| 34 SendCallback callback) OVERRIDE; | 34 SendCallback callback) 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::string& sender_id, |
| 38 const std::string& cert, | 38 const std::string& cert, |
| 39 RegisterCallback callback); | 39 RegisterCallback callback); |
| 40 | 40 |
| 41 void SendFinished(const std::string& app_id, | 41 void SendFinished(const std::string& app_id, |
| 42 const std::string& receiver_id, | 42 const std::string& receiver_id, |
| 43 const GCMClient::OutgoingMessage& message, | 43 const GCMClient::OutgoingMessage& message, |
| 44 SendCallback callback); | 44 SendCallback callback); |
| 45 | 45 |
| 46 const GCMClient::OutgoingMessage& last_sent_message() const { | 46 const GCMClient::OutgoingMessage& last_sent_message() const { |
| 47 return last_sent_message_; | 47 return last_sent_message_; |
| 48 } | 48 } |
| 49 | 49 |
| 50 const std::string& last_receiver_id() const { | 50 const std::string& last_receiver_id() const { |
| 51 return last_receiver_id_; | 51 return last_receiver_id_; |
| 52 } | 52 } |
| 53 | 53 |
| 54 const std::string& last_registered_app_id() const { | 54 const std::string& last_registered_app_id() const { |
| 55 return last_registered_app_id_; | 55 return last_registered_app_id_; |
| 56 } | 56 } |
| 57 | 57 |
| 58 const std::vector<std::string>& last_registered_sender_ids() const { | 58 const std::string& last_registered_sender_id() const { |
| 59 return last_registered_sender_ids_; | 59 return last_registered_sender_id_; |
| 60 } | 60 } |
| 61 | 61 |
| 62 const std::string& last_registered_cert() const { | 62 const std::string& last_registered_cert() const { |
| 63 return last_registered_cert_; | 63 return last_registered_cert_; |
| 64 } | 64 } |
| 65 | 65 |
| 66 void set_collect(bool collect) { | 66 void set_collect(bool collect) { |
| 67 collect_ = collect; | 67 collect_ = collect; |
| 68 } | 68 } |
| 69 | 69 |
| 70 private: | 70 private: |
| 71 // Indicates whether the serivce will collect paramters of the calls for | 71 // Indicates whether the serivce will collect paramters of the calls for |
| 72 // furter verification in tests. | 72 // furter verification in tests. |
| 73 bool collect_; | 73 bool collect_; |
| 74 std::string last_registered_app_id_; | 74 std::string last_registered_app_id_; |
| 75 std::vector<std::string> last_registered_sender_ids_; | 75 std::string last_registered_sender_id_; |
| 76 std::string last_registered_cert_; | 76 std::string last_registered_cert_; |
| 77 GCMClient::OutgoingMessage last_sent_message_; | 77 GCMClient::OutgoingMessage last_sent_message_; |
| 78 std::string last_receiver_id_; | 78 std::string last_receiver_id_; |
| 79 | 79 |
| 80 DISALLOW_COPY_AND_ASSIGN(FakeGCMProfileService); | 80 DISALLOW_COPY_AND_ASSIGN(FakeGCMProfileService); |
| 81 }; | 81 }; |
| 82 | 82 |
| 83 } // namespace gcm | 83 } // namespace gcm |
| 84 | 84 |
| 85 #endif // CHROME_BROWSER_SERVICES_GCM_FAKE_GCM_PROFILE_SERVICE_H_ | 85 #endif // CHROME_BROWSER_SERVICES_GCM_FAKE_GCM_PROFILE_SERVICE_H_ |
| OLD | NEW |