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

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

Issue 290013011: Move all remaining files to gcm_driver component (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix per feedback Created 6 years, 6 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_SERVICES_GCM_FAKE_GCM_CLIENT_H_
6 #define CHROME_BROWSER_SERVICES_GCM_FAKE_GCM_CLIENT_H_
7
8 #include "base/compiler_specific.h"
9 #include "base/memory/weak_ptr.h"
10 #include "google_apis/gcm/gcm_client.h"
11
12 namespace base {
13 class SequencedTaskRunner;
14 }
15
16 namespace gcm {
17
18 class FakeGCMClient : public GCMClient {
19 public:
20 enum Status {
21 UNINITIALIZED,
22 STARTED,
23 STOPPED,
24 CHECKED_OUT
25 };
26
27 enum StartMode {
28 NO_DELAY_START,
29 DELAY_START,
30 };
31
32 FakeGCMClient(StartMode start_mode,
33 const scoped_refptr<base::SequencedTaskRunner>& ui_thread,
34 const scoped_refptr<base::SequencedTaskRunner>& io_thread);
35 virtual ~FakeGCMClient();
36
37 // Overridden from GCMClient:
38 // Called on IO thread.
39 virtual void Initialize(
40 const ChromeBuildInfo& chrome_build_info,
41 const base::FilePath& store_path,
42 const std::vector<std::string>& account_ids,
43 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner,
44 const scoped_refptr<net::URLRequestContextGetter>&
45 url_request_context_getter,
46 scoped_ptr<Encryptor> encryptor,
47 Delegate* delegate) OVERRIDE;
48 virtual void Start() OVERRIDE;
49 virtual void Stop() OVERRIDE;
50 virtual void CheckOut() OVERRIDE;
51 virtual void Register(const std::string& app_id,
52 const std::vector<std::string>& sender_ids) OVERRIDE;
53 virtual void Unregister(const std::string& app_id) OVERRIDE;
54 virtual void Send(const std::string& app_id,
55 const std::string& receiver_id,
56 const OutgoingMessage& message) OVERRIDE;
57 virtual void SetRecording(bool recording) OVERRIDE;
58 virtual void ClearActivityLogs() OVERRIDE;
59 virtual GCMStatistics GetStatistics() const OVERRIDE;
60
61 // Initiate the loading that has been delayed.
62 // Called on UI thread.
63 void PerformDelayedLoading();
64
65 // Simulate receiving something from the server.
66 // Called on UI thread.
67 void ReceiveMessage(const std::string& app_id,
68 const IncomingMessage& message);
69 void DeleteMessages(const std::string& app_id);
70
71 static std::string GetRegistrationIdFromSenderIds(
72 const std::vector<std::string>& sender_ids);
73
74 Status status() const { return status_; }
75
76 private:
77 // Called on IO thread.
78 void DoLoading();
79 void CheckinFinished();
80 void RegisterFinished(const std::string& app_id,
81 const std::string& registrion_id);
82 void UnregisterFinished(const std::string& app_id);
83 void SendFinished(const std::string& app_id, const OutgoingMessage& message);
84 void MessageReceived(const std::string& app_id,
85 const IncomingMessage& message);
86 void MessagesDeleted(const std::string& app_id);
87 void MessageSendError(const std::string& app_id,
88 const SendErrorDetails& send_error_details);
89
90 Delegate* delegate_;
91 Status status_;
92 StartMode start_mode_;
93 scoped_refptr<base::SequencedTaskRunner> ui_thread_;
94 scoped_refptr<base::SequencedTaskRunner> io_thread_;
95 base::WeakPtrFactory<FakeGCMClient> weak_ptr_factory_;
96
97 DISALLOW_COPY_AND_ASSIGN(FakeGCMClient);
98 };
99
100 } // namespace gcm
101
102 #endif // CHROME_BROWSER_SERVICES_GCM_FAKE_GCM_CLIENT_H_
OLDNEW
« no previous file with comments | « chrome/browser/services/gcm/fake_gcm_app_handler.cc ('k') | chrome/browser/services/gcm/fake_gcm_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698