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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 return false; | 330 return false; |
331 } | 331 } |
332 if (content_size > 0) { | 332 if (content_size > 0) { |
333 wrote = file->WriteSync(reinterpret_cast<char*>((*i)->contents()), | 333 wrote = file->WriteSync(reinterpret_cast<char*>((*i)->contents()), |
334 content_size); | 334 content_size); |
335 if (wrote != content_size) { | 335 if (wrote != content_size) { |
336 NOTREACHED() << "error writing"; | 336 NOTREACHED() << "error writing"; |
337 return false; | 337 return false; |
338 } | 338 } |
339 } | 339 } |
| 340 #if defined(OS_CHROMEOS) |
| 341 // TODO(gspencer): Remove this once we find a better place to do it. |
| 342 // See issue http://crbug.com/245015 |
| 343 file->FlushSync(); |
| 344 #endif |
340 } | 345 } |
341 return true; | 346 return true; |
342 } | 347 } |
343 | 348 |
344 SessionBackend::~SessionBackend() { | 349 SessionBackend::~SessionBackend() { |
345 if (current_session_file_.get()) { | 350 if (current_session_file_.get()) { |
346 // Destructor performs file IO because file is open in sync mode. | 351 // Destructor performs file IO because file is open in sync mode. |
347 // crbug.com/112512. | 352 // crbug.com/112512. |
348 base::ThreadRestrictions::ScopedAllowIO allow_io; | 353 base::ThreadRestrictions::ScopedAllowIO allow_io; |
349 current_session_file_.reset(); | 354 current_session_file_.reset(); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 } | 399 } |
395 | 400 |
396 base::FilePath SessionBackend::GetCurrentSessionPath() { | 401 base::FilePath SessionBackend::GetCurrentSessionPath() { |
397 base::FilePath path = path_to_dir_; | 402 base::FilePath path = path_to_dir_; |
398 if (type_ == BaseSessionService::TAB_RESTORE) | 403 if (type_ == BaseSessionService::TAB_RESTORE) |
399 path = path.AppendASCII(kCurrentTabSessionFileName); | 404 path = path.AppendASCII(kCurrentTabSessionFileName); |
400 else | 405 else |
401 path = path.AppendASCII(kCurrentSessionFileName); | 406 path = path.AppendASCII(kCurrentSessionFileName); |
402 return path; | 407 return path; |
403 } | 408 } |
OLD | NEW |