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 "chrome/browser/sync_file_system/drive_backend/sync_task_manager.h" | 5 #include "chrome/browser/sync_file_system/drive_backend/sync_task_manager.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/sequenced_task_runner.h" | 10 #include "base/sequenced_task_runner.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 | 65 |
66 SyncTaskManager::~SyncTaskManager() { | 66 SyncTaskManager::~SyncTaskManager() { |
67 client_.reset(); | 67 client_.reset(); |
68 token_.reset(); | 68 token_.reset(); |
69 } | 69 } |
70 | 70 |
71 void SyncTaskManager::Initialize(SyncStatusCode status) { | 71 void SyncTaskManager::Initialize(SyncStatusCode status) { |
72 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); | 72 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); |
73 DCHECK(!token_); | 73 DCHECK(!token_); |
74 NotifyTaskDone( | 74 NotifyTaskDone( |
75 SyncTaskToken::CreateForForegroundTask(AsWeakPtr(), task_runner_), | 75 SyncTaskToken::CreateForForegroundTask(AsWeakPtr(), task_runner_.get()), |
76 status); | 76 status); |
77 } | 77 } |
78 | 78 |
79 void SyncTaskManager::ScheduleTask( | 79 void SyncTaskManager::ScheduleTask( |
80 const tracked_objects::Location& from_here, | 80 const tracked_objects::Location& from_here, |
81 const Task& task, | 81 const Task& task, |
82 Priority priority, | 82 Priority priority, |
83 const SyncStatusCallback& callback) { | 83 const SyncStatusCallback& callback) { |
84 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); | 84 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); |
85 | 85 |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 } | 320 } |
321 | 321 |
322 if (background_task_token) { | 322 if (background_task_token) { |
323 background_task_token->set_blocking_factor(blocking_factor.Pass()); | 323 background_task_token->set_blocking_factor(blocking_factor.Pass()); |
324 } else { | 324 } else { |
325 tracked_objects::Location from_here = foreground_task_token->location(); | 325 tracked_objects::Location from_here = foreground_task_token->location(); |
326 SyncStatusCallback callback = foreground_task_token->callback(); | 326 SyncStatusCallback callback = foreground_task_token->callback(); |
327 foreground_task_token->clear_callback(); | 327 foreground_task_token->clear_callback(); |
328 | 328 |
329 background_task_token = | 329 background_task_token = |
330 SyncTaskToken::CreateForBackgroundTask( | 330 SyncTaskToken::CreateForBackgroundTask(AsWeakPtr(), |
331 AsWeakPtr(), | 331 task_runner_.get(), |
332 task_runner_, | 332 task_token_seq_++, |
333 task_token_seq_++, | 333 blocking_factor.Pass()); |
334 blocking_factor.Pass()); | |
335 background_task_token->UpdateTask(from_here, callback); | 334 background_task_token->UpdateTask(from_here, callback); |
336 running_background_tasks_.set(background_task_token->token_id(), | 335 running_background_tasks_.set(background_task_token->token_id(), |
337 running_foreground_task_.Pass()); | 336 running_foreground_task_.Pass()); |
338 } | 337 } |
339 | 338 |
340 token_ = foreground_task_token.Pass(); | 339 token_ = foreground_task_token.Pass(); |
341 MaybeStartNextForegroundTask(scoped_ptr<SyncTaskToken>()); | 340 MaybeStartNextForegroundTask(scoped_ptr<SyncTaskToken>()); |
342 background_task_token->SetTaskLog(task_log.Pass()); | 341 background_task_token->SetTaskLog(task_log.Pass()); |
343 continuation.Run(background_task_token.Pass()); | 342 continuation.Run(background_task_token.Pass()); |
344 } | 343 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 closure.Run(); | 394 closure.Run(); |
396 return; | 395 return; |
397 } | 396 } |
398 | 397 |
399 if (client_) | 398 if (client_) |
400 client_->MaybeScheduleNextTask(); | 399 client_->MaybeScheduleNextTask(); |
401 } | 400 } |
402 | 401 |
403 } // namespace drive_backend | 402 } // namespace drive_backend |
404 } // namespace sync_file_system | 403 } // namespace sync_file_system |
OLD | NEW |