Chromium Code Reviews| Index: chrome/browser/sessions/base_session_service.cc |
| diff --git a/chrome/browser/sessions/base_session_service.cc b/chrome/browser/sessions/base_session_service.cc |
| index 05d61bf7213b1a55a42df2c457d4335db8df9d81..7af894985cbb7ce4b49116c94cc204111ce35a61 100644 |
| --- a/chrome/browser/sessions/base_session_service.cc |
| +++ b/chrome/browser/sessions/base_session_service.cc |
| @@ -67,10 +67,10 @@ void BaseSessionService::DeleteLastSession() { |
| base::Bind(&SessionBackend::DeleteLastSession, backend())); |
| } |
| -void BaseSessionService::ScheduleCommand(SessionCommand* command) { |
| +void BaseSessionService::ScheduleCommand(scoped_ptr<SessionCommand> command) { |
| DCHECK(command); |
| commands_since_reset_++; |
| - pending_commands_.push_back(command); |
| + pending_commands_.push_back(command.release()); |
| StartSaveTimer(); |
| } |
| @@ -91,15 +91,17 @@ void BaseSessionService::Save() { |
| if (pending_commands_.empty()) |
| return; |
| + // We create a new ScopedVector which will receive all elements from the |
| + // current commands. This will also clear the current list. |
| + ScopedVector<SessionCommand>* passed = new ScopedVector<SessionCommand>(); |
|
sky
2014/10/30 22:51:07
ScopedVector supports move semantics. Can't you su
Mr4D (OOO till 08-26)
2014/10/30 23:31:21
Aha. ScopedVector.passed() works. Interesting. Don
|
| + passed->swap(pending_commands_); |
| + DCHECK(pending_commands_.empty()); |
| RunTaskOnBackendThread( |
| FROM_HERE, |
| base::Bind(&SessionBackend::AppendCommands, backend(), |
| - new std::vector<SessionCommand*>(pending_commands_), |
| + passed, |
| pending_reset_)); |
| - // Backend took ownership of commands. |
| - pending_commands_.clear(); |
| - |
| if (pending_reset_) { |
| commands_since_reset_ = 0; |
| pending_reset_ = false; |