Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: chrome/browser/services/gcm/fake_gcm_profile_service.h

Issue 286213003: Make GCMProfileService own GCMDriver, instead of deriving from it (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <list>
9 #include <vector>
10
11 #include "chrome/browser/services/gcm/gcm_driver.h"
8 #include "chrome/browser/services/gcm/gcm_profile_service.h" 12 #include "chrome/browser/services/gcm/gcm_profile_service.h"
9 13
10 namespace content { 14 namespace content {
11 class BrowserContext; 15 class BrowserContext;
12 } // namespace content 16 } // namespace content
13 17
14 namespace gcm { 18 namespace gcm {
15 19
16 // Acts as a bridge between GCM API and GCMClient layer for testing purposes. 20 // Acts as a bridge between GCM API and GCMClient layer for testing purposes.
17 class FakeGCMProfileService : public GCMProfileService { 21 class FakeGCMProfileService : public GCMProfileService {
18 public: 22 public:
19 // Helper function to be used with 23 // Helper function to be used with
20 // KeyedService::SetTestingFactory(). 24 // KeyedService::SetTestingFactory().
21 static KeyedService* Build(content::BrowserContext* context); 25 static KeyedService* Build(content::BrowserContext* context);
22 26
23 explicit FakeGCMProfileService(Profile* profile); 27 explicit FakeGCMProfileService(Profile* profile);
24 virtual ~FakeGCMProfileService(); 28 virtual ~FakeGCMProfileService();
25 29
26 // GCMProfileService overrides.
27 virtual void Register(const std::string& app_id,
28 const std::vector<std::string>& sender_ids,
29 const RegisterCallback& callback) OVERRIDE;
30 virtual void Unregister(const std::string& app_id,
31 const UnregisterCallback& callback) OVERRIDE;
32 virtual void Send(const std::string& app_id,
33 const std::string& receiver_id,
34 const GCMClient::OutgoingMessage& message,
35 const SendCallback& callback) OVERRIDE;
36
37 void RegisterFinished(const std::string& app_id, 30 void RegisterFinished(const std::string& app_id,
38 const std::vector<std::string>& sender_ids, 31 const std::vector<std::string>& sender_ids,
39 const RegisterCallback& callback); 32 const GCMDriver::RegisterCallback& callback);
40 33 void UnregisterFinished(const std::string& app_id,
34 const GCMDriver::UnregisterCallback& callback);
41 void SendFinished(const std::string& app_id, 35 void SendFinished(const std::string& app_id,
42 const std::string& receiver_id, 36 const std::string& receiver_id,
43 const GCMClient::OutgoingMessage& message, 37 const GCMClient::OutgoingMessage& message,
44 const SendCallback& callback); 38 const GCMDriver::SendCallback& callback);
45 39
46 void AddExpectedUnregisterResponse(GCMClient::Result result); 40 void AddExpectedUnregisterResponse(GCMClient::Result result);
47 GCMClient::Result GetNextExpectedUnregisterResponse();
48 41
49 const GCMClient::OutgoingMessage& last_sent_message() const { 42 const GCMClient::OutgoingMessage& last_sent_message() const {
50 return last_sent_message_; 43 return last_sent_message_;
51 } 44 }
52 45
53 const std::string& last_receiver_id() const { 46 const std::string& last_receiver_id() const {
54 return last_receiver_id_; 47 return last_receiver_id_;
55 } 48 }
56 49
57 const std::string& last_registered_app_id() const { 50 const std::string& last_registered_app_id() const {
58 return last_registered_app_id_; 51 return last_registered_app_id_;
59 } 52 }
60 53
61 const std::vector<std::string>& last_registered_sender_ids() const { 54 const std::vector<std::string>& last_registered_sender_ids() const {
62 return last_registered_sender_ids_; 55 return last_registered_sender_ids_;
63 } 56 }
64 57
65 void set_collect(bool collect) { 58 void set_collect(bool collect) {
66 collect_ = collect; 59 collect_ = collect;
67 } 60 }
68 61
69 private: 62 private:
70 // Indicates whether the serivce will collect paramters of the calls for 63 // Indicates whether the serivce will collect paramters of the calls for
71 // furter verification in tests. 64 // furter verification in tests.
72 bool collect_; 65 bool collect_;
73 std::string last_registered_app_id_; 66 std::string last_registered_app_id_;
74 std::vector<std::string> last_registered_sender_ids_; 67 std::vector<std::string> last_registered_sender_ids_;
75 std::vector<GCMClient::Result> unregister_responses_; 68 std::list<GCMClient::Result> unregister_responses_;
76 GCMClient::OutgoingMessage last_sent_message_; 69 GCMClient::OutgoingMessage last_sent_message_;
77 std::string last_receiver_id_; 70 std::string last_receiver_id_;
78 71
79 DISALLOW_COPY_AND_ASSIGN(FakeGCMProfileService); 72 DISALLOW_COPY_AND_ASSIGN(FakeGCMProfileService);
80 }; 73 };
81 74
82 } // namespace gcm 75 } // namespace gcm
83 76
84 #endif // CHROME_BROWSER_SERVICES_GCM_FAKE_GCM_PROFILE_SERVICE_H_ 77 #endif // CHROME_BROWSER_SERVICES_GCM_FAKE_GCM_PROFILE_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698