Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(680)

Side by Side Diff: chrome/browser/sync_file_system/drive_backend/sync_task_manager.h

Issue 881203003: Suppress sequence checks in SyncFileSystem on the shutdown phase (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: +param comment Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_TASK_MANAGER_H_ 5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_TASK_MANAGER_H_
6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_TASK_MANAGER_H_ 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_TASK_MANAGER_H_
7 7
8 #include <queue> 8 #include <queue>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/containers/scoped_ptr_hash_map.h" 12 #include "base/containers/scoped_ptr_hash_map.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/sequence_checker.h" 15 #include "base/sequence_checker.h"
16 #include "base/threading/sequenced_worker_pool.h"
16 #include "chrome/browser/sync_file_system/drive_backend/task_dependency_manager. h" 17 #include "chrome/browser/sync_file_system/drive_backend/task_dependency_manager. h"
17 #include "chrome/browser/sync_file_system/sync_callbacks.h" 18 #include "chrome/browser/sync_file_system/sync_callbacks.h"
18 #include "chrome/browser/sync_file_system/sync_status_code.h" 19 #include "chrome/browser/sync_file_system/sync_status_code.h"
19 #include "chrome/browser/sync_file_system/task_logger.h" 20 #include "chrome/browser/sync_file_system/task_logger.h"
20 21
21 namespace base { 22 namespace base {
22 class SequencedTaskRunner; 23 class SequencedTaskRunner;
23 } 24 }
24 25
25 namespace tracked_objects { 26 namespace tracked_objects {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 SyncStatusCode last_operation_status, 64 SyncStatusCode last_operation_status,
64 bool last_operation_used_network) = 0; 65 bool last_operation_used_network) = 0;
65 66
66 virtual void RecordTaskLog(scoped_ptr<TaskLogger::TaskLog> task_log) = 0; 67 virtual void RecordTaskLog(scoped_ptr<TaskLogger::TaskLog> task_log) = 0;
67 }; 68 };
68 69
69 // Runs at most |maximum_background_tasks| parallel as background tasks. 70 // Runs at most |maximum_background_tasks| parallel as background tasks.
70 // If |maximum_background_tasks| is zero, all task runs as foreground task. 71 // If |maximum_background_tasks| is zero, all task runs as foreground task.
71 SyncTaskManager(base::WeakPtr<Client> client, 72 SyncTaskManager(base::WeakPtr<Client> client,
72 size_t maximum_background_task, 73 size_t maximum_background_task,
73 const scoped_refptr<base::SequencedTaskRunner>& task_runner); 74 const scoped_refptr<base::SequencedTaskRunner>& task_runner,
75 const scoped_refptr<base::SequencedWorkerPool>& worker_pool);
74 virtual ~SyncTaskManager(); 76 virtual ~SyncTaskManager();
75 77
76 // This needs to be called to start task scheduling. 78 // This needs to be called to start task scheduling.
77 // If |status| is not SYNC_STATUS_OK calling this may change the 79 // If |status| is not SYNC_STATUS_OK calling this may change the
78 // service status. This should not be called more than once. 80 // service status. This should not be called more than once.
79 void Initialize(SyncStatusCode status); 81 void Initialize(SyncStatusCode status);
80 82
81 // Schedules a task at the given priority. 83 // Schedules a task at the given priority.
82 void ScheduleTask(const tracked_objects::Location& from_here, 84 void ScheduleTask(const tracked_objects::Location& from_here,
83 const Task& task, 85 const Task& task,
(...skipping 29 matching lines...) Expand all
113 // Note that this function once releases previous |task_blocker| before 115 // Note that this function once releases previous |task_blocker| before
114 // applying new |task_blocker|. So, any other task may be run before 116 // applying new |task_blocker|. So, any other task may be run before
115 // invocation of |continuation|. 117 // invocation of |continuation|.
116 static void UpdateTaskBlocker(scoped_ptr<SyncTaskToken> current_task_token, 118 static void UpdateTaskBlocker(scoped_ptr<SyncTaskToken> current_task_token,
117 scoped_ptr<TaskBlocker> task_blocker, 119 scoped_ptr<TaskBlocker> task_blocker,
118 const Continuation& continuation); 120 const Continuation& continuation);
119 121
120 bool IsRunningTask(int64 task_token_id) const; 122 bool IsRunningTask(int64 task_token_id) const;
121 123
122 void DetachFromSequence(); 124 void DetachFromSequence();
125 bool ShouldTrackTaskToken() const;
123 126
124 private: 127 private:
125 struct PendingTask { 128 struct PendingTask {
126 base::Closure task; 129 base::Closure task;
127 Priority priority; 130 Priority priority;
128 int64 seq; 131 int64 seq;
129 132
130 PendingTask(); 133 PendingTask();
131 PendingTask(const base::Closure& task, Priority pri, int seq); 134 PendingTask(const base::Closure& task, Priority pri, int seq);
132 ~PendingTask(); 135 ~PendingTask();
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 // Absence of |token_| implies a task is running. Incoming tasks should 191 // Absence of |token_| implies a task is running. Incoming tasks should
189 // wait for the task to finish in |pending_tasks_| if |token_| is null. 192 // wait for the task to finish in |pending_tasks_| if |token_| is null.
190 // Each task must take TaskToken instance from |token_| and must hold it 193 // Each task must take TaskToken instance from |token_| and must hold it
191 // until it finished. And the task must return the instance through 194 // until it finished. And the task must return the instance through
192 // NotifyTaskDone when the task finished. 195 // NotifyTaskDone when the task finished.
193 scoped_ptr<SyncTaskToken> token_; 196 scoped_ptr<SyncTaskToken> token_;
194 197
195 TaskDependencyManager dependency_manager_; 198 TaskDependencyManager dependency_manager_;
196 199
197 scoped_refptr<base::SequencedTaskRunner> task_runner_; 200 scoped_refptr<base::SequencedTaskRunner> task_runner_;
201 scoped_refptr<base::SequencedWorkerPool> worker_pool_;
198 base::SequenceChecker sequence_checker_; 202 base::SequenceChecker sequence_checker_;
199 203
200 base::WeakPtrFactory<SyncTaskManager> weak_ptr_factory_;; 204 base::WeakPtrFactory<SyncTaskManager> weak_ptr_factory_;;
201 205
202 DISALLOW_COPY_AND_ASSIGN(SyncTaskManager); 206 DISALLOW_COPY_AND_ASSIGN(SyncTaskManager);
203 }; 207 };
204 208
205 } // namespace drive_backend 209 } // namespace drive_backend
206 } // namespace sync_file_system 210 } // namespace sync_file_system
207 211
208 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_TASK_MANAGER_H_ 212 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_TASK_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698