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_token.h" | 5 #include "chrome/browser/sync_file_system/drive_backend/sync_task_token.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 callback_ = callback; | 58 callback_ = callback; |
59 DVLOG(2) << "Token updated: " << location_.ToString(); | 59 DVLOG(2) << "Token updated: " << location_.ToString(); |
60 } | 60 } |
61 | 61 |
62 SyncTaskToken::~SyncTaskToken() { | 62 SyncTaskToken::~SyncTaskToken() { |
63 // All task on Client must hold TaskToken instance to ensure | 63 // All task on Client must hold TaskToken instance to ensure |
64 // no other tasks are running. Also, as soon as a task finishes to work, | 64 // no other tasks are running. Also, as soon as a task finishes to work, |
65 // it must return the token to TaskManager. | 65 // it must return the token to TaskManager. |
66 // Destroying a token with valid |client| indicates the token was | 66 // Destroying a token with valid |client| indicates the token was |
67 // dropped by a task without returning. | 67 // dropped by a task without returning. |
68 if (task_runner_.get() && task_runner_->RunsTasksOnCurrentThread() && | 68 if (task_runner_.get() && task_runner_->RunsTasksInCurrentSequence() && |
69 manager_ && manager_->IsRunningTask(token_id_)) { | 69 manager_ && manager_->IsRunningTask(token_id_)) { |
70 if (!manager_->ShouldTrackTaskToken()) | 70 if (!manager_->ShouldTrackTaskToken()) |
71 return; | 71 return; |
72 | 72 |
73 NOTREACHED() | 73 NOTREACHED() |
74 << "Unexpected TaskToken deletion from: " << location_.ToString(); | 74 << "Unexpected TaskToken deletion from: " << location_.ToString(); |
75 | 75 |
76 // Reinitializes the token. | 76 // Reinitializes the token. |
77 SyncTaskManager::NotifyTaskDone( | 77 SyncTaskManager::NotifyTaskDone( |
78 base::WrapUnique(new SyncTaskToken(manager_, task_runner_.get(), | 78 base::WrapUnique(new SyncTaskToken(manager_, task_runner_.get(), |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 std::unique_ptr<TaskBlocker> task_blocker, | 143 std::unique_ptr<TaskBlocker> task_blocker, |
144 const SyncStatusCallback& callback) | 144 const SyncStatusCallback& callback) |
145 : manager_(manager), | 145 : manager_(manager), |
146 task_runner_(task_runner), | 146 task_runner_(task_runner), |
147 token_id_(token_id), | 147 token_id_(token_id), |
148 callback_(callback), | 148 callback_(callback), |
149 task_blocker_(std::move(task_blocker)) {} | 149 task_blocker_(std::move(task_blocker)) {} |
150 | 150 |
151 } // namespace drive_backend | 151 } // namespace drive_backend |
152 } // namespace sync_file_system | 152 } // namespace sync_file_system |
OLD | NEW |