| OLD | NEW |
| 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 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 } | 336 } |
| 337 if (content_size > 0) { | 337 if (content_size > 0) { |
| 338 wrote = file->WriteSync(reinterpret_cast<char*>((*i)->contents()), | 338 wrote = file->WriteSync(reinterpret_cast<char*>((*i)->contents()), |
| 339 content_size); | 339 content_size); |
| 340 if (wrote != content_size) { | 340 if (wrote != content_size) { |
| 341 NOTREACHED() << "error writing"; | 341 NOTREACHED() << "error writing"; |
| 342 return false; | 342 return false; |
| 343 } | 343 } |
| 344 } | 344 } |
| 345 } | 345 } |
| 346 file->Flush(); | 346 file->FlushSync(); |
| 347 return true; | 347 return true; |
| 348 } | 348 } |
| 349 | 349 |
| 350 SessionBackend::~SessionBackend() { | 350 SessionBackend::~SessionBackend() { |
| 351 if (current_session_file_.get()) { | 351 if (current_session_file_.get()) { |
| 352 // Close() performs file IO. crbug.com/112512. | 352 // Close() performs file IO. crbug.com/112512. |
| 353 base::ThreadRestrictions::ScopedAllowIO allow_io; | 353 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 354 current_session_file_->CloseSync(); | 354 current_session_file_->CloseSync(); |
| 355 } | 355 } |
| 356 } | 356 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 } | 398 } |
| 399 | 399 |
| 400 FilePath SessionBackend::GetCurrentSessionPath() { | 400 FilePath SessionBackend::GetCurrentSessionPath() { |
| 401 FilePath path = path_to_dir_; | 401 FilePath path = path_to_dir_; |
| 402 if (type_ == BaseSessionService::TAB_RESTORE) | 402 if (type_ == BaseSessionService::TAB_RESTORE) |
| 403 path = path.AppendASCII(kCurrentTabSessionFileName); | 403 path = path.AppendASCII(kCurrentTabSessionFileName); |
| 404 else | 404 else |
| 405 path = path.AppendASCII(kCurrentSessionFileName); | 405 path = path.AppendASCII(kCurrentSessionFileName); |
| 406 return path; | 406 return path; |
| 407 } | 407 } |
| OLD | NEW |