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

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

Issue 16950028: Move file_util::Delete to the base namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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 unified diff | Download patch | Annotate | Revision Log
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/file_util.h" 9 #include "base/file_util.h"
10 #include "base/memory/scoped_vector.h" 10 #include "base/memory/scoped_vector.h"
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 258
259 bool SessionBackend::ReadLastSessionCommandsImpl( 259 bool SessionBackend::ReadLastSessionCommandsImpl(
260 std::vector<SessionCommand*>* commands) { 260 std::vector<SessionCommand*>* commands) {
261 Init(); 261 Init();
262 SessionFileReader file_reader(GetLastSessionPath()); 262 SessionFileReader file_reader(GetLastSessionPath());
263 return file_reader.Read(type_, commands); 263 return file_reader.Read(type_, commands);
264 } 264 }
265 265
266 void SessionBackend::DeleteLastSession() { 266 void SessionBackend::DeleteLastSession() {
267 Init(); 267 Init();
268 file_util::Delete(GetLastSessionPath(), false); 268 base::Delete(GetLastSessionPath(), false);
269 } 269 }
270 270
271 void SessionBackend::MoveCurrentSessionToLastSession() { 271 void SessionBackend::MoveCurrentSessionToLastSession() {
272 Init(); 272 Init();
273 current_session_file_.reset(NULL); 273 current_session_file_.reset(NULL);
274 274
275 const base::FilePath current_session_path = GetCurrentSessionPath(); 275 const base::FilePath current_session_path = GetCurrentSessionPath();
276 const base::FilePath last_session_path = GetLastSessionPath(); 276 const base::FilePath last_session_path = GetLastSessionPath();
277 if (file_util::PathExists(last_session_path)) 277 if (file_util::PathExists(last_session_path))
278 file_util::Delete(last_session_path, false); 278 base::Delete(last_session_path, false);
279 if (file_util::PathExists(current_session_path)) { 279 if (file_util::PathExists(current_session_path)) {
280 int64 file_size; 280 int64 file_size;
281 if (file_util::GetFileSize(current_session_path, &file_size)) { 281 if (file_util::GetFileSize(current_session_path, &file_size)) {
282 if (type_ == BaseSessionService::TAB_RESTORE) { 282 if (type_ == BaseSessionService::TAB_RESTORE) {
283 UMA_HISTOGRAM_COUNTS("TabRestore.last_session_file_size", 283 UMA_HISTOGRAM_COUNTS("TabRestore.last_session_file_size",
284 static_cast<int>(file_size / 1024)); 284 static_cast<int>(file_size / 1024));
285 } else { 285 } else {
286 UMA_HISTOGRAM_COUNTS("SessionRestore.last_session_file_size", 286 UMA_HISTOGRAM_COUNTS("SessionRestore.last_session_file_size",
287 static_cast<int>(file_size / 1024)); 287 static_cast<int>(file_size / 1024));
288 } 288 }
289 } 289 }
290 last_session_valid_ = file_util::Move(current_session_path, 290 last_session_valid_ = file_util::Move(current_session_path,
291 last_session_path); 291 last_session_path);
292 } 292 }
293 293
294 if (file_util::PathExists(current_session_path)) 294 if (file_util::PathExists(current_session_path))
295 file_util::Delete(current_session_path, false); 295 base::Delete(current_session_path, false);
296 296
297 // Create and open the file for the current session. 297 // Create and open the file for the current session.
298 ResetFile(); 298 ResetFile();
299 } 299 }
300 300
301 bool SessionBackend::ReadCurrentSessionCommandsImpl( 301 bool SessionBackend::ReadCurrentSessionCommandsImpl(
302 std::vector<SessionCommand*>* commands) { 302 std::vector<SessionCommand*>* commands) {
303 Init(); 303 Init();
304 SessionFileReader file_reader(GetCurrentSessionPath()); 304 SessionFileReader file_reader(GetCurrentSessionPath());
305 return file_reader.Read(type_, commands); 305 return file_reader.Read(type_, commands);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 } 399 }
400 400
401 base::FilePath SessionBackend::GetCurrentSessionPath() { 401 base::FilePath SessionBackend::GetCurrentSessionPath() {
402 base::FilePath path = path_to_dir_; 402 base::FilePath path = path_to_dir_;
403 if (type_ == BaseSessionService::TAB_RESTORE) 403 if (type_ == BaseSessionService::TAB_RESTORE)
404 path = path.AppendASCII(kCurrentTabSessionFileName); 404 path = path.AppendASCII(kCurrentTabSessionFileName);
405 else 405 else
406 path = path.AppendASCII(kCurrentSessionFileName); 406 path = path.AppendASCII(kCurrentSessionFileName);
407 return path; 407 return path;
408 } 408 }
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_store_file.cc ('k') | chrome/browser/shell_integration_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698