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 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNC_TASK_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNC_TASK_MANAGER_H_ |
6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNC_TASK_MANAGER_H_ | 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNC_TASK_MANAGER_H_ |
7 | 7 |
8 #include <queue> | 8 #include <queue> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 | 50 |
51 explicit SyncTaskManager(base::WeakPtr<Client> client); | 51 explicit SyncTaskManager(base::WeakPtr<Client> client); |
52 virtual ~SyncTaskManager(); | 52 virtual ~SyncTaskManager(); |
53 | 53 |
54 // This needs to be called to start task scheduling. | 54 // This needs to be called to start task scheduling. |
55 // If |status| is not SYNC_STATUS_OK calling this may change the | 55 // If |status| is not SYNC_STATUS_OK calling this may change the |
56 // service status. This should not be called more than once. | 56 // service status. This should not be called more than once. |
57 void Initialize(SyncStatusCode status); | 57 void Initialize(SyncStatusCode status); |
58 | 58 |
59 // Schedules a task at PRIORITY_MED. | 59 // Schedules a task at PRIORITY_MED. |
60 void ScheduleTask(const Task& task, | 60 void ScheduleTask(const tracked_objects::Location& from_here, |
| 61 const Task& task, |
61 const SyncStatusCallback& callback); | 62 const SyncStatusCallback& callback); |
62 void ScheduleSyncTask(scoped_ptr<SyncTask> task, | 63 void ScheduleSyncTask(const tracked_objects::Location& from_here, |
| 64 scoped_ptr<SyncTask> task, |
63 const SyncStatusCallback& callback); | 65 const SyncStatusCallback& callback); |
64 | 66 |
65 // Schedules a task at the given priority. | 67 // Schedules a task at the given priority. |
66 void ScheduleTaskAtPriority(const Task& task, | 68 void ScheduleTaskAtPriority(const tracked_objects::Location& from_here, |
| 69 const Task& task, |
67 Priority priority, | 70 Priority priority, |
68 const SyncStatusCallback& callback); | 71 const SyncStatusCallback& callback); |
69 void ScheduleSyncTaskAtPriority(scoped_ptr<SyncTask> task, | 72 void ScheduleSyncTaskAtPriority(const tracked_objects::Location& from_here, |
| 73 scoped_ptr<SyncTask> task, |
70 Priority priority, | 74 Priority priority, |
71 const SyncStatusCallback& callback); | 75 const SyncStatusCallback& callback); |
72 | 76 |
73 // Runs the posted task only when we're idle. Returns true if tha task is | 77 // Runs the posted task only when we're idle. Returns true if tha task is |
74 // scheduled. | 78 // scheduled. |
75 bool ScheduleTaskIfIdle(const Task& task, const SyncStatusCallback& callback); | 79 bool ScheduleTaskIfIdle(const tracked_objects::Location& from_here, |
76 bool ScheduleSyncTaskIfIdle(scoped_ptr<SyncTask> task, | 80 const Task& task, |
| 81 const SyncStatusCallback& callback); |
| 82 bool ScheduleSyncTaskIfIdle(const tracked_objects::Location& from_here, |
| 83 scoped_ptr<SyncTask> task, |
77 const SyncStatusCallback& callback); | 84 const SyncStatusCallback& callback); |
78 | 85 |
79 void NotifyTaskDone(scoped_ptr<TaskToken> token, | 86 void NotifyTaskDone(scoped_ptr<TaskToken> token, |
80 SyncStatusCode status); | 87 SyncStatusCode status); |
81 | 88 |
82 private: | 89 private: |
83 struct PendingTask { | 90 struct PendingTask { |
84 base::Closure task; | 91 base::Closure task; |
85 Priority priority; | 92 Priority priority; |
86 int64 seq; | 93 int64 seq; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 // until it finished. And the task must return the instance through | 129 // until it finished. And the task must return the instance through |
123 // NotifyTaskDone when the task finished. | 130 // NotifyTaskDone when the task finished. |
124 scoped_ptr<TaskToken> token_; | 131 scoped_ptr<TaskToken> token_; |
125 | 132 |
126 DISALLOW_COPY_AND_ASSIGN(SyncTaskManager); | 133 DISALLOW_COPY_AND_ASSIGN(SyncTaskManager); |
127 }; | 134 }; |
128 | 135 |
129 } // namespace sync_file_system | 136 } // namespace sync_file_system |
130 | 137 |
131 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNC_TASK_MANAGER_H_ | 138 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNC_TASK_MANAGER_H_ |
OLD | NEW |