OLD | NEW |
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/core/session_service_commands.h" | 5 #include "components/sessions/core/session_service_commands.h" |
6 | 6 |
| 7 #include <stdint.h> |
| 8 #include <string.h> |
| 9 |
7 #include <vector> | 10 #include <vector> |
8 | 11 |
9 #include "base/pickle.h" | 12 #include "base/pickle.h" |
10 #include "components/sessions/core/base_session_service_commands.h" | 13 #include "components/sessions/core/base_session_service_commands.h" |
11 #include "components/sessions/core/base_session_service_delegate.h" | 14 #include "components/sessions/core/base_session_service_delegate.h" |
12 #include "components/sessions/core/session_command.h" | 15 #include "components/sessions/core/session_command.h" |
13 #include "components/sessions/core/session_types.h" | 16 #include "components/sessions/core/session_types.h" |
14 | 17 |
15 namespace sessions { | 18 namespace sessions { |
16 | 19 |
(...skipping 21 matching lines...) Expand all Loading... |
38 static const SessionCommand::id_type kCommandSetTabUserAgentOverride = 18; | 41 static const SessionCommand::id_type kCommandSetTabUserAgentOverride = 18; |
39 static const SessionCommand::id_type kCommandSessionStorageAssociated = 19; | 42 static const SessionCommand::id_type kCommandSessionStorageAssociated = 19; |
40 static const SessionCommand::id_type kCommandSetActiveWindow = 20; | 43 static const SessionCommand::id_type kCommandSetActiveWindow = 20; |
41 static const SessionCommand::id_type kCommandLastActiveTime = 21; | 44 static const SessionCommand::id_type kCommandLastActiveTime = 21; |
42 | 45 |
43 namespace { | 46 namespace { |
44 | 47 |
45 // Various payload structures. | 48 // Various payload structures. |
46 struct ClosedPayload { | 49 struct ClosedPayload { |
47 SessionID::id_type id; | 50 SessionID::id_type id; |
48 int64 close_time; | 51 int64_t close_time; |
49 }; | 52 }; |
50 | 53 |
51 struct WindowBoundsPayload2 { | 54 struct WindowBoundsPayload2 { |
52 SessionID::id_type window_id; | 55 SessionID::id_type window_id; |
53 int32 x; | 56 int32_t x; |
54 int32 y; | 57 int32_t y; |
55 int32 w; | 58 int32_t w; |
56 int32 h; | 59 int32_t h; |
57 bool is_maximized; | 60 bool is_maximized; |
58 }; | 61 }; |
59 | 62 |
60 struct WindowBoundsPayload3 { | 63 struct WindowBoundsPayload3 { |
61 SessionID::id_type window_id; | 64 SessionID::id_type window_id; |
62 int32 x; | 65 int32_t x; |
63 int32 y; | 66 int32_t y; |
64 int32 w; | 67 int32_t w; |
65 int32 h; | 68 int32_t h; |
66 int32 show_state; | 69 int32_t show_state; |
67 }; | 70 }; |
68 | 71 |
69 typedef SessionID::id_type ActiveWindowPayload; | 72 typedef SessionID::id_type ActiveWindowPayload; |
70 | 73 |
71 struct IDAndIndexPayload { | 74 struct IDAndIndexPayload { |
72 SessionID::id_type id; | 75 SessionID::id_type id; |
73 int32 index; | 76 int32_t index; |
74 }; | 77 }; |
75 | 78 |
76 typedef IDAndIndexPayload TabIndexInWindowPayload; | 79 typedef IDAndIndexPayload TabIndexInWindowPayload; |
77 | 80 |
78 typedef IDAndIndexPayload TabNavigationPathPrunedFromBackPayload; | 81 typedef IDAndIndexPayload TabNavigationPathPrunedFromBackPayload; |
79 | 82 |
80 typedef IDAndIndexPayload SelectedNavigationIndexPayload; | 83 typedef IDAndIndexPayload SelectedNavigationIndexPayload; |
81 | 84 |
82 typedef IDAndIndexPayload SelectedTabInIndexPayload; | 85 typedef IDAndIndexPayload SelectedTabInIndexPayload; |
83 | 86 |
84 typedef IDAndIndexPayload WindowTypePayload; | 87 typedef IDAndIndexPayload WindowTypePayload; |
85 | 88 |
86 typedef IDAndIndexPayload TabNavigationPathPrunedFromFrontPayload; | 89 typedef IDAndIndexPayload TabNavigationPathPrunedFromFrontPayload; |
87 | 90 |
88 struct PinnedStatePayload { | 91 struct PinnedStatePayload { |
89 SessionID::id_type tab_id; | 92 SessionID::id_type tab_id; |
90 bool pinned_state; | 93 bool pinned_state; |
91 }; | 94 }; |
92 | 95 |
93 struct LastActiveTimePayload { | 96 struct LastActiveTimePayload { |
94 SessionID::id_type tab_id; | 97 SessionID::id_type tab_id; |
95 int64 last_active_time; | 98 int64_t last_active_time; |
96 }; | 99 }; |
97 | 100 |
98 // Persisted versions of ui::WindowShowState that are written to disk and can | 101 // Persisted versions of ui::WindowShowState that are written to disk and can |
99 // never change. | 102 // never change. |
100 enum PersistedWindowShowState { | 103 enum PersistedWindowShowState { |
101 // SHOW_STATE_DEFAULT (0) never persisted. | 104 // SHOW_STATE_DEFAULT (0) never persisted. |
102 PERSISTED_SHOW_STATE_NORMAL = 1, | 105 PERSISTED_SHOW_STATE_NORMAL = 1, |
103 PERSISTED_SHOW_STATE_MINIMIZED = 2, | 106 PERSISTED_SHOW_STATE_MINIMIZED = 2, |
104 PERSISTED_SHOW_STATE_MAXIMIZED = 3, | 107 PERSISTED_SHOW_STATE_MAXIMIZED = 3, |
105 // SHOW_STATE_INACTIVE (4) never persisted. | 108 // SHOW_STATE_INACTIVE (4) never persisted. |
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 new SessionCommand(kCommandSetSelectedNavigationIndex, sizeof(payload))); | 679 new SessionCommand(kCommandSetSelectedNavigationIndex, sizeof(payload))); |
677 memcpy(command->contents(), &payload, sizeof(payload)); | 680 memcpy(command->contents(), &payload, sizeof(payload)); |
678 return command; | 681 return command; |
679 } | 682 } |
680 | 683 |
681 scoped_ptr<SessionCommand> CreateSetWindowTypeCommand( | 684 scoped_ptr<SessionCommand> CreateSetWindowTypeCommand( |
682 const SessionID& window_id, | 685 const SessionID& window_id, |
683 SessionWindow::WindowType type) { | 686 SessionWindow::WindowType type) { |
684 WindowTypePayload payload = { 0 }; | 687 WindowTypePayload payload = { 0 }; |
685 payload.id = window_id.id(); | 688 payload.id = window_id.id(); |
686 payload.index = static_cast<int32>(type); | 689 payload.index = static_cast<int32_t>(type); |
687 scoped_ptr<SessionCommand> command( | 690 scoped_ptr<SessionCommand> command( |
688 new SessionCommand( kCommandSetWindowType, sizeof(payload))); | 691 new SessionCommand( kCommandSetWindowType, sizeof(payload))); |
689 memcpy(command->contents(), &payload, sizeof(payload)); | 692 memcpy(command->contents(), &payload, sizeof(payload)); |
690 return command; | 693 return command; |
691 } | 694 } |
692 | 695 |
693 scoped_ptr<SessionCommand> CreatePinnedStateCommand( | 696 scoped_ptr<SessionCommand> CreatePinnedStateCommand( |
694 const SessionID& tab_id, | 697 const SessionID& tab_id, |
695 bool is_pinned) { | 698 bool is_pinned) { |
696 PinnedStatePayload payload = { 0 }; | 699 PinnedStatePayload payload = { 0 }; |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 AddTabsToWindows(&tabs, &windows); | 867 AddTabsToWindows(&tabs, &windows); |
865 SortTabsBasedOnVisualOrderAndPrune(&windows, valid_windows); | 868 SortTabsBasedOnVisualOrderAndPrune(&windows, valid_windows); |
866 UpdateSelectedTabIndex(valid_windows); | 869 UpdateSelectedTabIndex(valid_windows); |
867 } | 870 } |
868 STLDeleteValues(&tabs); | 871 STLDeleteValues(&tabs); |
869 // Don't delete contents of windows, that is done by the caller as all | 872 // Don't delete contents of windows, that is done by the caller as all |
870 // valid windows are added to valid_windows. | 873 // valid windows are added to valid_windows. |
871 } | 874 } |
872 | 875 |
873 } // namespace sessions | 876 } // namespace sessions |
OLD | NEW |