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

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: Fix trybots 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>
Nicolas Zea 2014/05/19 21:04:06 nit: newline after
jianli 2014/05/19 23:03:48 Done.
10 #include "chrome/browser/services/gcm/gcm_driver.h"
8 #include "chrome/browser/services/gcm/gcm_profile_service.h" 11 #include "chrome/browser/services/gcm/gcm_profile_service.h"
9 12
10 namespace content { 13 namespace content {
11 class BrowserContext; 14 class BrowserContext;
12 } // namespace content 15 } // namespace content
13 16
14 namespace gcm { 17 namespace gcm {
15 18
16 // Acts as a bridge between GCM API and GCMClient layer for testing purposes. 19 // Acts as a bridge between GCM API and GCMClient layer for testing purposes.
17 class FakeGCMProfileService : public GCMProfileService { 20 class FakeGCMProfileService : public GCMProfileService {
18 public: 21 public:
19 // Helper function to be used with 22 // Helper function to be used with
20 // KeyedService::SetTestingFactory(). 23 // KeyedService::SetTestingFactory().
21 static KeyedService* Build(content::BrowserContext* context); 24 static KeyedService* Build(content::BrowserContext* context);
22 25
23 explicit FakeGCMProfileService(Profile* profile); 26 explicit FakeGCMProfileService(Profile* profile);
24 virtual ~FakeGCMProfileService(); 27 virtual ~FakeGCMProfileService();
25 28
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, 29 void RegisterFinished(const std::string& app_id,
38 const std::vector<std::string>& sender_ids, 30 const std::vector<std::string>& sender_ids,
39 const RegisterCallback& callback); 31 const GCMDriver::RegisterCallback& callback);
40 32 void UnregisterFinished(const std::string& app_id,
33 const GCMDriver::UnregisterCallback& callback);
41 void SendFinished(const std::string& app_id, 34 void SendFinished(const std::string& app_id,
42 const std::string& receiver_id, 35 const std::string& receiver_id,
43 const GCMClient::OutgoingMessage& message, 36 const GCMClient::OutgoingMessage& message,
44 const SendCallback& callback); 37 const GCMDriver::SendCallback& callback);
45 38
46 void AddExpectedUnregisterResponse(GCMClient::Result result); 39 void AddExpectedUnregisterResponse(GCMClient::Result result);
47 GCMClient::Result GetNextExpectedUnregisterResponse();
48 40
49 const GCMClient::OutgoingMessage& last_sent_message() const { 41 const GCMClient::OutgoingMessage& last_sent_message() const {
50 return last_sent_message_; 42 return last_sent_message_;
51 } 43 }
52 44
53 const std::string& last_receiver_id() const { 45 const std::string& last_receiver_id() const {
54 return last_receiver_id_; 46 return last_receiver_id_;
55 } 47 }
56 48
57 const std::string& last_registered_app_id() const { 49 const std::string& last_registered_app_id() const {
58 return last_registered_app_id_; 50 return last_registered_app_id_;
59 } 51 }
60 52
61 const std::vector<std::string>& last_registered_sender_ids() const { 53 const std::vector<std::string>& last_registered_sender_ids() const {
62 return last_registered_sender_ids_; 54 return last_registered_sender_ids_;
63 } 55 }
64 56
65 void set_collect(bool collect) { 57 void set_collect(bool collect) {
66 collect_ = collect; 58 collect_ = collect;
67 } 59 }
68 60
69 private: 61 private:
70 // Indicates whether the serivce will collect paramters of the calls for 62 // Indicates whether the serivce will collect paramters of the calls for
71 // furter verification in tests. 63 // furter verification in tests.
72 bool collect_; 64 bool collect_;
73 std::string last_registered_app_id_; 65 std::string last_registered_app_id_;
74 std::vector<std::string> last_registered_sender_ids_; 66 std::vector<std::string> last_registered_sender_ids_;
75 std::vector<GCMClient::Result> unregister_responses_; 67 std::list<GCMClient::Result> unregister_responses_;
76 GCMClient::OutgoingMessage last_sent_message_; 68 GCMClient::OutgoingMessage last_sent_message_;
77 std::string last_receiver_id_; 69 std::string last_receiver_id_;
78 70
79 DISALLOW_COPY_AND_ASSIGN(FakeGCMProfileService); 71 DISALLOW_COPY_AND_ASSIGN(FakeGCMProfileService);
80 }; 72 };
81 73
82 } // namespace gcm 74 } // namespace gcm
83 75
84 #endif // CHROME_BROWSER_SERVICES_GCM_FAKE_GCM_PROFILE_SERVICE_H_ 76 #endif // CHROME_BROWSER_SERVICES_GCM_FAKE_GCM_PROFILE_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698