| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 } | 334 } |
| 335 if (content_size > 0) { | 335 if (content_size > 0) { |
| 336 wrote = file->Write(reinterpret_cast<char*>((*i)->contents()), | 336 wrote = file->Write(reinterpret_cast<char*>((*i)->contents()), |
| 337 content_size, NULL); | 337 content_size, NULL); |
| 338 if (wrote != content_size) { | 338 if (wrote != content_size) { |
| 339 NOTREACHED() << "error writing"; | 339 NOTREACHED() << "error writing"; |
| 340 return false; | 340 return false; |
| 341 } | 341 } |
| 342 } | 342 } |
| 343 } | 343 } |
| 344 file->Flush(); |
| 344 return true; | 345 return true; |
| 345 } | 346 } |
| 346 | 347 |
| 347 SessionBackend::~SessionBackend() { | 348 SessionBackend::~SessionBackend() { |
| 348 } | 349 } |
| 349 | 350 |
| 350 void SessionBackend::ResetFile() { | 351 void SessionBackend::ResetFile() { |
| 351 DCHECK(inited_); | 352 DCHECK(inited_); |
| 352 if (current_session_file_.get()) { | 353 if (current_session_file_.get()) { |
| 353 // File is already open, truncate it. We truncate instead of closing and | 354 // File is already open, truncate it. We truncate instead of closing and |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 } | 391 } |
| 391 | 392 |
| 392 FilePath SessionBackend::GetCurrentSessionPath() { | 393 FilePath SessionBackend::GetCurrentSessionPath() { |
| 393 FilePath path = path_to_dir_; | 394 FilePath path = path_to_dir_; |
| 394 if (type_ == BaseSessionService::TAB_RESTORE) | 395 if (type_ == BaseSessionService::TAB_RESTORE) |
| 395 path = path.AppendASCII(kCurrentTabSessionFileName); | 396 path = path.AppendASCII(kCurrentTabSessionFileName); |
| 396 else | 397 else |
| 397 path = path.AppendASCII(kCurrentSessionFileName); | 398 path = path.AppendASCII(kCurrentSessionFileName); |
| 398 return path; | 399 return path; |
| 399 } | 400 } |
| OLD | NEW |