| 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 virtual bool IsRunning() override { |
| 30 return timer_.IsRunning(); | 30 return timer_.IsRunning(); |
| 31 } | 31 } |
| 32 | 32 |
| 33 virtual void Start(const tracked_objects::Location& from_here, | 33 virtual void Start(const tracked_objects::Location& from_here, |
| 34 const base::TimeDelta& delay, | 34 const base::TimeDelta& delay, |
| 35 const base::Closure& closure) OVERRIDE { | 35 const base::Closure& closure) override { |
| 36 timer_.Start(from_here, delay, closure); | 36 timer_.Start(from_here, delay, closure); |
| 37 } | 37 } |
| 38 | 38 |
| 39 virtual base::TimeTicks Now() const OVERRIDE { | 39 virtual base::TimeTicks Now() const override { |
| 40 return base::TimeTicks::Now(); | 40 return base::TimeTicks::Now(); |
| 41 } | 41 } |
| 42 | 42 |
| 43 virtual ~BaseTimerHelper() {} | 43 virtual ~BaseTimerHelper() {} |
| 44 | 44 |
| 45 private: | 45 private: |
| 46 base::OneShotTimer<SyncProcessRunner> timer_; | 46 base::OneShotTimer<SyncProcessRunner> timer_; |
| 47 | 47 |
| 48 DISALLOW_COPY_AND_ASSIGN(BaseTimerHelper); | 48 DISALLOW_COPY_AND_ASSIGN(BaseTimerHelper); |
| 49 }; | 49 }; |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 FROM_HERE, next_scheduled - now, | 237 FROM_HERE, next_scheduled - now, |
| 238 base::Bind(&SyncProcessRunner::Run, base::Unretained(this))); | 238 base::Bind(&SyncProcessRunner::Run, base::Unretained(this))); |
| 239 } | 239 } |
| 240 | 240 |
| 241 void SyncProcessRunner::CheckIfIdle() { | 241 void SyncProcessRunner::CheckIfIdle() { |
| 242 if (pending_changes_ == 0 && running_tasks_ == 0) | 242 if (pending_changes_ == 0 && running_tasks_ == 0) |
| 243 client_->OnSyncIdle(); | 243 client_->OnSyncIdle(); |
| 244 } | 244 } |
| 245 | 245 |
| 246 } // namespace sync_file_system | 246 } // namespace sync_file_system |
| OLD | NEW |