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

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

Issue 865483005: Creating the audio_modem component (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merging again Created 5 years, 10 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
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 #include "components/copresence/copresence_manager_impl.h" 5 #include "components/copresence/copresence_manager_impl.h"
6 6
7 #include <map> 7 #include <map>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "base/timer/timer.h" 13 #include "base/timer/timer.h"
14 #include "components/audio_modem/public/whispernet_client.h"
14 #include "components/copresence/copresence_state_impl.h" 15 #include "components/copresence/copresence_state_impl.h"
15 #include "components/copresence/handlers/directive_handler_impl.h" 16 #include "components/copresence/handlers/directive_handler_impl.h"
16 #include "components/copresence/handlers/gcm_handler_impl.h" 17 #include "components/copresence/handlers/gcm_handler_impl.h"
17 #include "components/copresence/proto/rpcs.pb.h" 18 #include "components/copresence/proto/rpcs.pb.h"
18 #include "components/copresence/public/whispernet_client.h"
19 #include "components/copresence/rpc/rpc_handler.h" 19 #include "components/copresence/rpc/rpc_handler.h"
20 20
21 using google::protobuf::RepeatedPtrField; 21 using google::protobuf::RepeatedPtrField;
22 22
23 using audio_modem::AUDIBLE;
24 using audio_modem::AudioToken;
25 using audio_modem::INAUDIBLE;
26
23 namespace { 27 namespace {
24 28
25 const int kPollTimerIntervalMs = 3000; // milliseconds. 29 const int kPollTimerIntervalMs = 3000; // milliseconds.
26 const int kAudioCheckIntervalMs = 1000; // milliseconds. 30 const int kAudioCheckIntervalMs = 1000; // milliseconds.
27 31
28 const int kQueuedMessageTimeout = 10; // seconds. 32 const int kQueuedMessageTimeout = 10; // seconds.
29 const int kMaxQueuedMessages = 1000; 33 const int kMaxQueuedMessages = 1000;
30 34
31 } // namespace 35 } // namespace
32 36
(...skipping 24 matching lines...) Expand all
57 // will be destructed before the CopresenceState instance. 61 // will be destructed before the CopresenceState instance.
58 base::Bind(&CopresenceStateImpl::UpdateDirectives, 62 base::Bind(&CopresenceStateImpl::UpdateDirectives,
59 base::Unretained(state_.get())))), 63 base::Unretained(state_.get())))),
60 poll_timer_(new base::RepeatingTimer<CopresenceManagerImpl>), 64 poll_timer_(new base::RepeatingTimer<CopresenceManagerImpl>),
61 audio_check_timer_(new base::RepeatingTimer<CopresenceManagerImpl>), 65 audio_check_timer_(new base::RepeatingTimer<CopresenceManagerImpl>),
62 queued_messages_by_token_( 66 queued_messages_by_token_(
63 base::TimeDelta::FromSeconds(kQueuedMessageTimeout), 67 base::TimeDelta::FromSeconds(kQueuedMessageTimeout),
64 kMaxQueuedMessages) { 68 kMaxQueuedMessages) {
65 DCHECK(delegate_); 69 DCHECK(delegate_);
66 DCHECK(delegate_->GetWhispernetClient()); 70 DCHECK(delegate_->GetWhispernetClient());
71 // TODO(ckehoe): Handle whispernet initialization in the whispernet component.
67 delegate_->GetWhispernetClient()->Initialize( 72 delegate_->GetWhispernetClient()->Initialize(
68 whispernet_init_callback_.callback()); 73 whispernet_init_callback_.callback());
69 74
70 MessagesCallback messages_callback = base::Bind( 75 MessagesCallback messages_callback = base::Bind(
71 &CopresenceManagerImpl::DispatchMessages, 76 &CopresenceManagerImpl::DispatchMessages,
72 // This will only be passed to objects that we own. 77 // This will only be passed to objects that we own.
73 base::Unretained(this)); 78 base::Unretained(this));
74 79
75 if (delegate->GetGCMDriver()) 80 if (delegate->GetGCMDriver())
76 gcm_handler_.reset(new GCMHandlerImpl(delegate->GetGCMDriver(), 81 gcm_handler_.reset(new GCMHandlerImpl(delegate->GetGCMDriver(),
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 for (const auto& map_entry : messages_by_subscription) { 260 for (const auto& map_entry : messages_by_subscription) {
256 // TODO(ckehoe): Once we have the app ID from the server, we need to pass 261 // TODO(ckehoe): Once we have the app ID from the server, we need to pass
257 // it in here and get rid of the app id registry from the main API class. 262 // it in here and get rid of the app id registry from the main API class.
258 const std::string& subscription = map_entry.first; 263 const std::string& subscription = map_entry.first;
259 const std::vector<Message>& messages = map_entry.second; 264 const std::vector<Message>& messages = map_entry.second;
260 delegate_->HandleMessages(std::string(), subscription, messages); 265 delegate_->HandleMessages(std::string(), subscription, messages);
261 } 266 }
262 } 267 }
263 268
264 } // namespace copresence 269 } // namespace copresence
OLDNEW
« no previous file with comments | « components/copresence/copresence_manager_impl.h ('k') | components/copresence/copresence_state_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698