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 <utility> |
| 8 |
7 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
8 #include "base/macros.h" | 10 #include "base/macros.h" |
9 #include "chrome/browser/sync_file_system/logger.h" | 11 #include "chrome/browser/sync_file_system/logger.h" |
10 | 12 |
11 namespace sync_file_system { | 13 namespace sync_file_system { |
12 | 14 |
13 const int64_t SyncProcessRunner::kSyncDelayInMilliseconds = | 15 const int64_t SyncProcessRunner::kSyncDelayInMilliseconds = |
14 1 * base::Time::kMillisecondsPerSecond; // 1 sec | 16 1 * base::Time::kMillisecondsPerSecond; // 1 sec |
15 const int64_t SyncProcessRunner::kSyncDelayWithSyncError = | 17 const int64_t SyncProcessRunner::kSyncDelayWithSyncError = |
16 3 * base::Time::kMillisecondsPerSecond; // 3 sec | 18 3 * base::Time::kMillisecondsPerSecond; // 3 sec |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 return status == SYNC_STATUS_OK || | 51 return status == SYNC_STATUS_OK || |
50 status == SYNC_STATUS_HAS_CONFLICT || | 52 status == SYNC_STATUS_HAS_CONFLICT || |
51 status == SYNC_STATUS_NO_CONFLICT || | 53 status == SYNC_STATUS_NO_CONFLICT || |
52 status == SYNC_STATUS_NO_CHANGE_TO_SYNC || | 54 status == SYNC_STATUS_NO_CHANGE_TO_SYNC || |
53 status == SYNC_STATUS_UNKNOWN_ORIGIN || | 55 status == SYNC_STATUS_UNKNOWN_ORIGIN || |
54 status == SYNC_STATUS_RETRY; | 56 status == SYNC_STATUS_RETRY; |
55 } | 57 } |
56 | 58 |
57 } // namespace | 59 } // namespace |
58 | 60 |
59 SyncProcessRunner::SyncProcessRunner( | 61 SyncProcessRunner::SyncProcessRunner(const std::string& name, |
60 const std::string& name, | 62 Client* client, |
61 Client* client, | 63 scoped_ptr<TimerHelper> timer_helper, |
62 scoped_ptr<TimerHelper> timer_helper, | 64 size_t max_parallel_task) |
63 size_t max_parallel_task) | |
64 : name_(name), | 65 : name_(name), |
65 client_(client), | 66 client_(client), |
66 max_parallel_task_(max_parallel_task), | 67 max_parallel_task_(max_parallel_task), |
67 running_tasks_(0), | 68 running_tasks_(0), |
68 timer_helper_(timer_helper.Pass()), | 69 timer_helper_(std::move(timer_helper)), |
69 service_state_(SYNC_SERVICE_RUNNING), | 70 service_state_(SYNC_SERVICE_RUNNING), |
70 pending_changes_(0), | 71 pending_changes_(0), |
71 factory_(this) { | 72 factory_(this) { |
72 DCHECK_LE(1u, max_parallel_task_); | 73 DCHECK_LE(1u, max_parallel_task_); |
73 if (!timer_helper_) | 74 if (!timer_helper_) |
74 timer_helper_.reset(new BaseTimerHelper); | 75 timer_helper_.reset(new BaseTimerHelper); |
75 } | 76 } |
76 | 77 |
77 SyncProcessRunner::~SyncProcessRunner() {} | 78 SyncProcessRunner::~SyncProcessRunner() {} |
78 | 79 |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 FROM_HERE, next_scheduled - now, | 234 FROM_HERE, next_scheduled - now, |
234 base::Bind(&SyncProcessRunner::Run, base::Unretained(this))); | 235 base::Bind(&SyncProcessRunner::Run, base::Unretained(this))); |
235 } | 236 } |
236 | 237 |
237 void SyncProcessRunner::CheckIfIdle() { | 238 void SyncProcessRunner::CheckIfIdle() { |
238 if (pending_changes_ == 0 && running_tasks_ == 0) | 239 if (pending_changes_ == 0 && running_tasks_ == 0) |
239 client_->OnSyncIdle(); | 240 client_->OnSyncIdle(); |
240 } | 241 } |
241 | 242 |
242 } // namespace sync_file_system | 243 } // namespace sync_file_system |
OLD | NEW |