| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/sync_file_system/sync_process_runner.h" | 5 #include "chrome/browser/sync_file_system/sync_process_runner.h" |
| 6 | 6 |
| 7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
| 8 #include "chrome/browser/sync_file_system/logger.h" | 8 #include "chrome/browser/sync_file_system/logger.h" |
| 9 #include "chrome/browser/sync_file_system/sync_file_system_service.h" | 9 #include "chrome/browser/sync_file_system/sync_file_system_service.h" |
| 10 | 10 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 } | 86 } |
| 87 | 87 |
| 88 void SyncProcessRunner::ScheduleIfNotRunning() { | 88 void SyncProcessRunner::ScheduleIfNotRunning() { |
| 89 if (!timer_.IsRunning()) | 89 if (!timer_.IsRunning()) |
| 90 Schedule(); | 90 Schedule(); |
| 91 } | 91 } |
| 92 | 92 |
| 93 void SyncProcessRunner::OnChangesUpdated( | 93 void SyncProcessRunner::OnChangesUpdated( |
| 94 int64 pending_changes) { | 94 int64 pending_changes) { |
| 95 DCHECK_GE(pending_changes, 0); | 95 DCHECK_GE(pending_changes, 0); |
| 96 if (pending_changes_ != pending_changes) { | 96 int64 old_pending_changes = pending_changes_; |
| 97 pending_changes_ = pending_changes; |
| 98 if (old_pending_changes != pending_changes) { |
| 97 if (pending_changes == 0) | 99 if (pending_changes == 0) |
| 98 sync_service()->OnSyncIdle(); | 100 sync_service()->OnSyncIdle(); |
| 99 util::Log(logging::LOG_VERBOSE, FROM_HERE, | 101 util::Log(logging::LOG_VERBOSE, FROM_HERE, |
| 100 "[%s] pending_changes updated: %" PRId64, | 102 "[%s] pending_changes updated: %" PRId64, |
| 101 name_.c_str(), pending_changes); | 103 name_.c_str(), pending_changes); |
| 102 } | 104 } |
| 103 pending_changes_ = pending_changes; | |
| 104 Schedule(); | 105 Schedule(); |
| 105 } | 106 } |
| 106 | 107 |
| 107 SyncServiceState SyncProcessRunner::GetServiceState() { | 108 SyncServiceState SyncProcessRunner::GetServiceState() { |
| 108 return sync_service()->GetSyncServiceState(); | 109 return sync_service()->GetSyncServiceState(); |
| 109 } | 110 } |
| 110 | 111 |
| 111 void SyncProcessRunner::Finished(SyncStatusCode status) { | 112 void SyncProcessRunner::Finished(SyncStatusCode status) { |
| 112 DCHECK(running_); | 113 DCHECK(running_); |
| 113 running_ = false; | 114 running_ = false; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 util::Log(logging::LOG_VERBOSE, FROM_HERE, | 161 util::Log(logging::LOG_VERBOSE, FROM_HERE, |
| 161 "[%s] Scheduling task in %" PRId64 " secs", | 162 "[%s] Scheduling task in %" PRId64 " secs", |
| 162 name_.c_str(), time_to_next.InSeconds()); | 163 name_.c_str(), time_to_next.InSeconds()); |
| 163 } | 164 } |
| 164 current_delay_ = delay; | 165 current_delay_ = delay; |
| 165 | 166 |
| 166 timer_.Start(FROM_HERE, time_to_next, this, &SyncProcessRunner::Run); | 167 timer_.Start(FROM_HERE, time_to_next, this, &SyncProcessRunner::Run); |
| 167 } | 168 } |
| 168 | 169 |
| 169 } // namespace sync_file_system | 170 } // namespace sync_file_system |
| OLD | NEW |