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

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

Issue 712833002: Undoing revert, cl is not the cause of gcm crash on canary. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2214
Patch Set: Created 6 years, 1 month 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 <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
11 #include "base/timer/timer.h" 11 #include "base/timer/timer.h"
12 #include "components/copresence/handlers/directive_handler.h" 12 #include "components/copresence/handlers/directive_handler.h"
13 #include "components/copresence/handlers/gcm_handler.h"
13 #include "components/copresence/proto/rpcs.pb.h" 14 #include "components/copresence/proto/rpcs.pb.h"
14 #include "components/copresence/public/whispernet_client.h" 15 #include "components/copresence/public/whispernet_client.h"
15 #include "components/copresence/rpc/rpc_handler.h" 16 #include "components/copresence/rpc/rpc_handler.h"
16 17
17 namespace { 18 namespace {
18 19
19 const int kPollTimerIntervalMs = 3000; // milliseconds. 20 const int kPollTimerIntervalMs = 3000; // milliseconds.
20 const int kAudioCheckIntervalMs = 1000; // milliseconds. 21 const int kAudioCheckIntervalMs = 1000; // milliseconds.
21 22
22 } // namespace 23 } // namespace
23 24
24 namespace copresence { 25 namespace copresence {
25 26
26 // Public functions. 27 // Public functions.
27 28
28 CopresenceManagerImpl::CopresenceManagerImpl(CopresenceDelegate* delegate) 29 CopresenceManagerImpl::CopresenceManagerImpl(CopresenceDelegate* delegate)
29 : delegate_(delegate), 30 : delegate_(delegate),
30 whispernet_init_callback_(base::Bind( 31 whispernet_init_callback_(base::Bind(
31 &CopresenceManagerImpl::WhispernetInitComplete, 32 &CopresenceManagerImpl::WhispernetInitComplete,
32 // This callback gets cancelled when we are destroyed. 33 // This callback gets cancelled when we are destroyed.
33 base::Unretained(this))), 34 base::Unretained(this))),
35 init_failed_(false),
34 directive_handler_(new DirectiveHandler), 36 directive_handler_(new DirectiveHandler),
35 poll_timer_(new base::RepeatingTimer<CopresenceManagerImpl>), 37 poll_timer_(new base::RepeatingTimer<CopresenceManagerImpl>),
36 audio_check_timer_(new base::RepeatingTimer<CopresenceManagerImpl>), 38 audio_check_timer_(new base::RepeatingTimer<CopresenceManagerImpl>) {
37 init_failed_(false) {
38 DCHECK(delegate_); 39 DCHECK(delegate_);
39 DCHECK(delegate_->GetWhispernetClient()); 40 DCHECK(delegate_->GetWhispernetClient());
40 delegate_->GetWhispernetClient()->Initialize( 41 delegate_->GetWhispernetClient()->Initialize(
41 whispernet_init_callback_.callback()); 42 whispernet_init_callback_.callback());
42 43
43 rpc_handler_.reset(new RpcHandler(delegate_, directive_handler_.get())); 44 if (delegate->GetGCMDriver())
45 gcm_handler_.reset(new GCMHandler(delegate->GetGCMDriver(),
46 directive_handler_.get()));
47
48 rpc_handler_.reset(new RpcHandler(delegate,
49 directive_handler_.get(),
50 gcm_handler_.get()));
44 } 51 }
45 52
46 CopresenceManagerImpl::~CopresenceManagerImpl() { 53 CopresenceManagerImpl::~CopresenceManagerImpl() {
47 whispernet_init_callback_.Cancel(); 54 whispernet_init_callback_.Cancel();
48 } 55 }
49 56
50 // Returns false if any operations were malformed. 57 // Returns false if any operations were malformed.
51 void CopresenceManagerImpl::ExecuteReportRequest( 58 void CopresenceManagerImpl::ExecuteReportRequest(
52 const ReportRequest& request, 59 const ReportRequest& request,
53 const std::string& app_id, 60 const std::string& app_id,
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 if (!directive_handler_->GetCurrentAudioToken(AUDIBLE).empty() && 120 if (!directive_handler_->GetCurrentAudioToken(AUDIBLE).empty() &&
114 !directive_handler_->IsAudioTokenHeard(AUDIBLE)) { 121 !directive_handler_->IsAudioTokenHeard(AUDIBLE)) {
115 delegate_->HandleStatusUpdate(AUDIO_FAIL); 122 delegate_->HandleStatusUpdate(AUDIO_FAIL);
116 } else if (!directive_handler_->GetCurrentAudioToken(INAUDIBLE).empty() && 123 } else if (!directive_handler_->GetCurrentAudioToken(INAUDIBLE).empty() &&
117 !directive_handler_->IsAudioTokenHeard(INAUDIBLE)) { 124 !directive_handler_->IsAudioTokenHeard(INAUDIBLE)) {
118 delegate_->HandleStatusUpdate(AUDIO_FAIL); 125 delegate_->HandleStatusUpdate(AUDIO_FAIL);
119 } 126 }
120 } 127 }
121 128
122 } // namespace copresence 129 } // namespace copresence
OLDNEW
« no previous file with comments | « components/copresence/copresence_manager_impl.h ('k') | components/copresence/handlers/gcm_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698