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

Unified Diff: chrome/browser/sync/engine/syncapi.cc

Issue 7530023: sync: Disable network change notifications for unauthenticated users. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/engine/syncapi.cc
diff --git a/chrome/browser/sync/engine/syncapi.cc b/chrome/browser/sync/engine/syncapi.cc
index e7159479e689c51dfc8ed0e99440d299fae6f5eb..6f87e786ea2235095a9e0bd952f4b2df8dbcdebe 100644
--- a/chrome/browser/sync/engine/syncapi.cc
+++ b/chrome/browser/sync/engine/syncapi.cc
@@ -1201,6 +1201,7 @@ class SyncManager::SyncInternal
registrar_(NULL),
initialized_(false),
setup_for_test_mode_(false),
+ observing_ip_address_changes_(false),
js_transaction_observer_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
// Pre-fill |notification_info_map_|.
for (int i = syncable::FIRST_REAL_MODEL_TYPE;
@@ -1627,6 +1628,9 @@ class SyncManager::SyncInternal
// scheduler actually communicating with the server).
bool setup_for_test_mode_;
+ // Whether we should respond to an IP address change notification.
+ bool observing_ip_address_changes_;
akalin 2011/07/29 03:08:57 I think having 'bool has_valid_credentials_;' is c
+
// Map used to store the notification info to be displayed in
// about:sync page.
NotificationInfoMap notification_info_map_;
@@ -1770,6 +1774,7 @@ bool SyncManager::SyncInternal::Init(
sync_server_and_path, port, use_ssl, user_agent, post_factory));
net::NetworkChangeNotifier::AddIPAddressObserver(this);
+ observing_ip_address_changes_ = true;
akalin 2011/07/29 03:08:57 shouldn't this remain false? We're initing, but w
connection_manager()->AddListener(this);
@@ -1941,6 +1946,8 @@ void SyncManager::SyncInternal::UpdateCredentials(
DCHECK_EQ(credentials.email, share_.name);
DCHECK(!credentials.email.empty());
DCHECK(!credentials.sync_token.empty());
+
+ observing_ip_address_changes_ = true;
connection_manager()->set_auth_token(credentials.sync_token);
sync_notifier_->UpdateCredentials(
credentials.email, credentials.sync_token);
@@ -2237,6 +2244,7 @@ void SyncManager::SyncInternal::Shutdown() {
connection_manager_.reset();
net::NetworkChangeNotifier::RemoveIPAddressObserver(this);
+ observing_ip_address_changes_ = false;
if (dir_manager()) {
dir_manager()->FinalSaveChangesForAll();
@@ -2260,6 +2268,11 @@ void SyncManager::SyncInternal::Shutdown() {
void SyncManager::SyncInternal::OnIPAddressChanged() {
VLOG(1) << "IP address change detected";
+ if (!observing_ip_address_changes_) {
+ VLOG(1) << "IP address change dropped.";
akalin 2011/07/29 03:08:57 VLOG can also say something like "IP address chang
+ return;
+ }
+
#if defined (OS_CHROMEOS)
// TODO(tim): This is a hack to intentionally lose a race with flimflam at
// shutdown, so we don't cause shutdown to wait for our http request.
@@ -2292,6 +2305,7 @@ void SyncManager::SyncInternal::OnServerConnectionEvent(
}
if (event.connection_code == browser_sync::HttpResponse::SYNC_AUTH_ERROR) {
+ observing_ip_address_changes_ = false;
ObserverList<SyncManager::Observer> temp_obs_list;
CopyObservers(&temp_obs_list);
FOR_EACH_OBSERVER(SyncManager::Observer, temp_obs_list,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698