| 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_task_manager.h" | 5 #include "chrome/browser/sync_file_system/sync_task_manager.h" |
| 6 | 6 |
| 7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "chrome/browser/sync_file_system/sync_file_metadata.h" | 9 #include "chrome/browser/sync_file_system/sync_file_metadata.h" |
| 10 | 10 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 | 79 |
| 80 void SyncTaskManager::Initialize(SyncStatusCode status) { | 80 void SyncTaskManager::Initialize(SyncStatusCode status) { |
| 81 DCHECK(!token_); | 81 DCHECK(!token_); |
| 82 NotifyTaskDone(make_scoped_ptr(new TaskToken(AsWeakPtr())), | 82 NotifyTaskDone(make_scoped_ptr(new TaskToken(AsWeakPtr())), |
| 83 status); | 83 status); |
| 84 } | 84 } |
| 85 | 85 |
| 86 void SyncTaskManager::ScheduleTask( | 86 void SyncTaskManager::ScheduleTask( |
| 87 const tracked_objects::Location& from_here, | 87 const tracked_objects::Location& from_here, |
| 88 const Task& task, | 88 const Task& task, |
| 89 const SyncStatusCallback& callback) { | |
| 90 ScheduleTaskAtPriority(from_here, task, PRIORITY_MED, callback); | |
| 91 } | |
| 92 | |
| 93 void SyncTaskManager::ScheduleSyncTask( | |
| 94 const tracked_objects::Location& from_here, | |
| 95 scoped_ptr<SyncTask> task, | |
| 96 const SyncStatusCallback& callback) { | |
| 97 ScheduleSyncTaskAtPriority(from_here, task.Pass(), PRIORITY_MED, callback); | |
| 98 } | |
| 99 | |
| 100 void SyncTaskManager::ScheduleTaskAtPriority( | |
| 101 const tracked_objects::Location& from_here, | |
| 102 const Task& task, | |
| 103 Priority priority, | 89 Priority priority, |
| 104 const SyncStatusCallback& callback) { | 90 const SyncStatusCallback& callback) { |
| 105 scoped_ptr<TaskToken> token(GetToken(from_here)); | 91 scoped_ptr<TaskToken> token(GetToken(from_here)); |
| 106 if (!token) { | 92 if (!token) { |
| 107 PushPendingTask( | 93 PushPendingTask( |
| 108 base::Bind(&SyncTaskManager::ScheduleTask, AsWeakPtr(), from_here, | 94 base::Bind(&SyncTaskManager::ScheduleTask, AsWeakPtr(), from_here, |
| 109 task, callback), | 95 task, priority, callback), |
| 110 priority); | 96 priority); |
| 111 return; | 97 return; |
| 112 } | 98 } |
| 113 task.Run(CreateCompletionCallback(token.Pass(), callback)); | 99 task.Run(CreateCompletionCallback(token.Pass(), callback)); |
| 114 } | 100 } |
| 115 | 101 |
| 116 void SyncTaskManager::ScheduleSyncTaskAtPriority( | 102 void SyncTaskManager::ScheduleSyncTask( |
| 117 const tracked_objects::Location& from_here, | 103 const tracked_objects::Location& from_here, |
| 118 scoped_ptr<SyncTask> task, | 104 scoped_ptr<SyncTask> task, |
| 119 Priority priority, | 105 Priority priority, |
| 120 const SyncStatusCallback& callback) { | 106 const SyncStatusCallback& callback) { |
| 121 scoped_ptr<TaskToken> token(GetToken(from_here)); | 107 scoped_ptr<TaskToken> token(GetToken(from_here)); |
| 122 if (!token) { | 108 if (!token) { |
| 123 PushPendingTask( | 109 PushPendingTask( |
| 124 base::Bind(&SyncTaskManager::ScheduleSyncTask, AsWeakPtr(), from_here, | 110 base::Bind(&SyncTaskManager::ScheduleSyncTask, AsWeakPtr(), from_here, |
| 125 base::Passed(&task), callback), | 111 base::Passed(&task), priority, callback), |
| 126 priority); | 112 priority); |
| 127 return; | 113 return; |
| 128 } | 114 } |
| 129 DCHECK(!running_task_); | 115 DCHECK(!running_task_); |
| 130 running_task_ = task.Pass(); | 116 running_task_ = task.Pass(); |
| 131 running_task_->Run(CreateCompletionCallback(token.Pass(), callback)); | 117 running_task_->Run(CreateCompletionCallback(token.Pass(), callback)); |
| 132 } | 118 } |
| 133 | 119 |
| 134 bool SyncTaskManager::ScheduleTaskIfIdle( | 120 bool SyncTaskManager::ScheduleTaskIfIdle( |
| 135 const tracked_objects::Location& from_here, | 121 const tracked_objects::Location& from_here, |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 return base::Bind(&SyncTaskManager::NotifyTaskDone, | 199 return base::Bind(&SyncTaskManager::NotifyTaskDone, |
| 214 AsWeakPtr(), base::Passed(&token)); | 200 AsWeakPtr(), base::Passed(&token)); |
| 215 } | 201 } |
| 216 | 202 |
| 217 void SyncTaskManager::PushPendingTask( | 203 void SyncTaskManager::PushPendingTask( |
| 218 const base::Closure& closure, Priority priority) { | 204 const base::Closure& closure, Priority priority) { |
| 219 pending_tasks_.push(PendingTask(closure, priority, pending_task_seq_++)); | 205 pending_tasks_.push(PendingTask(closure, priority, pending_task_seq_++)); |
| 220 } | 206 } |
| 221 | 207 |
| 222 } // namespace sync_file_system | 208 } // namespace sync_file_system |
| OLD | NEW |