| 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/tab_restore_service.h" | 5 #include "chrome/browser/sessions/tab_restore_service.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 #include <map> | 9 #include <map> |
| 10 | 10 |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 // Request the tabs closed in the last session. If the last session crashed, | 467 // Request the tabs closed in the last session. If the last session crashed, |
| 468 // this won't contain the tabs/window that were open at the point of the | 468 // this won't contain the tabs/window that were open at the point of the |
| 469 // crash (the call to GetLastSession above requests those). | 469 // crash (the call to GetLastSession above requests those). |
| 470 ScheduleGetLastSessionCommands( | 470 ScheduleGetLastSessionCommands( |
| 471 new InternalGetCommandsRequest( | 471 new InternalGetCommandsRequest( |
| 472 base::Bind(&TabRestoreService::OnGotLastSessionCommands, | 472 base::Bind(&TabRestoreService::OnGotLastSessionCommands, |
| 473 base::Unretained(this))), | 473 base::Unretained(this))), |
| 474 &load_consumer_); | 474 &load_consumer_); |
| 475 } | 475 } |
| 476 | 476 |
| 477 bool TabRestoreService::IsLoaded() const { |
| 478 return !(load_state_ & (NOT_LOADED | LOADING)); |
| 479 } |
| 480 |
| 477 void TabRestoreService::Shutdown() { | 481 void TabRestoreService::Shutdown() { |
| 478 if (backend()) | 482 if (backend()) |
| 479 Save(); | 483 Save(); |
| 480 } | 484 } |
| 481 | 485 |
| 482 void TabRestoreService::Save() { | 486 void TabRestoreService::Save() { |
| 483 int to_write_count = std::min(entries_to_write_, | 487 int to_write_count = std::min(entries_to_write_, |
| 484 static_cast<int>(entries_.size())); | 488 static_cast<int>(entries_.size())); |
| 485 entries_to_write_ = 0; | 489 entries_to_write_ = 0; |
| 486 if (entries_written_ + to_write_count > kEntriesPerReset) { | 490 if (entries_written_ + to_write_count > kEntriesPerReset) { |
| (...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1241 // the front, not the end and we just added the entries to the end). | 1245 // the front, not the end and we just added the entries to the end). |
| 1242 entries_to_write_ = staging_entries_.size(); | 1246 entries_to_write_ = staging_entries_.size(); |
| 1243 | 1247 |
| 1244 PruneEntries(); | 1248 PruneEntries(); |
| 1245 NotifyTabsChanged(); | 1249 NotifyTabsChanged(); |
| 1246 } | 1250 } |
| 1247 | 1251 |
| 1248 Time TabRestoreService::TimeNow() const { | 1252 Time TabRestoreService::TimeNow() const { |
| 1249 return time_factory_ ? time_factory_->TimeNow() : Time::Now(); | 1253 return time_factory_ ? time_factory_->TimeNow() : Time::Now(); |
| 1250 } | 1254 } |
| OLD | NEW |