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

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

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 #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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 const PendingTask& left, 48 const PendingTask& left,
49 const PendingTask& right) const { 49 const PendingTask& right) const {
50 if (left.priority != right.priority) 50 if (left.priority != right.priority)
51 return left.priority < right.priority; 51 return left.priority < right.priority;
52 return left.seq > right.seq; 52 return left.seq > right.seq;
53 } 53 }
54 54
55 SyncTaskManager::SyncTaskManager( 55 SyncTaskManager::SyncTaskManager(
56 base::WeakPtr<Client> client, 56 base::WeakPtr<Client> client,
57 size_t maximum_background_task, 57 size_t maximum_background_task,
58 const scoped_refptr<base::SequencedTaskRunner>& task_runner) 58 const scoped_refptr<base::SequencedTaskRunner>& task_runner,
59 const scoped_refptr<base::SequencedWorkerPool>& worker_pool)
59 : client_(client), 60 : client_(client),
60 maximum_background_task_(maximum_background_task), 61 maximum_background_task_(maximum_background_task),
61 pending_task_seq_(0), 62 pending_task_seq_(0),
62 task_token_seq_(SyncTaskToken::kMinimumBackgroundTaskTokenID), 63 task_token_seq_(SyncTaskToken::kMinimumBackgroundTaskTokenID),
63 task_runner_(task_runner), 64 task_runner_(task_runner),
65 worker_pool_(worker_pool),
64 weak_ptr_factory_(this) { 66 weak_ptr_factory_(this) {
65 } 67 }
66 68
67 SyncTaskManager::~SyncTaskManager() { 69 SyncTaskManager::~SyncTaskManager() {
68 weak_ptr_factory_.InvalidateWeakPtrs(); 70 weak_ptr_factory_.InvalidateWeakPtrs();
69 71
70 client_.reset(); 72 client_.reset();
71 token_.reset(); 73 token_.reset();
72 } 74 }
73 75
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 if (token_id == SyncTaskToken::kForegroundTaskTokenID) 199 if (token_id == SyncTaskToken::kForegroundTaskTokenID)
198 return true; 200 return true;
199 201
200 return ContainsKey(running_background_tasks_, token_id); 202 return ContainsKey(running_background_tasks_, token_id);
201 } 203 }
202 204
203 void SyncTaskManager::DetachFromSequence() { 205 void SyncTaskManager::DetachFromSequence() {
204 sequence_checker_.DetachFromSequence(); 206 sequence_checker_.DetachFromSequence();
205 } 207 }
206 208
209 bool SyncTaskManager::ShouldTrackTaskToken() const {
210 return !worker_pool_ || !worker_pool_->IsShutdownInProgress();
211 }
212
207 void SyncTaskManager::NotifyTaskDoneBody(scoped_ptr<SyncTaskToken> token, 213 void SyncTaskManager::NotifyTaskDoneBody(scoped_ptr<SyncTaskToken> token,
208 SyncStatusCode status) { 214 SyncStatusCode status) {
209 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); 215 DCHECK(sequence_checker_.CalledOnValidSequencedThread());
210 DCHECK(token); 216 DCHECK(token);
211 217
212 DVLOG(3) << "NotifyTaskDone: " << "finished with status=" << status 218 DVLOG(3) << "NotifyTaskDone: " << "finished with status=" << status
213 << " (" << SyncStatusCodeToString(status) << ")" 219 << " (" << SyncStatusCodeToString(status) << ")"
214 << " " << token->location().ToString(); 220 << " " << token->location().ToString();
215 221
216 if (token->task_blocker()) { 222 if (token->task_blocker()) {
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 closure.Run(); 405 closure.Run();
400 return; 406 return;
401 } 407 }
402 408
403 if (client_) 409 if (client_)
404 client_->MaybeScheduleNextTask(); 410 client_->MaybeScheduleNextTask();
405 } 411 }
406 412
407 } // namespace drive_backend 413 } // namespace drive_backend
408 } // namespace sync_file_system 414 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698