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 16 matching lines...) Expand all Loading... |
27 std::vector<std::unique_ptr<SessionCommand>> commands) { | 27 std::vector<std::unique_ptr<SessionCommand>> commands) { |
28 if (is_canceled.Run()) | 28 if (is_canceled.Run()) |
29 return; | 29 return; |
30 callback.Run(std::move(commands)); | 30 callback.Run(std::move(commands)); |
31 } | 31 } |
32 | 32 |
33 void PostOrRunInternalGetCommandsCallback( | 33 void PostOrRunInternalGetCommandsCallback( |
34 base::TaskRunner* task_runner, | 34 base::TaskRunner* task_runner, |
35 const BaseSessionService::GetCommandsCallback& callback, | 35 const BaseSessionService::GetCommandsCallback& callback, |
36 std::vector<std::unique_ptr<SessionCommand>> commands) { | 36 std::vector<std::unique_ptr<SessionCommand>> commands) { |
37 if (task_runner->RunsTasksOnCurrentThread()) { | 37 if (task_runner->RunsTasksInCurrentSequence()) { |
38 callback.Run(std::move(commands)); | 38 callback.Run(std::move(commands)); |
39 } else { | 39 } else { |
40 task_runner->PostTask(FROM_HERE, | 40 task_runner->PostTask(FROM_HERE, |
41 base::Bind(callback, base::Passed(&commands))); | 41 base::Bind(callback, base::Passed(&commands))); |
42 } | 42 } |
43 } | 43 } |
44 | 44 |
45 } // namespace | 45 } // namespace |
46 | 46 |
47 // Delay between when a command is received, and when we save it to the | 47 // Delay between when a command is received, and when we save it to the |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 pool->PostSequencedWorkerTask(sequence_token_, from_here, task); | 182 pool->PostSequencedWorkerTask(sequence_token_, from_here, task); |
183 } else { | 183 } else { |
184 // Fall back to executing on the main thread if the sequence | 184 // Fall back to executing on the main thread if the sequence |
185 // worker pool has been requested to shutdown (around shutdown | 185 // worker pool has been requested to shutdown (around shutdown |
186 // time). | 186 // time). |
187 task.Run(); | 187 task.Run(); |
188 } | 188 } |
189 } | 189 } |
190 | 190 |
191 } // namespace sessions | 191 } // namespace sessions |
OLD | NEW |