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

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

Issue 685133004: Handling |SessionCommand|s as scoped_ptr's (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed 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
« no previous file with comments | « chrome/browser/sessions/session_backend.h ('k') | chrome/browser/sessions/session_backend_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sessions/session_backend.cc
diff --git a/chrome/browser/sessions/session_backend.cc b/chrome/browser/sessions/session_backend.cc
index c62adf4e8855e2bbc89010e953fa44e99a515f7d..825b8114d4a966f5ec17c1be118f2fa0c6d08f8f 100644
--- a/chrome/browser/sessions/session_backend.cc
+++ b/chrome/browser/sessions/session_backend.cc
@@ -52,7 +52,7 @@ class SessionFileReader {
// true on success. It is up to the caller to free all SessionCommands
// added to commands.
bool Read(BaseSessionService::SessionType type,
- std::vector<SessionCommand*>* commands);
+ ScopedVector<SessionCommand>* commands);
private:
// Reads a single command, returning it. A return value of NULL indicates
@@ -86,7 +86,7 @@ class SessionFileReader {
};
bool SessionFileReader::Read(BaseSessionService::SessionType type,
- std::vector<SessionCommand*>* commands) {
+ ScopedVector<SessionCommand>* commands) {
if (!file_->IsValid())
return false;
FileHeader header;
@@ -221,7 +221,7 @@ void SessionBackend::Init() {
}
void SessionBackend::AppendCommands(
- std::vector<SessionCommand*>* commands,
+ ScopedVector<SessionCommand>* commands,
bool reset_first) {
Init();
// Make sure and check current_session_file_, if opening the file failed
@@ -236,7 +236,7 @@ void SessionBackend::AppendCommands(
current_session_file_.reset(NULL);
}
empty_file_ = false;
- STLDeleteElements(commands);
+ // Deleting the ScopedVector will also delete its elements.
delete commands;
}
@@ -249,12 +249,12 @@ void SessionBackend::ReadLastSessionCommands(
Init();
ScopedVector<SessionCommand> commands;
- ReadLastSessionCommandsImpl(&(commands.get()));
+ ReadLastSessionCommandsImpl(&commands);
callback.Run(commands.Pass());
}
bool SessionBackend::ReadLastSessionCommandsImpl(
- std::vector<SessionCommand*>* commands) {
+ ScopedVector<SessionCommand>* commands) {
Init();
SessionFileReader file_reader(GetLastSessionPath());
return file_reader.Read(type_, commands);
@@ -295,15 +295,15 @@ void SessionBackend::MoveCurrentSessionToLastSession() {
}
bool SessionBackend::ReadCurrentSessionCommandsImpl(
- std::vector<SessionCommand*>* commands) {
+ ScopedVector<SessionCommand>* commands) {
Init();
SessionFileReader file_reader(GetCurrentSessionPath());
return file_reader.Read(type_, commands);
}
bool SessionBackend::AppendCommandsToFile(base::File* file,
- const std::vector<SessionCommand*>& commands) {
- for (std::vector<SessionCommand*>::const_iterator i = commands.begin();
+ const ScopedVector<SessionCommand>& commands) {
+ for (ScopedVector<SessionCommand>::const_iterator i = commands.begin();
i != commands.end(); ++i) {
int wrote;
const size_type content_size = static_cast<size_type>((*i)->size());
« no previous file with comments | « chrome/browser/sessions/session_backend.h ('k') | chrome/browser/sessions/session_backend_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698