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

Side by Side Diff: chrome/browser/sessions/session_backend.cc

Issue 689143002: Minor tweak to Session* to use base::Passed so ownership is clearer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update test Created 6 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "chrome/browser/sessions/session_backend.h" 5 #include "chrome/browser/sessions/session_backend.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/files/file.h" 9 #include "base/files/file.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 214
215 inited_ = true; 215 inited_ = true;
216 216
217 // Create the directory for session info. 217 // Create the directory for session info.
218 base::CreateDirectory(path_to_dir_); 218 base::CreateDirectory(path_to_dir_);
219 219
220 MoveCurrentSessionToLastSession(); 220 MoveCurrentSessionToLastSession();
221 } 221 }
222 222
223 void SessionBackend::AppendCommands( 223 void SessionBackend::AppendCommands(
224 ScopedVector<SessionCommand>* commands, 224 ScopedVector<SessionCommand> commands,
225 bool reset_first) { 225 bool reset_first) {
226 Init(); 226 Init();
227 // Make sure and check current_session_file_, if opening the file failed 227 // Make sure and check current_session_file_, if opening the file failed
228 // current_session_file_ will be NULL. 228 // current_session_file_ will be NULL.
229 if ((reset_first && !empty_file_) || !current_session_file_.get() || 229 if ((reset_first && !empty_file_) || !current_session_file_.get() ||
230 !current_session_file_->IsValid()) { 230 !current_session_file_->IsValid()) {
231 ResetFile(); 231 ResetFile();
232 } 232 }
233 // Need to check current_session_file_ again, ResetFile may fail. 233 // Need to check current_session_file_ again, ResetFile may fail.
234 if (current_session_file_.get() && current_session_file_->IsValid() && 234 if (current_session_file_.get() && current_session_file_->IsValid() &&
235 !AppendCommandsToFile(current_session_file_.get(), *commands)) { 235 !AppendCommandsToFile(current_session_file_.get(), commands)) {
236 current_session_file_.reset(NULL); 236 current_session_file_.reset(NULL);
237 } 237 }
238 empty_file_ = false; 238 empty_file_ = false;
239 // Deleting the ScopedVector will also delete its elements.
240 delete commands;
241 } 239 }
242 240
243 void SessionBackend::ReadLastSessionCommands( 241 void SessionBackend::ReadLastSessionCommands(
244 const base::CancelableTaskTracker::IsCanceledCallback& is_canceled, 242 const base::CancelableTaskTracker::IsCanceledCallback& is_canceled,
245 const BaseSessionService::InternalGetCommandsCallback& callback) { 243 const BaseSessionService::InternalGetCommandsCallback& callback) {
246 if (is_canceled.Run()) 244 if (is_canceled.Run())
247 return; 245 return;
248 246
249 Init(); 247 Init();
250 248
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 } 393 }
396 394
397 base::FilePath SessionBackend::GetCurrentSessionPath() { 395 base::FilePath SessionBackend::GetCurrentSessionPath() {
398 base::FilePath path = path_to_dir_; 396 base::FilePath path = path_to_dir_;
399 if (type_ == BaseSessionService::TAB_RESTORE) 397 if (type_ == BaseSessionService::TAB_RESTORE)
400 path = path.AppendASCII(kCurrentTabSessionFileName); 398 path = path.AppendASCII(kCurrentTabSessionFileName);
401 else 399 else
402 path = path.AppendASCII(kCurrentSessionFileName); 400 path = path.AppendASCII(kCurrentSessionFileName);
403 return path; 401 return path;
404 } 402 }
OLDNEW
« 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