Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Unified Diff: chrome/browser/sessions/base_session_service.cc

Issue 685133004: Handling |SessionCommand|s as scoped_ptr's (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;

Powered by Google App Engine
This is Rietveld 408576698