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

Side by Side Diff: components/copresence/copresence_manager_impl.h

Issue 2130803002: Deleting the copresence API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 5 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 | « components/copresence/OWNERS ('k') | components/copresence/copresence_manager_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 COMPONENTS_COPRESENCE_COPRESENCE_MANAGER_IMPL_H_
6 #define COMPONENTS_COPRESENCE_COPRESENCE_MANAGER_IMPL_H_
7
8 #include <google/protobuf/repeated_field.h>
9
10 #include <memory>
11 #include <string>
12 #include <vector>
13
14 #include "base/cancelable_callback.h"
15 #include "base/macros.h"
16 #include "components/copresence/copresence_state_impl.h"
17 #include "components/copresence/public/copresence_manager.h"
18 #include "components/copresence/timed_map.h"
19
20 namespace audio_modem {
21 struct AudioToken;
22 }
23
24 namespace base {
25 class Timer;
26 }
27
28 namespace net {
29 class URLContextGetter;
30 }
31
32 namespace copresence {
33
34 class DirectiveHandler;
35 class GCMHandler;
36 class ReportRequest;
37 class RpcHandler;
38 class SubscribedMessage;
39
40 // The implementation for CopresenceManager. Responsible primarily for
41 // client-side initialization. The RpcHandler handles all the details
42 // of interacting with the server.
43 // TODO(ckehoe, rkc): Add tests for this class.
44 class CopresenceManagerImpl : public CopresenceManager {
45 public:
46 // The delegate is owned by the caller, and must outlive the manager.
47 explicit CopresenceManagerImpl(CopresenceDelegate* delegate);
48
49 ~CopresenceManagerImpl() override;
50
51 // CopresenceManager overrides.
52 CopresenceState* state() override;
53 void ExecuteReportRequest(const ReportRequest& request,
54 const std::string& app_id,
55 const std::string& auth_token,
56 const StatusCallback& callback) override;
57
58 private:
59 // Complete initialization when Whispernet is available.
60 void WhispernetInitComplete(bool success);
61
62 // Handle tokens decoded by Whispernet.
63 // TODO(ckehoe): Replace AudioToken with ReceivedToken.
64 void ReceivedTokens(const std::vector<audio_modem::AudioToken>& tokens);
65
66 // Verifies that we can hear the audio we're playing.
67 // This gets called every kAudioCheckIntervalMs milliseconds.
68 void AudioCheck();
69
70 // This gets called every kPollTimerIntervalMs milliseconds
71 // to poll the server for new messages.
72 void PollForMessages();
73
74 // Send SubscribedMessages to the appropriate clients.
75 void DispatchMessages(
76 const google::protobuf::RepeatedPtrField<SubscribedMessage>&
77 subscribed_messages);
78
79 // Belongs to the caller.
80 CopresenceDelegate* const delegate_;
81
82 // We use a CancelableCallback here because Whispernet
83 // does not provide a way to unregister its init callback.
84 base::CancelableCallback<void(bool)> whispernet_init_callback_;
85
86 bool init_failed_;
87
88 // The RpcHandler makes calls to the other objects here, so it must come last.
89 std::unique_ptr<CopresenceStateImpl> state_;
90 std::unique_ptr<DirectiveHandler> directive_handler_;
91 std::unique_ptr<GCMHandler> gcm_handler_;
92 std::unique_ptr<RpcHandler> rpc_handler_;
93
94 std::unique_ptr<base::Timer> poll_timer_;
95 std::unique_ptr<base::Timer> audio_check_timer_;
96
97 TimedMap<std::string, google::protobuf::RepeatedPtrField<SubscribedMessage>>
98 queued_messages_by_token_;
99
100 DISALLOW_COPY_AND_ASSIGN(CopresenceManagerImpl);
101 };
102
103 } // namespace copresence
104
105 #endif // COMPONENTS_COPRESENCE_COPRESENCE_MANAGER_IMPL_H_
OLDNEW
« no previous file with comments | « components/copresence/OWNERS ('k') | components/copresence/copresence_manager_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698