| 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/files/file.h" | 10 #include "base/files/file.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 FileHeader header; | 92 FileHeader header; |
| 93 int read_count; | 93 int read_count; |
| 94 TimeTicks start_time = TimeTicks::Now(); | 94 TimeTicks start_time = TimeTicks::Now(); |
| 95 read_count = file_->ReadAtCurrentPos(reinterpret_cast<char*>(&header), | 95 read_count = file_->ReadAtCurrentPos(reinterpret_cast<char*>(&header), |
| 96 sizeof(header)); | 96 sizeof(header)); |
| 97 if (read_count != sizeof(header) || header.signature != kFileSignature || | 97 if (read_count != sizeof(header) || header.signature != kFileSignature || |
| 98 header.version != kFileCurrentVersion) | 98 header.version != kFileCurrentVersion) |
| 99 return false; | 99 return false; |
| 100 | 100 |
| 101 ScopedVector<SessionCommand> read_commands; | 101 ScopedVector<SessionCommand> read_commands; |
| 102 SessionCommand* command; | 102 for (SessionCommand* command = ReadCommand(); command && !errored_; |
| 103 while ((command = ReadCommand()) && !errored_) | 103 command = ReadCommand()) |
| 104 read_commands.push_back(command); | 104 read_commands.push_back(command); |
| 105 if (!errored_) | 105 if (!errored_) |
| 106 read_commands.swap(*commands); | 106 read_commands.swap(*commands); |
| 107 if (type == BaseSessionService::TAB_RESTORE) { | 107 if (type == BaseSessionService::TAB_RESTORE) { |
| 108 UMA_HISTOGRAM_TIMES("TabRestore.read_session_file_time", | 108 UMA_HISTOGRAM_TIMES("TabRestore.read_session_file_time", |
| 109 TimeTicks::Now() - start_time); | 109 TimeTicks::Now() - start_time); |
| 110 } else { | 110 } else { |
| 111 UMA_HISTOGRAM_TIMES("SessionRestore.read_session_file_time", | 111 UMA_HISTOGRAM_TIMES("SessionRestore.read_session_file_time", |
| 112 TimeTicks::Now() - start_time); | 112 TimeTicks::Now() - start_time); |
| 113 } | 113 } |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 } | 395 } |
| 396 | 396 |
| 397 base::FilePath SessionBackend::GetCurrentSessionPath() { | 397 base::FilePath SessionBackend::GetCurrentSessionPath() { |
| 398 base::FilePath path = path_to_dir_; | 398 base::FilePath path = path_to_dir_; |
| 399 if (type_ == BaseSessionService::TAB_RESTORE) | 399 if (type_ == BaseSessionService::TAB_RESTORE) |
| 400 path = path.AppendASCII(kCurrentTabSessionFileName); | 400 path = path.AppendASCII(kCurrentTabSessionFileName); |
| 401 else | 401 else |
| 402 path = path.AppendASCII(kCurrentSessionFileName); | 402 path = path.AppendASCII(kCurrentSessionFileName); |
| 403 return path; | 403 return path; |
| 404 } | 404 } |
| OLD | NEW |