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

Side by Side Diff: sync/notifier/sync_invalidation_listener.cc

Issue 116533006: Control invalidations network channel from TiclInvalidationService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 11 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "sync/notifier/sync_invalidation_listener.h" 5 #include "sync/notifier/sync_invalidation_listener.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 12 matching lines...) Expand all
23 23
24 const char kApplicationName[] = "chrome-sync"; 24 const char kApplicationName[] = "chrome-sync";
25 25
26 } // namespace 26 } // namespace
27 27
28 namespace syncer { 28 namespace syncer {
29 29
30 SyncInvalidationListener::Delegate::~Delegate() {} 30 SyncInvalidationListener::Delegate::~Delegate() {}
31 31
32 SyncInvalidationListener::SyncInvalidationListener( 32 SyncInvalidationListener::SyncInvalidationListener(
33 scoped_ptr<notifier::PushClient> push_client) 33 scoped_ptr<SyncNetworkChannel> network_channel)
34 : push_client_channel_(push_client.Pass()), 34 : sync_network_channel_(network_channel.Pass()),
35 sync_system_resources_(&push_client_channel_, this), 35 sync_system_resources_(sync_network_channel_.get(), this),
36 delegate_(NULL), 36 delegate_(NULL),
37 ticl_state_(DEFAULT_INVALIDATION_ERROR), 37 ticl_state_(DEFAULT_INVALIDATION_ERROR),
38 push_client_state_(DEFAULT_INVALIDATION_ERROR), 38 push_client_state_(DEFAULT_INVALIDATION_ERROR),
39 weak_ptr_factory_(this) { 39 weak_ptr_factory_(this) {
40 DCHECK(CalledOnValidThread()); 40 DCHECK(CalledOnValidThread());
41 push_client_channel_.AddObserver(this); 41 sync_network_channel_->AddObserver(this);
42 } 42 }
43 43
44 SyncInvalidationListener::~SyncInvalidationListener() { 44 SyncInvalidationListener::~SyncInvalidationListener() {
45 DCHECK(CalledOnValidThread()); 45 DCHECK(CalledOnValidThread());
46 push_client_channel_.RemoveObserver(this); 46 sync_network_channel_->RemoveObserver(this);
47 Stop(); 47 Stop();
48 DCHECK(!delegate_); 48 DCHECK(!delegate_);
49 } 49 }
50 50
51 void SyncInvalidationListener::Start( 51 void SyncInvalidationListener::Start(
52 const CreateInvalidationClientCallback& 52 const CreateInvalidationClientCallback&
53 create_invalidation_client_callback, 53 create_invalidation_client_callback,
54 const std::string& client_id, const std::string& client_info, 54 const std::string& client_id, const std::string& client_info,
55 const std::string& invalidation_bootstrap_data, 55 const std::string& invalidation_bootstrap_data,
56 const UnackedInvalidationsMap& initial_unacked_invalidations, 56 const UnackedInvalidationsMap& initial_unacked_invalidations,
(...skipping 30 matching lines...) Expand all
87 kApplicationName, this)); 87 kApplicationName, this));
88 invalidation_client_->Start(); 88 invalidation_client_->Start();
89 89
90 registration_manager_.reset( 90 registration_manager_.reset(
91 new RegistrationManager(invalidation_client_.get())); 91 new RegistrationManager(invalidation_client_.get()));
92 } 92 }
93 93
94 void SyncInvalidationListener::UpdateCredentials( 94 void SyncInvalidationListener::UpdateCredentials(
95 const std::string& email, const std::string& token) { 95 const std::string& email, const std::string& token) {
96 DCHECK(CalledOnValidThread()); 96 DCHECK(CalledOnValidThread());
97 push_client_channel_.UpdateCredentials(email, token); 97 sync_network_channel_->UpdateCredentials(email, token);
98 } 98 }
99 99
100 void SyncInvalidationListener::UpdateRegisteredIds(const ObjectIdSet& ids) { 100 void SyncInvalidationListener::UpdateRegisteredIds(const ObjectIdSet& ids) {
101 DCHECK(CalledOnValidThread()); 101 DCHECK(CalledOnValidThread());
102 registered_ids_ = ids; 102 registered_ids_ = ids;
103 // |ticl_state_| can go to INVALIDATIONS_ENABLED even without a 103 // |ticl_state_| can go to INVALIDATIONS_ENABLED even without a
104 // working XMPP connection (as observed by us), so check it instead 104 // working XMPP connection (as observed by us), so check it instead
105 // of GetState() (see http://crbug.com/139424). 105 // of GetState() (see http://crbug.com/139424).
106 if (ticl_state_ == INVALIDATIONS_ENABLED && registration_manager_) { 106 if (ticl_state_ == INVALIDATIONS_ENABLED && registration_manager_) {
107 DoRegistrationUpdate(); 107 DoRegistrationUpdate();
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 } 411 }
412 412
413 void SyncInvalidationListener::OnNetworkChannelStateChanged( 413 void SyncInvalidationListener::OnNetworkChannelStateChanged(
414 InvalidatorState invalidator_state) { 414 InvalidatorState invalidator_state) {
415 DCHECK(CalledOnValidThread()); 415 DCHECK(CalledOnValidThread());
416 push_client_state_ = invalidator_state; 416 push_client_state_ = invalidator_state;
417 EmitStateChange(); 417 EmitStateChange();
418 } 418 }
419 419
420 } // namespace syncer 420 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/notifier/sync_invalidation_listener.h ('k') | sync/notifier/sync_invalidation_listener_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698