OLD | NEW |
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" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 return true; | 43 return true; |
44 } | 44 } |
45 return false; | 45 return false; |
46 } | 46 } |
47 | 47 |
48 | 48 |
49 // Public functions. | 49 // Public functions. |
50 | 50 |
51 CopresenceManagerImpl::CopresenceManagerImpl(CopresenceDelegate* delegate) | 51 CopresenceManagerImpl::CopresenceManagerImpl(CopresenceDelegate* delegate) |
52 : delegate_(delegate), | 52 : delegate_(delegate), |
53 whispernet_init_callback_(base::Bind( | 53 whispernet_init_callback_( |
54 &CopresenceManagerImpl::WhispernetInitComplete, | 54 base::Bind(&CopresenceManagerImpl::WhispernetInitComplete, |
55 // This callback gets cancelled when we are destroyed. | 55 // This callback gets cancelled when we are destroyed. |
56 base::Unretained(this))), | 56 base::Unretained(this))), |
57 init_failed_(false), | 57 init_failed_(false), |
58 state_(new CopresenceStateImpl), | 58 state_(new CopresenceStateImpl), |
59 directive_handler_(new DirectiveHandlerImpl( | 59 directive_handler_(new DirectiveHandlerImpl( |
60 // The directive handler and its descendants | 60 // The directive handler and its descendants |
61 // will be destructed before the CopresenceState instance. | 61 // will be destructed before the CopresenceState instance. |
62 base::Bind(&CopresenceStateImpl::UpdateDirectives, | 62 base::Bind(&CopresenceStateImpl::UpdateDirectives, |
63 base::Unretained(state_.get())))), | 63 base::Unretained(state_.get())))), |
64 poll_timer_(new base::RepeatingTimer<CopresenceManagerImpl>), | 64 poll_timer_(new base::RepeatingTimer), |
65 audio_check_timer_(new base::RepeatingTimer<CopresenceManagerImpl>), | 65 audio_check_timer_(new base::RepeatingTimer), |
66 queued_messages_by_token_( | 66 queued_messages_by_token_( |
67 base::TimeDelta::FromSeconds(kQueuedMessageTimeout), | 67 base::TimeDelta::FromSeconds(kQueuedMessageTimeout), |
68 kMaxQueuedMessages) { | 68 kMaxQueuedMessages) { |
69 DCHECK(delegate_); | 69 DCHECK(delegate_); |
70 DCHECK(delegate_->GetWhispernetClient()); | 70 DCHECK(delegate_->GetWhispernetClient()); |
71 // TODO(ckehoe): Handle whispernet initialization in the whispernet component. | 71 // TODO(ckehoe): Handle whispernet initialization in the whispernet component. |
72 delegate_->GetWhispernetClient()->Initialize( | 72 delegate_->GetWhispernetClient()->Initialize( |
73 whispernet_init_callback_.callback()); | 73 whispernet_init_callback_.callback()); |
74 | 74 |
75 MessagesCallback messages_callback = base::Bind( | 75 MessagesCallback messages_callback = base::Bind( |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 for (const auto& map_entry : messages_by_subscription) { | 260 for (const auto& map_entry : messages_by_subscription) { |
261 // 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 |
262 // 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. |
263 const std::string& subscription = map_entry.first; | 263 const std::string& subscription = map_entry.first; |
264 const std::vector<Message>& messages = map_entry.second; | 264 const std::vector<Message>& messages = map_entry.second; |
265 delegate_->HandleMessages(std::string(), subscription, messages); | 265 delegate_->HandleMessages(std::string(), subscription, messages); |
266 } | 266 } |
267 } | 267 } |
268 | 268 |
269 } // namespace copresence | 269 } // namespace copresence |
OLD | NEW |