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

Side by Side Diff: components/gcm_driver/fake_gcm_client.h

Issue 848503002: [GCM] Remove GCMDriver::Purge and GCMClient::CheckOut (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
« no previous file with comments | « no previous file | components/gcm_driver/fake_gcm_client.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 COMPONENTS_GCM_DRIVER_FAKE_GCM_CLIENT_H_ 5 #ifndef COMPONENTS_GCM_DRIVER_FAKE_GCM_CLIENT_H_
6 #define COMPONENTS_GCM_DRIVER_FAKE_GCM_CLIENT_H_ 6 #define COMPONENTS_GCM_DRIVER_FAKE_GCM_CLIENT_H_
7 7
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "components/gcm_driver/gcm_client.h" 10 #include "components/gcm_driver/gcm_client.h"
11 11
12 namespace base { 12 namespace base {
13 class SequencedTaskRunner; 13 class SequencedTaskRunner;
14 } 14 }
15 15
16 namespace gcm { 16 namespace gcm {
17 17
18 class FakeGCMClient : public GCMClient { 18 class FakeGCMClient : public GCMClient {
19 public: 19 public:
20 enum Status {
21 UNINITIALIZED,
22 STARTED,
23 STOPPED,
24 CHECKED_OUT
25 };
26
27 enum StartMode { 20 enum StartMode {
28 NO_DELAY_START, 21 NO_DELAY_START,
29 DELAY_START, 22 DELAY_START,
30 }; 23 };
31 24
32 FakeGCMClient(StartMode start_mode, 25 FakeGCMClient(StartMode start_mode,
33 const scoped_refptr<base::SequencedTaskRunner>& ui_thread, 26 const scoped_refptr<base::SequencedTaskRunner>& ui_thread,
34 const scoped_refptr<base::SequencedTaskRunner>& io_thread); 27 const scoped_refptr<base::SequencedTaskRunner>& io_thread);
35 ~FakeGCMClient() override; 28 ~FakeGCMClient() override;
36 29
37 // Overridden from GCMClient: 30 // Overridden from GCMClient:
38 // Called on IO thread. 31 // Called on IO thread.
39 void Initialize( 32 void Initialize(
40 const ChromeBuildInfo& chrome_build_info, 33 const ChromeBuildInfo& chrome_build_info,
41 const base::FilePath& store_path, 34 const base::FilePath& store_path,
42 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner, 35 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner,
43 const scoped_refptr<net::URLRequestContextGetter>& 36 const scoped_refptr<net::URLRequestContextGetter>&
44 url_request_context_getter, 37 url_request_context_getter,
45 scoped_ptr<Encryptor> encryptor, 38 scoped_ptr<Encryptor> encryptor,
46 Delegate* delegate) override; 39 Delegate* delegate) override;
47 void Start() override; 40 void Start() override;
48 void Stop() override; 41 void Stop() override;
49 void CheckOut() override;
50 void Register(const std::string& app_id, 42 void Register(const std::string& app_id,
51 const std::vector<std::string>& sender_ids) override; 43 const std::vector<std::string>& sender_ids) override;
52 void Unregister(const std::string& app_id) override; 44 void Unregister(const std::string& app_id) override;
53 void Send(const std::string& app_id, 45 void Send(const std::string& app_id,
54 const std::string& receiver_id, 46 const std::string& receiver_id,
55 const OutgoingMessage& message) override; 47 const OutgoingMessage& message) override;
56 void SetRecording(bool recording) override; 48 void SetRecording(bool recording) override;
57 void ClearActivityLogs() override; 49 void ClearActivityLogs() override;
58 GCMStatistics GetStatistics() const override; 50 GCMStatistics GetStatistics() const override;
59 void SetAccountTokens( 51 void SetAccountTokens(
60 const std::vector<AccountTokenInfo>& account_tokens) override; 52 const std::vector<AccountTokenInfo>& account_tokens) override;
61 void UpdateAccountMapping(const AccountMapping& account_mapping) override; 53 void UpdateAccountMapping(const AccountMapping& account_mapping) override;
62 void RemoveAccountMapping(const std::string& account_id) override; 54 void RemoveAccountMapping(const std::string& account_id) override;
63 void SetLastTokenFetchTime(const base::Time& time) override; 55 void SetLastTokenFetchTime(const base::Time& time) override;
64 void UpdateHeartbeatTimer(scoped_ptr<base::Timer> timer) override; 56 void UpdateHeartbeatTimer(scoped_ptr<base::Timer> timer) override;
65 57
66 // Initiate the loading that has been delayed. 58 // Initiate the loading that has been delayed.
67 // Called on UI thread. 59 // Called on UI thread.
68 void PerformDelayedLoading(); 60 void PerformDelayedLoading();
69 61
70 // Simulate receiving something from the server. 62 // Simulate receiving something from the server.
71 // Called on UI thread. 63 // Called on UI thread.
72 void ReceiveMessage(const std::string& app_id, 64 void ReceiveMessage(const std::string& app_id,
73 const IncomingMessage& message); 65 const IncomingMessage& message);
74 void DeleteMessages(const std::string& app_id); 66 void DeleteMessages(const std::string& app_id);
75 67
76 std::string GetRegistrationIdFromSenderIds( 68 std::string GetRegistrationIdFromSenderIds(
77 const std::vector<std::string>& sender_ids) const; 69 const std::vector<std::string>& sender_ids) const;
78 70
79 Status status() const { return status_; }
80
81 private: 71 private:
82 // Called on IO thread. 72 // Called on IO thread.
83 void DoLoading(); 73 void DoLoading();
84 void CheckinFinished(); 74 void CheckinFinished();
85 void RegisterFinished(const std::string& app_id, 75 void RegisterFinished(const std::string& app_id,
86 const std::string& registrion_id); 76 const std::string& registrion_id);
87 void UnregisterFinished(const std::string& app_id); 77 void UnregisterFinished(const std::string& app_id);
88 void SendFinished(const std::string& app_id, const OutgoingMessage& message); 78 void SendFinished(const std::string& app_id, const OutgoingMessage& message);
89 void MessageReceived(const std::string& app_id, 79 void MessageReceived(const std::string& app_id,
90 const IncomingMessage& message); 80 const IncomingMessage& message);
91 void MessagesDeleted(const std::string& app_id); 81 void MessagesDeleted(const std::string& app_id);
92 void MessageSendError(const std::string& app_id, 82 void MessageSendError(const std::string& app_id,
93 const SendErrorDetails& send_error_details); 83 const SendErrorDetails& send_error_details);
94 void SendAcknowledgement(const std::string& app_id, 84 void SendAcknowledgement(const std::string& app_id,
95 const std::string& message_id); 85 const std::string& message_id);
96 86
97 Delegate* delegate_; 87 Delegate* delegate_;
98 // Increased at checkout in order to produce a different registration ID 88 // Increased at checkout in order to produce a different registration ID
99 // after checkout and re-checkin. 89 // after checkout and re-checkin.
100 int sequence_id_; 90 int sequence_id_;
101 Status status_; 91 bool started_;
102 StartMode start_mode_; 92 StartMode start_mode_;
103 scoped_refptr<base::SequencedTaskRunner> ui_thread_; 93 scoped_refptr<base::SequencedTaskRunner> ui_thread_;
104 scoped_refptr<base::SequencedTaskRunner> io_thread_; 94 scoped_refptr<base::SequencedTaskRunner> io_thread_;
105 base::WeakPtrFactory<FakeGCMClient> weak_ptr_factory_; 95 base::WeakPtrFactory<FakeGCMClient> weak_ptr_factory_;
106 96
107 DISALLOW_COPY_AND_ASSIGN(FakeGCMClient); 97 DISALLOW_COPY_AND_ASSIGN(FakeGCMClient);
108 }; 98 };
109 99
110 } // namespace gcm 100 } // namespace gcm
111 101
112 #endif // COMPONENTS_GCM_DRIVER_FAKE_GCM_CLIENT_H_ 102 #endif // COMPONENTS_GCM_DRIVER_FAKE_GCM_CLIENT_H_
OLDNEW
« no previous file with comments | « no previous file | components/gcm_driver/fake_gcm_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698