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 846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
857 if (pending_window_tabs <= 0) { | 857 if (pending_window_tabs <= 0) { |
858 // Should always have at least 1 tab. Likely indicates corruption. | 858 // Should always have at least 1 tab. Likely indicates corruption. |
859 return; | 859 return; |
860 } | 860 } |
861 | 861 |
862 RemoveEntryByID(payload.window_id, &id_to_entry, &(entries.get())); | 862 RemoveEntryByID(payload.window_id, &id_to_entry, &(entries.get())); |
863 | 863 |
864 current_window = new Window(); | 864 current_window = new Window(); |
865 current_window->selected_tab_index = payload.selected_tab_index; | 865 current_window->selected_tab_index = payload.selected_tab_index; |
866 current_window->timestamp = Time::FromInternalValue(payload.timestamp); | 866 current_window->timestamp = Time::FromInternalValue(payload.timestamp); |
867 entries->push_back(current_window); | 867 entries.push_back(current_window); |
868 id_to_entry[payload.window_id] = current_window; | 868 id_to_entry[payload.window_id] = current_window; |
869 break; | 869 break; |
870 } | 870 } |
871 | 871 |
872 case kCommandSelectedNavigationInTab: { | 872 case kCommandSelectedNavigationInTab: { |
873 SelectedNavigationInTabPayload2 payload; | 873 SelectedNavigationInTabPayload2 payload; |
874 if (!command.GetPayload(&payload, sizeof(payload))) { | 874 if (!command.GetPayload(&payload, sizeof(payload))) { |
875 SelectedNavigationInTabPayload old_payload; | 875 SelectedNavigationInTabPayload old_payload; |
876 if (!command.GetPayload(&old_payload, sizeof(old_payload))) | 876 if (!command.GetPayload(&old_payload, sizeof(old_payload))) |
877 return; | 877 return; |
(...skipping 12 matching lines...) Expand all Loading... |
890 } | 890 } |
891 current_window->tabs.resize(current_window->tabs.size() + 1); | 891 current_window->tabs.resize(current_window->tabs.size() + 1); |
892 current_tab = &(current_window->tabs.back()); | 892 current_tab = &(current_window->tabs.back()); |
893 if (--pending_window_tabs == 0) | 893 if (--pending_window_tabs == 0) |
894 current_window = NULL; | 894 current_window = NULL; |
895 } else { | 895 } else { |
896 RemoveEntryByID(payload.id, &id_to_entry, &(entries.get())); | 896 RemoveEntryByID(payload.id, &id_to_entry, &(entries.get())); |
897 current_tab = new Tab(); | 897 current_tab = new Tab(); |
898 id_to_entry[payload.id] = current_tab; | 898 id_to_entry[payload.id] = current_tab; |
899 current_tab->timestamp = Time::FromInternalValue(payload.timestamp); | 899 current_tab->timestamp = Time::FromInternalValue(payload.timestamp); |
900 entries->push_back(current_tab); | 900 entries.push_back(current_tab); |
901 } | 901 } |
902 current_tab->current_navigation_index = payload.index; | 902 current_tab->current_navigation_index = payload.index; |
903 break; | 903 break; |
904 } | 904 } |
905 | 905 |
906 case kCommandUpdateTabNavigation: { | 906 case kCommandUpdateTabNavigation: { |
907 if (!current_tab) { | 907 if (!current_tab) { |
908 // Should be in a tab when we get this. | 908 // Should be in a tab when we get this. |
909 return; | 909 return; |
910 } | 910 } |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1244 // the front, not the end and we just added the entries to the end). | 1244 // the front, not the end and we just added the entries to the end). |
1245 entries_to_write_ = staging_entries_.size(); | 1245 entries_to_write_ = staging_entries_.size(); |
1246 | 1246 |
1247 PruneEntries(); | 1247 PruneEntries(); |
1248 NotifyTabsChanged(); | 1248 NotifyTabsChanged(); |
1249 } | 1249 } |
1250 | 1250 |
1251 Time TabRestoreService::TimeNow() const { | 1251 Time TabRestoreService::TimeNow() const { |
1252 return time_factory_ ? time_factory_->TimeNow() : Time::Now(); | 1252 return time_factory_ ? time_factory_->TimeNow() : Time::Now(); |
1253 } | 1253 } |
OLD | NEW |