Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / services / gcm / fake_gcm_profile_service.h
blob65757fe65e3848e662c5744cffa2dd4e2bf69eea
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_SERVICES_GCM_FAKE_GCM_PROFILE_SERVICE_H_
6 #define CHROME_BROWSER_SERVICES_GCM_FAKE_GCM_PROFILE_SERVICE_H_
8 #include "chrome/browser/services/gcm/gcm_profile_service.h"
10 namespace content {
11 class BrowserContext;
12 } // namespace content
14 namespace gcm {
16 // Acts as a bridge between GCM API and GCMClient layer for testing purposes.
17 class FakeGCMProfileService : public GCMProfileService {
18 public:
19 // Helper function to be used with
20 // BrowserContextKeyedService::SetTestingFactory().
21 static BrowserContextKeyedService* Build(content::BrowserContext* context);
23 static void EnableGCMForTesting();
25 explicit FakeGCMProfileService(Profile* profile);
26 virtual ~FakeGCMProfileService();
28 // GCMProfileService overrides.
29 virtual void Register(const std::string& app_id,
30 const std::vector<std::string>& sender_ids,
31 const std::string& cert,
32 RegisterCallback callback) OVERRIDE;
33 virtual void Send(const std::string& app_id,
34 const std::string& receiver_id,
35 const GCMClient::OutgoingMessage& message,
36 SendCallback callback) OVERRIDE;
38 void RegisterFinished(const std::string& app_id,
39 const std::vector<std::string>& sender_ids,
40 const std::string& cert,
41 RegisterCallback callback);
43 void SendFinished(const std::string& app_id,
44 const std::string& receiver_id,
45 const GCMClient::OutgoingMessage& message,
46 SendCallback callback);
48 const GCMClient::OutgoingMessage& last_sent_message() const {
49 return last_sent_message_;
52 const std::string& last_receiver_id() const {
53 return last_receiver_id_;
56 const std::string& last_registered_app_id() const {
57 return last_registered_app_id_;
60 const std::vector<std::string>& last_registered_sender_ids() const {
61 return last_registered_sender_ids_;
64 const std::string& last_registered_cert() const {
65 return last_registered_cert_;
68 void set_collect(bool collect) {
69 collect_ = collect;
72 private:
73 // Indicates whether the serivce will collect paramters of the calls for
74 // furter verification in tests.
75 bool collect_;
76 std::string last_registered_app_id_;
77 std::vector<std::string> last_registered_sender_ids_;
78 std::string last_registered_cert_;
79 GCMClient::OutgoingMessage last_sent_message_;
80 std::string last_receiver_id_;
82 DISALLOW_COPY_AND_ASSIGN(FakeGCMProfileService);
85 } // namespace gcm
87 #endif // CHROME_BROWSER_SERVICES_GCM_FAKE_GCM_PROFILE_SERVICE_H_