OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <deque> | 5 #include <deque> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 task_manager_.reset(new SyncTaskManager( | 63 task_manager_.reset(new SyncTaskManager( |
64 AsWeakPtr(), maximum_background_task, | 64 AsWeakPtr(), maximum_background_task, |
65 base::ThreadTaskRunnerHandle::Get())); | 65 base::ThreadTaskRunnerHandle::Get())); |
66 task_manager_->Initialize(SYNC_STATUS_OK); | 66 task_manager_->Initialize(SYNC_STATUS_OK); |
67 base::MessageLoop::current()->RunUntilIdle(); | 67 base::MessageLoop::current()->RunUntilIdle(); |
68 maybe_schedule_next_task_count_ = 0; | 68 maybe_schedule_next_task_count_ = 0; |
69 } | 69 } |
70 virtual ~TaskManagerClient() {} | 70 virtual ~TaskManagerClient() {} |
71 | 71 |
72 // DriveFileSyncManager::Client overrides. | 72 // DriveFileSyncManager::Client overrides. |
73 virtual void MaybeScheduleNextTask() OVERRIDE { | 73 virtual void MaybeScheduleNextTask() override { |
74 ++maybe_schedule_next_task_count_; | 74 ++maybe_schedule_next_task_count_; |
75 } | 75 } |
76 virtual void NotifyLastOperationStatus( | 76 virtual void NotifyLastOperationStatus( |
77 SyncStatusCode last_operation_status, | 77 SyncStatusCode last_operation_status, |
78 bool last_operation_used_network) OVERRIDE { | 78 bool last_operation_used_network) override { |
79 last_operation_status_ = last_operation_status; | 79 last_operation_status_ = last_operation_status; |
80 } | 80 } |
81 | 81 |
82 virtual void RecordTaskLog(scoped_ptr<TaskLogger::TaskLog>) OVERRIDE {} | 82 virtual void RecordTaskLog(scoped_ptr<TaskLogger::TaskLog>) override {} |
83 | 83 |
84 void ScheduleTask(SyncStatusCode status_to_return, | 84 void ScheduleTask(SyncStatusCode status_to_return, |
85 const SyncStatusCallback& callback) { | 85 const SyncStatusCallback& callback) { |
86 task_manager_->ScheduleTask( | 86 task_manager_->ScheduleTask( |
87 FROM_HERE, | 87 FROM_HERE, |
88 base::Bind(&TaskManagerClient::DoTask, AsWeakPtr(), | 88 base::Bind(&TaskManagerClient::DoTask, AsWeakPtr(), |
89 status_to_return, false /* idle */), | 89 status_to_return, false /* idle */), |
90 SyncTaskManager::PRIORITY_MED, | 90 SyncTaskManager::PRIORITY_MED, |
91 callback); | 91 callback); |
92 } | 92 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 bool* task_completed) | 136 bool* task_completed) |
137 : task_started_(task_started), | 137 : task_started_(task_started), |
138 task_completed_(task_completed), | 138 task_completed_(task_completed), |
139 weak_ptr_factory_(this) { | 139 weak_ptr_factory_(this) { |
140 DCHECK(task_started_); | 140 DCHECK(task_started_); |
141 DCHECK(task_completed_); | 141 DCHECK(task_completed_); |
142 } | 142 } |
143 | 143 |
144 virtual ~MultihopSyncTask() {} | 144 virtual ~MultihopSyncTask() {} |
145 | 145 |
146 virtual void RunExclusive(const SyncStatusCallback& callback) OVERRIDE { | 146 virtual void RunExclusive(const SyncStatusCallback& callback) override { |
147 DCHECK(!*task_started_); | 147 DCHECK(!*task_started_); |
148 *task_started_ = true; | 148 *task_started_ = true; |
149 base::MessageLoop::current()->PostTask( | 149 base::MessageLoop::current()->PostTask( |
150 FROM_HERE, base::Bind(&MultihopSyncTask::CompleteTask, | 150 FROM_HERE, base::Bind(&MultihopSyncTask::CompleteTask, |
151 weak_ptr_factory_.GetWeakPtr(), callback)); | 151 weak_ptr_factory_.GetWeakPtr(), callback)); |
152 } | 152 } |
153 | 153 |
154 private: | 154 private: |
155 void CompleteTask(const SyncStatusCallback& callback) { | 155 void CompleteTask(const SyncStatusCallback& callback) { |
156 DCHECK(*task_started_); | 156 DCHECK(*task_started_); |
(...skipping 27 matching lines...) Expand all Loading... |
184 Stats* stats) | 184 Stats* stats) |
185 : app_id_(app_id), | 185 : app_id_(app_id), |
186 path_(path), | 186 path_(path), |
187 stats_(stats), | 187 stats_(stats), |
188 weak_ptr_factory_(this) { | 188 weak_ptr_factory_(this) { |
189 } | 189 } |
190 | 190 |
191 virtual ~BackgroundTask() { | 191 virtual ~BackgroundTask() { |
192 } | 192 } |
193 | 193 |
194 virtual void RunPreflight(scoped_ptr<SyncTaskToken> token) OVERRIDE { | 194 virtual void RunPreflight(scoped_ptr<SyncTaskToken> token) override { |
195 scoped_ptr<TaskBlocker> task_blocker(new TaskBlocker); | 195 scoped_ptr<TaskBlocker> task_blocker(new TaskBlocker); |
196 task_blocker->app_id = app_id_; | 196 task_blocker->app_id = app_id_; |
197 task_blocker->paths.push_back(path_); | 197 task_blocker->paths.push_back(path_); |
198 | 198 |
199 SyncTaskManager::UpdateTaskBlocker( | 199 SyncTaskManager::UpdateTaskBlocker( |
200 token.Pass(), task_blocker.Pass(), | 200 token.Pass(), task_blocker.Pass(), |
201 base::Bind(&BackgroundTask::RunAsBackgroundTask, | 201 base::Bind(&BackgroundTask::RunAsBackgroundTask, |
202 weak_ptr_factory_.GetWeakPtr())); | 202 weak_ptr_factory_.GetWeakPtr())); |
203 } | 203 } |
204 | 204 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 : name_(name), | 241 : name_(name), |
242 app_id_(app_id), | 242 app_id_(app_id), |
243 paths_(paths.begin(), paths.end()), | 243 paths_(paths.begin(), paths.end()), |
244 log_(log), | 244 log_(log), |
245 weak_ptr_factory_(this) { | 245 weak_ptr_factory_(this) { |
246 } | 246 } |
247 | 247 |
248 virtual ~BlockerUpdateTestHelper() { | 248 virtual ~BlockerUpdateTestHelper() { |
249 } | 249 } |
250 | 250 |
251 virtual void RunPreflight(scoped_ptr<SyncTaskToken> token) OVERRIDE { | 251 virtual void RunPreflight(scoped_ptr<SyncTaskToken> token) override { |
252 UpdateBlocker(token.Pass()); | 252 UpdateBlocker(token.Pass()); |
253 } | 253 } |
254 | 254 |
255 private: | 255 private: |
256 void UpdateBlocker(scoped_ptr<SyncTaskToken> token) { | 256 void UpdateBlocker(scoped_ptr<SyncTaskToken> token) { |
257 if (paths_.empty()) { | 257 if (paths_.empty()) { |
258 log_->push_back(name_ + ": finished"); | 258 log_->push_back(name_ + ": finished"); |
259 SyncTaskManager::NotifyTaskDone(token.Pass(), SYNC_STATUS_OK); | 259 SyncTaskManager::NotifyTaskDone(token.Pass(), SYNC_STATUS_OK); |
260 return; | 260 return; |
261 } | 261 } |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
667 | 667 |
668 EXPECT_EQ("task1: finished", log[i++]); | 668 EXPECT_EQ("task1: finished", log[i++]); |
669 | 669 |
670 EXPECT_EQ("task2: updating to /hoge/fuga/piyo", log[i++]); | 670 EXPECT_EQ("task2: updating to /hoge/fuga/piyo", log[i++]); |
671 EXPECT_EQ("task2: updated to /hoge/fuga/piyo", log[i++]); | 671 EXPECT_EQ("task2: updated to /hoge/fuga/piyo", log[i++]); |
672 EXPECT_EQ("task2: finished", log[i++]); | 672 EXPECT_EQ("task2: finished", log[i++]); |
673 } | 673 } |
674 | 674 |
675 } // namespace drive_backend | 675 } // namespace drive_backend |
676 } // namespace sync_file_system | 676 } // namespace sync_file_system |
OLD | NEW |