| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "components/sessions/core/base_session_service.h" | 5 #include "components/sessions/core/base_session_service.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 base::CancelableTaskTracker* tracker) { | 154 base::CancelableTaskTracker* tracker) { |
| 155 base::CancelableTaskTracker::IsCanceledCallback is_canceled; | 155 base::CancelableTaskTracker::IsCanceledCallback is_canceled; |
| 156 base::CancelableTaskTracker::TaskId id = | 156 base::CancelableTaskTracker::TaskId id = |
| 157 tracker->NewTrackedTaskId(&is_canceled); | 157 tracker->NewTrackedTaskId(&is_canceled); |
| 158 | 158 |
| 159 GetCommandsCallback run_if_not_canceled = | 159 GetCommandsCallback run_if_not_canceled = |
| 160 base::Bind(&RunIfNotCanceled, is_canceled, callback); | 160 base::Bind(&RunIfNotCanceled, is_canceled, callback); |
| 161 | 161 |
| 162 GetCommandsCallback callback_runner = | 162 GetCommandsCallback callback_runner = |
| 163 base::Bind(&PostOrRunInternalGetCommandsCallback, | 163 base::Bind(&PostOrRunInternalGetCommandsCallback, |
| 164 base::ThreadTaskRunnerHandle::Get(), run_if_not_canceled); | 164 base::RetainedRef(base::ThreadTaskRunnerHandle::Get()), |
| 165 run_if_not_canceled); |
| 165 | 166 |
| 166 RunTaskOnBackendThread( | 167 RunTaskOnBackendThread( |
| 167 FROM_HERE, | 168 FROM_HERE, |
| 168 base::Bind(&SessionBackend::ReadLastSessionCommands, backend_, | 169 base::Bind(&SessionBackend::ReadLastSessionCommands, backend_, |
| 169 is_canceled, callback_runner)); | 170 is_canceled, callback_runner)); |
| 170 return id; | 171 return id; |
| 171 } | 172 } |
| 172 | 173 |
| 173 void BaseSessionService::RunTaskOnBackendThread( | 174 void BaseSessionService::RunTaskOnBackendThread( |
| 174 const tracked_objects::Location& from_here, | 175 const tracked_objects::Location& from_here, |
| 175 const base::Closure& task) { | 176 const base::Closure& task) { |
| 176 base::SequencedWorkerPool* pool = delegate_->GetBlockingPool(); | 177 base::SequencedWorkerPool* pool = delegate_->GetBlockingPool(); |
| 177 if (!pool->IsShutdownInProgress()) { | 178 if (!pool->IsShutdownInProgress()) { |
| 178 pool->PostSequencedWorkerTask(sequence_token_, from_here, task); | 179 pool->PostSequencedWorkerTask(sequence_token_, from_here, task); |
| 179 } else { | 180 } else { |
| 180 // Fall back to executing on the main thread if the sequence | 181 // Fall back to executing on the main thread if the sequence |
| 181 // worker pool has been requested to shutdown (around shutdown | 182 // worker pool has been requested to shutdown (around shutdown |
| 182 // time). | 183 // time). |
| 183 task.Run(); | 184 task.Run(); |
| 184 } | 185 } |
| 185 } | 186 } |
| 186 | 187 |
| 187 } // namespace sessions | 188 } // namespace sessions |
| OLD | NEW |