| 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 | 9 |
| 10 namespace sync_file_system { | 10 namespace sync_file_system { |
| 11 | 11 |
| 12 const int64 SyncProcessRunner::kSyncDelayInMilliseconds = | 12 const int64 SyncProcessRunner::kSyncDelayInMilliseconds = |
| 13 1 * base::Time::kMillisecondsPerSecond; // 1 sec | 13 1 * base::Time::kMillisecondsPerSecond; // 1 sec |
| 14 const int64 SyncProcessRunner::kSyncDelayWithSyncError = | 14 const int64 SyncProcessRunner::kSyncDelayWithSyncError = |
| 15 3 * base::Time::kMillisecondsPerSecond; // 3 sec | 15 3 * base::Time::kMillisecondsPerSecond; // 3 sec |
| 16 const int64 SyncProcessRunner::kSyncDelayFastInMilliseconds = 100; // 100 ms | 16 const int64 SyncProcessRunner::kSyncDelayFastInMilliseconds = 100; // 100 ms |
| 17 const int SyncProcessRunner::kPendingChangeThresholdForFastSync = 10; | 17 const int SyncProcessRunner::kPendingChangeThresholdForFastSync = 10; |
| 18 const int64 SyncProcessRunner::kSyncDelaySlowInMilliseconds = | 18 const int64 SyncProcessRunner::kSyncDelaySlowInMilliseconds = |
| 19 30 * base::Time::kMillisecondsPerSecond; // 30 sec | 19 30 * base::Time::kMillisecondsPerSecond; // 30 sec |
| 20 const int64 SyncProcessRunner::kSyncDelayMaxInMilliseconds = | 20 const int64 SyncProcessRunner::kSyncDelayMaxInMilliseconds = |
| 21 30 * 60 * base::Time::kMillisecondsPerSecond; // 30 min | 21 30 * 60 * base::Time::kMillisecondsPerSecond; // 30 min |
| 22 | 22 |
| 23 namespace { | 23 namespace { |
| 24 | 24 |
| 25 class BaseTimerHelper : public SyncProcessRunner::TimerHelper { | 25 class BaseTimerHelper : public SyncProcessRunner::TimerHelper { |
| 26 public: | 26 public: |
| 27 BaseTimerHelper() {} | 27 BaseTimerHelper() {} |
| 28 | 28 |
| 29 virtual bool IsRunning() override { | 29 bool IsRunning() override { return timer_.IsRunning(); } |
| 30 return timer_.IsRunning(); | |
| 31 } | |
| 32 | 30 |
| 33 virtual void Start(const tracked_objects::Location& from_here, | 31 void Start(const tracked_objects::Location& from_here, |
| 34 const base::TimeDelta& delay, | 32 const base::TimeDelta& delay, |
| 35 const base::Closure& closure) override { | 33 const base::Closure& closure) override { |
| 36 timer_.Start(from_here, delay, closure); | 34 timer_.Start(from_here, delay, closure); |
| 37 } | 35 } |
| 38 | 36 |
| 39 virtual base::TimeTicks Now() const override { | 37 base::TimeTicks Now() const override { return base::TimeTicks::Now(); } |
| 40 return base::TimeTicks::Now(); | |
| 41 } | |
| 42 | 38 |
| 43 virtual ~BaseTimerHelper() {} | 39 ~BaseTimerHelper() override {} |
| 44 | 40 |
| 45 private: | 41 private: |
| 46 base::OneShotTimer<SyncProcessRunner> timer_; | 42 base::OneShotTimer<SyncProcessRunner> timer_; |
| 47 | 43 |
| 48 DISALLOW_COPY_AND_ASSIGN(BaseTimerHelper); | 44 DISALLOW_COPY_AND_ASSIGN(BaseTimerHelper); |
| 49 }; | 45 }; |
| 50 | 46 |
| 51 bool WasSuccessfulSync(SyncStatusCode status) { | 47 bool WasSuccessfulSync(SyncStatusCode status) { |
| 52 return status == SYNC_STATUS_OK || | 48 return status == SYNC_STATUS_OK || |
| 53 status == SYNC_STATUS_HAS_CONFLICT || | 49 status == SYNC_STATUS_HAS_CONFLICT || |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 FROM_HERE, next_scheduled - now, | 233 FROM_HERE, next_scheduled - now, |
| 238 base::Bind(&SyncProcessRunner::Run, base::Unretained(this))); | 234 base::Bind(&SyncProcessRunner::Run, base::Unretained(this))); |
| 239 } | 235 } |
| 240 | 236 |
| 241 void SyncProcessRunner::CheckIfIdle() { | 237 void SyncProcessRunner::CheckIfIdle() { |
| 242 if (pending_changes_ == 0 && running_tasks_ == 0) | 238 if (pending_changes_ == 0 && running_tasks_ == 0) |
| 243 client_->OnSyncIdle(); | 239 client_->OnSyncIdle(); |
| 244 } | 240 } |
| 245 | 241 |
| 246 } // namespace sync_file_system | 242 } // namespace sync_file_system |
| OLD | NEW |