Explicitly add python-numpy dependency to install-build-deps.
[chromium-blink-merge.git] / components / gcm_driver / fake_gcm_client.h
blob56a3f1e5b983c6de3fb7fa9e12f41ae9b3da7502
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.
5 #ifndef COMPONENTS_GCM_DRIVER_FAKE_GCM_CLIENT_H_
6 #define COMPONENTS_GCM_DRIVER_FAKE_GCM_CLIENT_H_
8 #include "base/compiler_specific.h"
9 #include "base/memory/weak_ptr.h"
10 #include "components/gcm_driver/gcm_client.h"
12 namespace base {
13 class SequencedTaskRunner;
16 namespace gcm {
18 class FakeGCMClient : public GCMClient {
19 public:
20 enum Status {
21 UNINITIALIZED,
22 STARTED,
23 STOPPED,
24 CHECKED_OUT
27 enum StartMode {
28 NO_DELAY_START,
29 DELAY_START,
32 FakeGCMClient(StartMode start_mode,
33 const scoped_refptr<base::SequencedTaskRunner>& ui_thread,
34 const scoped_refptr<base::SequencedTaskRunner>& io_thread);
35 ~FakeGCMClient() override;
37 // Overridden from GCMClient:
38 // Called on IO thread.
39 void Initialize(
40 const ChromeBuildInfo& chrome_build_info,
41 const base::FilePath& store_path,
42 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner,
43 const scoped_refptr<net::URLRequestContextGetter>&
44 url_request_context_getter,
45 scoped_ptr<Encryptor> encryptor,
46 Delegate* delegate) override;
47 void Start() override;
48 void Stop() override;
49 void CheckOut() override;
50 void Register(const std::string& app_id,
51 const std::vector<std::string>& sender_ids) override;
52 void Unregister(const std::string& app_id) override;
53 void Send(const std::string& app_id,
54 const std::string& receiver_id,
55 const OutgoingMessage& message) override;
56 void SetRecording(bool recording) override;
57 void ClearActivityLogs() override;
58 GCMStatistics GetStatistics() const override;
59 void SetAccountTokens(
60 const std::vector<AccountTokenInfo>& account_tokens) override;
61 void UpdateAccountMapping(const AccountMapping& account_mapping) override;
62 void RemoveAccountMapping(const std::string& account_id) override;
63 void SetLastTokenFetchTime(const base::Time& time) override;
65 // Initiate the loading that has been delayed.
66 // Called on UI thread.
67 void PerformDelayedLoading();
69 // Simulate receiving something from the server.
70 // Called on UI thread.
71 void ReceiveMessage(const std::string& app_id,
72 const IncomingMessage& message);
73 void DeleteMessages(const std::string& app_id);
75 std::string GetRegistrationIdFromSenderIds(
76 const std::vector<std::string>& sender_ids) const;
78 Status status() const { return status_; }
80 private:
81 // Called on IO thread.
82 void DoLoading();
83 void CheckinFinished();
84 void RegisterFinished(const std::string& app_id,
85 const std::string& registrion_id);
86 void UnregisterFinished(const std::string& app_id);
87 void SendFinished(const std::string& app_id, const OutgoingMessage& message);
88 void MessageReceived(const std::string& app_id,
89 const IncomingMessage& message);
90 void MessagesDeleted(const std::string& app_id);
91 void MessageSendError(const std::string& app_id,
92 const SendErrorDetails& send_error_details);
93 void SendAcknowledgement(const std::string& app_id,
94 const std::string& message_id);
96 Delegate* delegate_;
97 // Increased at checkout in order to produce a different registration ID
98 // after checkout and re-checkin.
99 int sequence_id_;
100 Status status_;
101 StartMode start_mode_;
102 scoped_refptr<base::SequencedTaskRunner> ui_thread_;
103 scoped_refptr<base::SequencedTaskRunner> io_thread_;
104 base::WeakPtrFactory<FakeGCMClient> weak_ptr_factory_;
106 DISALLOW_COPY_AND_ASSIGN(FakeGCMClient);
109 } // namespace gcm
111 #endif // COMPONENTS_GCM_DRIVER_FAKE_GCM_CLIENT_H_