| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 TimeTicks start_time = TimeTicks::Now(); | 97 TimeTicks start_time = TimeTicks::Now(); |
| 98 read_count = file_->ReadUntilComplete(reinterpret_cast<char*>(&header), | 98 read_count = file_->ReadUntilComplete(reinterpret_cast<char*>(&header), |
| 99 sizeof(header)); | 99 sizeof(header)); |
| 100 if (read_count != sizeof(header) || header.signature != kFileSignature || | 100 if (read_count != sizeof(header) || header.signature != kFileSignature || |
| 101 header.version != kFileCurrentVersion) | 101 header.version != kFileCurrentVersion) |
| 102 return false; | 102 return false; |
| 103 | 103 |
| 104 ScopedVector<SessionCommand> read_commands; | 104 ScopedVector<SessionCommand> read_commands; |
| 105 SessionCommand* command; | 105 SessionCommand* command; |
| 106 while ((command = ReadCommand()) && !errored_) | 106 while ((command = ReadCommand()) && !errored_) |
| 107 read_commands->push_back(command); | 107 read_commands.push_back(command); |
| 108 if (!errored_) | 108 if (!errored_) |
| 109 read_commands->swap(*commands); | 109 read_commands.swap(*commands); |
| 110 if (type == BaseSessionService::TAB_RESTORE) { | 110 if (type == BaseSessionService::TAB_RESTORE) { |
| 111 UMA_HISTOGRAM_TIMES("TabRestore.read_session_file_time", | 111 UMA_HISTOGRAM_TIMES("TabRestore.read_session_file_time", |
| 112 TimeTicks::Now() - start_time); | 112 TimeTicks::Now() - start_time); |
| 113 } else { | 113 } else { |
| 114 UMA_HISTOGRAM_TIMES("SessionRestore.read_session_file_time", | 114 UMA_HISTOGRAM_TIMES("SessionRestore.read_session_file_time", |
| 115 TimeTicks::Now() - start_time); | 115 TimeTicks::Now() - start_time); |
| 116 } | 116 } |
| 117 return !errored_; | 117 return !errored_; |
| 118 } | 118 } |
| 119 | 119 |
| (...skipping 278 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 |