Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(292)

Side by Side Diff: components/sessions/session_service_commands.cc

Issue 1131373003: [Session restore] Add MRU logic to loading of background pages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unnecessary change in tab_restore_service.h Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/sessions/session_service_commands.h" 5 #include "components/sessions/session_service_commands.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/pickle.h" 9 #include "base/pickle.h"
10 #include "components/sessions/base_session_service_commands.h" 10 #include "components/sessions/base_session_service_commands.h"
(...skipping 20 matching lines...) Expand all
31 kCommandTabNavigationPathPrunedFromFront = 11; 31 kCommandTabNavigationPathPrunedFromFront = 11;
32 static const SessionCommand::id_type kCommandSetPinnedState = 12; 32 static const SessionCommand::id_type kCommandSetPinnedState = 12;
33 static const SessionCommand::id_type kCommandSetExtensionAppID = 13; 33 static const SessionCommand::id_type kCommandSetExtensionAppID = 13;
34 static const SessionCommand::id_type kCommandSetWindowBounds3 = 14; 34 static const SessionCommand::id_type kCommandSetWindowBounds3 = 14;
35 static const SessionCommand::id_type kCommandSetWindowAppName = 15; 35 static const SessionCommand::id_type kCommandSetWindowAppName = 15;
36 static const SessionCommand::id_type kCommandTabClosed = 16; 36 static const SessionCommand::id_type kCommandTabClosed = 16;
37 static const SessionCommand::id_type kCommandWindowClosed = 17; 37 static const SessionCommand::id_type kCommandWindowClosed = 17;
38 static const SessionCommand::id_type kCommandSetTabUserAgentOverride = 18; 38 static const SessionCommand::id_type kCommandSetTabUserAgentOverride = 18;
39 static const SessionCommand::id_type kCommandSessionStorageAssociated = 19; 39 static const SessionCommand::id_type kCommandSessionStorageAssociated = 19;
40 static const SessionCommand::id_type kCommandSetActiveWindow = 20; 40 static const SessionCommand::id_type kCommandSetActiveWindow = 20;
41 static const SessionCommand::id_type kCommandLastActiveTime = 21;
41 42
42 namespace { 43 namespace {
43 44
44 // Various payload structures. 45 // Various payload structures.
45 struct ClosedPayload { 46 struct ClosedPayload {
46 SessionID::id_type id; 47 SessionID::id_type id;
47 int64 close_time; 48 int64 close_time;
48 }; 49 };
49 50
50 struct WindowBoundsPayload2 { 51 struct WindowBoundsPayload2 {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 83
83 typedef IDAndIndexPayload WindowTypePayload; 84 typedef IDAndIndexPayload WindowTypePayload;
84 85
85 typedef IDAndIndexPayload TabNavigationPathPrunedFromFrontPayload; 86 typedef IDAndIndexPayload TabNavigationPathPrunedFromFrontPayload;
86 87
87 struct PinnedStatePayload { 88 struct PinnedStatePayload {
88 SessionID::id_type tab_id; 89 SessionID::id_type tab_id;
89 bool pinned_state; 90 bool pinned_state;
90 }; 91 };
91 92
93 struct LastActiveTimePayload {
94 SessionID::id_type tab_id;
95 int64 last_active_time;
96 };
97
92 // Persisted versions of ui::WindowShowState that are written to disk and can 98 // Persisted versions of ui::WindowShowState that are written to disk and can
93 // never change. 99 // never change.
94 enum PersistedWindowShowState { 100 enum PersistedWindowShowState {
95 // SHOW_STATE_DEFAULT (0) never persisted. 101 // SHOW_STATE_DEFAULT (0) never persisted.
96 PERSISTED_SHOW_STATE_NORMAL = 1, 102 PERSISTED_SHOW_STATE_NORMAL = 1,
97 PERSISTED_SHOW_STATE_MINIMIZED = 2, 103 PERSISTED_SHOW_STATE_MINIMIZED = 2,
98 PERSISTED_SHOW_STATE_MAXIMIZED = 3, 104 PERSISTED_SHOW_STATE_MAXIMIZED = 3,
99 // SHOW_STATE_INACTIVE (4) never persisted. 105 // SHOW_STATE_INACTIVE (4) never persisted.
100 PERSISTED_SHOW_STATE_FULLSCREEN = 5, 106 PERSISTED_SHOW_STATE_FULLSCREEN = 5,
101 PERSISTED_SHOW_STATE_DETACHED_DEPRECATED = 6, 107 PERSISTED_SHOW_STATE_DETACHED_DEPRECATED = 6,
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 case kCommandSetActiveWindow: { 557 case kCommandSetActiveWindow: {
552 ActiveWindowPayload payload; 558 ActiveWindowPayload payload;
553 if (!command->GetPayload(&payload, sizeof(payload))) { 559 if (!command->GetPayload(&payload, sizeof(payload))) {
554 DVLOG(1) << "Failed reading command " << command->id(); 560 DVLOG(1) << "Failed reading command " << command->id();
555 return true; 561 return true;
556 } 562 }
557 *active_window_id = payload; 563 *active_window_id = payload;
558 break; 564 break;
559 } 565 }
560 566
567 case kCommandLastActiveTime: {
568 LastActiveTimePayload payload;
569 if (!command->GetPayload(&payload, sizeof(payload))) {
570 DVLOG(1) << "Failed reading command " << command->id();
571 return true;
572 }
573 SessionTab* tab = GetTab(payload.tab_id, tabs);
574 tab->last_active_time =
575 base::Time::FromInternalValue(payload.last_active_time);
576 break;
577 }
578
561 default: 579 default:
562 // TODO(skuhne): This might call back into a callback handler to extend 580 // TODO(skuhne): This might call back into a callback handler to extend
563 // the command set for specific implementations. 581 // the command set for specific implementations.
564 DVLOG(1) << "Failed reading an unknown command " << command->id(); 582 DVLOG(1) << "Failed reading an unknown command " << command->id();
565 return true; 583 return true;
566 } 584 }
567 } 585 }
568 return true; 586 return true;
569 } 587 }
570 588
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 scoped_ptr<SessionCommand> CreateSetActiveWindowCommand( 715 scoped_ptr<SessionCommand> CreateSetActiveWindowCommand(
698 const SessionID& window_id) { 716 const SessionID& window_id) {
699 ActiveWindowPayload payload = 0; 717 ActiveWindowPayload payload = 0;
700 payload = window_id.id(); 718 payload = window_id.id();
701 scoped_ptr<SessionCommand> command( 719 scoped_ptr<SessionCommand> command(
702 new SessionCommand(kCommandSetActiveWindow, sizeof(payload))); 720 new SessionCommand(kCommandSetActiveWindow, sizeof(payload)));
703 memcpy(command->contents(), &payload, sizeof(payload)); 721 memcpy(command->contents(), &payload, sizeof(payload));
704 return command; 722 return command;
705 } 723 }
706 724
725 scoped_ptr<SessionCommand> CreateLastActiveTimeCommand(
726 const SessionID& tab_id,
727 base::Time last_active_time) {
728 LastActiveTimePayload payload = {0};
729 payload.tab_id = tab_id.id();
730 payload.last_active_time = last_active_time.ToInternalValue();
731 scoped_ptr<SessionCommand> command(
732 new SessionCommand(kCommandLastActiveTime, sizeof(payload)));
733 memcpy(command->contents(), &payload, sizeof(payload));
734 return command;
735 }
736
707 scoped_ptr<SessionCommand> CreateTabNavigationPathPrunedFromBackCommand( 737 scoped_ptr<SessionCommand> CreateTabNavigationPathPrunedFromBackCommand(
708 const SessionID& tab_id, 738 const SessionID& tab_id,
709 int count) { 739 int count) {
710 TabNavigationPathPrunedFromBackPayload payload = { 0 }; 740 TabNavigationPathPrunedFromBackPayload payload = { 0 };
711 payload.id = tab_id.id(); 741 payload.id = tab_id.id();
712 payload.index = count; 742 payload.index = count;
713 scoped_ptr<SessionCommand> command( 743 scoped_ptr<SessionCommand> command(
714 new SessionCommand(kCommandTabNavigationPathPrunedFromBack, 744 new SessionCommand(kCommandTabNavigationPathPrunedFromBack,
715 sizeof(payload))); 745 sizeof(payload)));
716 memcpy(command->contents(), &payload, sizeof(payload)); 746 memcpy(command->contents(), &payload, sizeof(payload));
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 AddTabsToWindows(&tabs, &windows); 863 AddTabsToWindows(&tabs, &windows);
834 SortTabsBasedOnVisualOrderAndPrune(&windows, valid_windows); 864 SortTabsBasedOnVisualOrderAndPrune(&windows, valid_windows);
835 UpdateSelectedTabIndex(valid_windows); 865 UpdateSelectedTabIndex(valid_windows);
836 } 866 }
837 STLDeleteValues(&tabs); 867 STLDeleteValues(&tabs);
838 // Don't delete contents of windows, that is done by the caller as all 868 // Don't delete contents of windows, that is done by the caller as all
839 // valid windows are added to valid_windows. 869 // valid windows are added to valid_windows.
840 } 870 }
841 871
842 } // namespace sessions 872 } // namespace sessions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698