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

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

Issue 9251035: Delete lots of sync ServerConnectionManager code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/sync/engine/sync_scheduler.cc
diff --git a/chrome/browser/sync/engine/sync_scheduler.cc b/chrome/browser/sync/engine/sync_scheduler.cc
index 8ba1959db08b8a15dcb22210a1077b08f2cf1990..8b7eef1fffcb616a8a21d39961ac0b13993e77e7 100644
--- a/chrome/browser/sync/engine/sync_scheduler.cc
+++ b/chrome/browser/sync/engine/sync_scheduler.cc
@@ -190,7 +190,6 @@ SyncScheduler::SyncScheduler(const std::string& name,
sessions_commit_delay_(
TimeDelta::FromSeconds(kDefaultSessionsCommitDelaySeconds)),
mode_(NORMAL_MODE),
- server_connection_ok_(false),
delay_provider_(new DelayProvider()),
syncer_(syncer),
session_context_(context) {
@@ -202,38 +201,6 @@ SyncScheduler::~SyncScheduler() {
StopImpl(base::Closure());
}
-void SyncScheduler::CheckServerConnectionManagerStatus(
- HttpResponse::ServerConnectionCode code) {
- DCHECK_EQ(MessageLoop::current(), sync_loop_);
- SDVLOG(2) << "New server connection code: "
- << HttpResponse::GetServerConnectionCodeString(code);
- bool old_server_connection_ok = server_connection_ok_;
-
- // Note, be careful when adding cases here because if the SyncScheduler
- // thinks there is no valid connection as determined by this method, it
- // will drop out of *all* forward progress sync loops (it won't poll and it
- // will queue up Talk notifications but not actually call SyncShare) until
- // some external action causes a ServerConnectionManager to broadcast that
- // a valid connection has been re-established.
- if (HttpResponse::CONNECTION_UNAVAILABLE == code ||
- HttpResponse::SYNC_AUTH_ERROR == code) {
- server_connection_ok_ = false;
- SDVLOG(2) << "Sync auth error or unavailable connection: "
- << "server connection is down";
- } else if (HttpResponse::SERVER_CONNECTION_OK == code) {
- server_connection_ok_ = true;
- SDVLOG(2) << "Sync server connection is ok: "
- << "server connection is up, doing canary job";
- DoCanaryJob();
- }
-
- if (old_server_connection_ok != server_connection_ok_) {
- const char* transition =
- server_connection_ok_ ? "down -> up" : "up -> down";
- SDVLOG(2) << "Server connection changed: " << transition;
- }
-}
-
void SyncScheduler::Start(Mode mode, const base::Closure& callback) {
DCHECK_EQ(MessageLoop::current(), sync_loop_);
std::string thread_name = MessageLoop::current()->thread_name();
@@ -243,7 +210,6 @@ void SyncScheduler::Start(Mode mode, const base::Closure& callback) {
<< thread_name << " with mode " << GetModeString(mode);
if (!started_) {
started_ = true;
- WatchConnectionManager();
PostTask(FROM_HERE, "SendInitialSnapshot",
base::Bind(&SyncScheduler::SendInitialSnapshot,
weak_ptr_factory_.GetWeakPtr()));
@@ -264,16 +230,6 @@ void SyncScheduler::SendInitialSnapshot() {
session_context_->NotifyListeners(event);
}
-void SyncScheduler::WatchConnectionManager() {
- DCHECK_EQ(MessageLoop::current(), sync_loop_);
- ServerConnectionManager* scm = session_context_->connection_manager();
- PostTask(FROM_HERE, "CheckServerConnectionManagerStatus",
- base::Bind(&SyncScheduler::CheckServerConnectionManagerStatus,
- weak_ptr_factory_.GetWeakPtr(),
- scm->server_status()));
- scm->AddListener(this);
-}
-
void SyncScheduler::StartImpl(Mode mode, const base::Closure& callback) {
DCHECK_EQ(MessageLoop::current(), sync_loop_);
SDVLOG(2) << "In StartImpl with mode " << GetModeString(mode);
@@ -358,10 +314,10 @@ SyncScheduler::JobProcessDecision SyncScheduler::DecideOnJob(
return DROP;
}
- if (server_connection_ok_)
+ if (!session_context_->connection_manager()->HasInvalidAuthToken())
return CONTINUE;
- SDVLOG(2) << "Bad server connection. Using that to decide on job.";
+ SDVLOG(2) << "We have no valid auth token. Using that to decide on job.";
return job.purpose == SyncSessionJob::NUDGE ? SAVE : DROP;
}
@@ -1016,7 +972,6 @@ void SyncScheduler::StopImpl(const base::Closure& callback) {
wait_interval_.reset();
poll_timer_.Stop();
if (started_) {
- session_context_->connection_manager()->RemoveListener(this);
started_ = false;
}
if (!callback.is_null())
@@ -1172,14 +1127,11 @@ void SyncScheduler::OnSyncProtocolError(
OnActionableError(snapshot);
}
+void SyncScheduler::TryToConnect() {
+ if (wait_interval_.get() && wait_interval_->mode == WaitInterval::THROTTLED)
+ return;
-void SyncScheduler::OnServerConnectionEvent(
- const ServerConnectionEvent& event) {
- DCHECK_EQ(MessageLoop::current(), sync_loop_);
- PostTask(FROM_HERE, "CheckServerConnectionManagerStatus",
- base::Bind(&SyncScheduler::CheckServerConnectionManagerStatus,
- weak_ptr_factory_.GetWeakPtr(),
- event.connection_code));
+ DoCanaryJob();
}
void SyncScheduler::set_notifications_enabled(bool notifications_enabled) {

Powered by Google App Engine
This is Rietveld 408576698