Mac: Fix performance issues with remote CoreAnimation
[chromium-blink-merge.git] / components / copresence / copresence_manager_impl.h
blobd91e7aeddb7dec86fcf5f6f0499814dee4365750
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_COPRESENCE_COPRESENCE_MANAGER_IMPL_H_
6 #define COMPONENTS_COPRESENCE_COPRESENCE_MANAGER_IMPL_H_
8 #include <string>
10 #include "base/cancelable_callback.h"
11 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "components/copresence/public/copresence_manager.h"
15 namespace base {
16 class Timer;
19 namespace net {
20 class URLContextGetter;
23 namespace copresence {
25 class DirectiveHandler;
26 class GCMHandler;
27 class ReportRequest;
28 class RpcHandler;
29 class WhispernetClient;
31 // The implementation for CopresenceManager. Responsible primarily for
32 // client-side initialization. The RpcHandler handles all the details
33 // of interacting with the server.
34 // TODO(rkc): Add tests for this class.
35 class CopresenceManagerImpl : public CopresenceManager {
36 public:
37 // The delegate is owned by the caller, and must outlive the manager.
38 explicit CopresenceManagerImpl(CopresenceDelegate* delegate);
40 ~CopresenceManagerImpl() override;
42 void ExecuteReportRequest(const ReportRequest& request,
43 const std::string& app_id,
44 const std::string& auth_token,
45 const StatusCallback& callback) override;
47 private:
48 void WhispernetInitComplete(bool success);
50 // This function will be called every kPollTimerIntervalMs milliseconds to
51 // poll the server for new messages.
52 void PollForMessages();
54 // This function will verify that we can hear the audio we're playing every
55 // kAudioCheckIntervalMs milliseconds.
56 void AudioCheck();
58 // Belongs to the caller.
59 CopresenceDelegate* const delegate_;
61 // We use a CancelableCallback here because Whispernet
62 // does not provide a way to unregister its init callback.
63 base::CancelableCallback<void(bool)> whispernet_init_callback_;
65 bool init_failed_;
67 // The GCMHandler must destruct before the DirectiveHandler,
68 // which must destruct before the RpcHandler. Do not change this order.
69 scoped_ptr<RpcHandler> rpc_handler_;
70 scoped_ptr<DirectiveHandler> directive_handler_;
71 scoped_ptr<GCMHandler> gcm_handler_;
73 scoped_ptr<base::Timer> poll_timer_;
74 scoped_ptr<base::Timer> audio_check_timer_;
76 DISALLOW_COPY_AND_ASSIGN(CopresenceManagerImpl);
79 } // namespace copresence
81 #endif // COMPONENTS_COPRESENCE_COPRESENCE_MANAGER_IMPL_H_