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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 FROM_HERE, base::Bind(&SessionBackend::MoveCurrentSessionToLastSession, | 69 FROM_HERE, base::Bind(&SessionBackend::MoveCurrentSessionToLastSession, |
70 backend_)); | 70 backend_)); |
71 } | 71 } |
72 | 72 |
73 void BaseSessionService::DeleteLastSession() { | 73 void BaseSessionService::DeleteLastSession() { |
74 RunTaskOnBackendThread( | 74 RunTaskOnBackendThread( |
75 FROM_HERE, | 75 FROM_HERE, |
76 base::Bind(&SessionBackend::DeleteLastSession, backend_)); | 76 base::Bind(&SessionBackend::DeleteLastSession, backend_)); |
77 } | 77 } |
78 | 78 |
79 void BaseSessionService::ScheduleCommand(scoped_ptr<SessionCommand> command) { | 79 void BaseSessionService::ScheduleCommand( |
| 80 std::unique_ptr<SessionCommand> command) { |
80 DCHECK(command); | 81 DCHECK(command); |
81 commands_since_reset_++; | 82 commands_since_reset_++; |
82 pending_commands_.push_back(command.release()); | 83 pending_commands_.push_back(command.release()); |
83 StartSaveTimer(); | 84 StartSaveTimer(); |
84 } | 85 } |
85 | 86 |
86 void BaseSessionService::AppendRebuildCommand( | 87 void BaseSessionService::AppendRebuildCommand( |
87 scoped_ptr<SessionCommand> command) { | 88 std::unique_ptr<SessionCommand> command) { |
88 DCHECK(command); | 89 DCHECK(command); |
89 pending_commands_.push_back(command.release()); | 90 pending_commands_.push_back(command.release()); |
90 } | 91 } |
91 | 92 |
92 void BaseSessionService::EraseCommand(SessionCommand* old_command) { | 93 void BaseSessionService::EraseCommand(SessionCommand* old_command) { |
93 ScopedVector<SessionCommand>::iterator it = | 94 ScopedVector<SessionCommand>::iterator it = |
94 std::find(pending_commands_.begin(), | 95 std::find(pending_commands_.begin(), |
95 pending_commands_.end(), | 96 pending_commands_.end(), |
96 old_command); | 97 old_command); |
97 CHECK(it != pending_commands_.end()); | 98 CHECK(it != pending_commands_.end()); |
98 pending_commands_.erase(it); | 99 pending_commands_.erase(it); |
99 } | 100 } |
100 | 101 |
101 void BaseSessionService::SwapCommand(SessionCommand* old_command, | 102 void BaseSessionService::SwapCommand( |
102 scoped_ptr<SessionCommand> new_command) { | 103 SessionCommand* old_command, |
| 104 std::unique_ptr<SessionCommand> new_command) { |
103 ScopedVector<SessionCommand>::iterator it = | 105 ScopedVector<SessionCommand>::iterator it = |
104 std::find(pending_commands_.begin(), | 106 std::find(pending_commands_.begin(), |
105 pending_commands_.end(), | 107 pending_commands_.end(), |
106 old_command); | 108 old_command); |
107 CHECK(it != pending_commands_.end()); | 109 CHECK(it != pending_commands_.end()); |
108 *it = new_command.release(); | 110 *it = new_command.release(); |
109 delete old_command; | 111 delete old_command; |
110 } | 112 } |
111 | 113 |
112 void BaseSessionService::ClearPendingCommands() { | 114 void BaseSessionService::ClearPendingCommands() { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 pool->PostSequencedWorkerTask(sequence_token_, from_here, task); | 181 pool->PostSequencedWorkerTask(sequence_token_, from_here, task); |
180 } else { | 182 } else { |
181 // Fall back to executing on the main thread if the sequence | 183 // Fall back to executing on the main thread if the sequence |
182 // worker pool has been requested to shutdown (around shutdown | 184 // worker pool has been requested to shutdown (around shutdown |
183 // time). | 185 // time). |
184 task.Run(); | 186 task.Run(); |
185 } | 187 } |
186 } | 188 } |
187 | 189 |
188 } // namespace sessions | 190 } // namespace sessions |
OLD | NEW |