Chromium Code Reviews| 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> | 7 #include <stdint.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 35 static const SessionCommand::id_type kCommandSetPinnedState = 12; | 35 static const SessionCommand::id_type kCommandSetPinnedState = 12; |
| 36 static const SessionCommand::id_type kCommandSetExtensionAppID = 13; | 36 static const SessionCommand::id_type kCommandSetExtensionAppID = 13; |
| 37 static const SessionCommand::id_type kCommandSetWindowBounds3 = 14; | 37 static const SessionCommand::id_type kCommandSetWindowBounds3 = 14; |
| 38 static const SessionCommand::id_type kCommandSetWindowAppName = 15; | 38 static const SessionCommand::id_type kCommandSetWindowAppName = 15; |
| 39 static const SessionCommand::id_type kCommandTabClosed = 16; | 39 static const SessionCommand::id_type kCommandTabClosed = 16; |
| 40 static const SessionCommand::id_type kCommandWindowClosed = 17; | 40 static const SessionCommand::id_type kCommandWindowClosed = 17; |
| 41 static const SessionCommand::id_type kCommandSetTabUserAgentOverride = 18; | 41 static const SessionCommand::id_type kCommandSetTabUserAgentOverride = 18; |
| 42 static const SessionCommand::id_type kCommandSessionStorageAssociated = 19; | 42 static const SessionCommand::id_type kCommandSessionStorageAssociated = 19; |
| 43 static const SessionCommand::id_type kCommandSetActiveWindow = 20; | 43 static const SessionCommand::id_type kCommandSetActiveWindow = 20; |
| 44 static const SessionCommand::id_type kCommandLastActiveTime = 21; | 44 static const SessionCommand::id_type kCommandLastActiveTime = 21; |
| 45 static const SessionCommand::id_type kCommandSetWindowWorkspace = 22; | 45 static const SessionCommand::id_type kCommandSetWindowWorkspace = 22; |
|
sky
2016/05/06 21:31:49
The format is now slightly different. You'll want
Tom (Use chromium acct)
2016/05/06 22:14:50
Done.
| |
| 46 | 46 |
| 47 namespace { | 47 namespace { |
| 48 | 48 |
| 49 // Various payload structures. | 49 // Various payload structures. |
| 50 struct ClosedPayload { | 50 struct ClosedPayload { |
| 51 SessionID::id_type id; | 51 SessionID::id_type id; |
| 52 int64_t close_time; | 52 int64_t close_time; |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 struct WindowBoundsPayload2 { | 55 struct WindowBoundsPayload2 { |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 577 } | 577 } |
| 578 SessionTab* tab = GetTab(payload.tab_id, tabs); | 578 SessionTab* tab = GetTab(payload.tab_id, tabs); |
| 579 tab->last_active_time = | 579 tab->last_active_time = |
| 580 base::TimeTicks::FromInternalValue(payload.last_active_time); | 580 base::TimeTicks::FromInternalValue(payload.last_active_time); |
| 581 break; | 581 break; |
| 582 } | 582 } |
| 583 | 583 |
| 584 case kCommandSetWindowWorkspace: { | 584 case kCommandSetWindowWorkspace: { |
| 585 std::unique_ptr<base::Pickle> pickle(command->PayloadAsPickle()); | 585 std::unique_ptr<base::Pickle> pickle(command->PayloadAsPickle()); |
| 586 base::PickleIterator it(*pickle); | 586 base::PickleIterator it(*pickle); |
| 587 const SessionID::id_type* window_id; | 587 SessionID::id_type window_id; |
| 588 std::string workspace; | 588 std::string workspace; |
| 589 if (!it.ReadBytes(reinterpret_cast<const char**>(&window_id), | 589 if (!it.ReadInt(&window_id) || !it.ReadString(&workspace)) { |
| 590 sizeof(*window_id)) || | |
| 591 !it.ReadString(&workspace)) { | |
| 592 DVLOG(1) << "Failed reading command " << command->id(); | 590 DVLOG(1) << "Failed reading command " << command->id(); |
| 593 return true; | 591 return true; |
| 594 } | 592 } |
| 595 GetWindow(*window_id, windows)->workspace = workspace; | 593 GetWindow(window_id, windows)->workspace = workspace; |
| 596 break; | 594 break; |
| 597 } | 595 } |
| 598 | 596 |
| 599 default: | 597 default: |
| 600 // TODO(skuhne): This might call back into a callback handler to extend | 598 // TODO(skuhne): This might call back into a callback handler to extend |
| 601 // the command set for specific implementations. | 599 // the command set for specific implementations. |
| 602 DVLOG(1) << "Failed reading an unknown command " << command->id(); | 600 DVLOG(1) << "Failed reading an unknown command " << command->id(); |
| 603 return true; | 601 return true; |
| 604 } | 602 } |
| 605 } | 603 } |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 752 std::unique_ptr<SessionCommand> command( | 750 std::unique_ptr<SessionCommand> command( |
| 753 new SessionCommand(kCommandLastActiveTime, sizeof(payload))); | 751 new SessionCommand(kCommandLastActiveTime, sizeof(payload))); |
| 754 memcpy(command->contents(), &payload, sizeof(payload)); | 752 memcpy(command->contents(), &payload, sizeof(payload)); |
| 755 return command; | 753 return command; |
| 756 } | 754 } |
| 757 | 755 |
| 758 std::unique_ptr<SessionCommand> CreateSetWindowWorkspaceCommand( | 756 std::unique_ptr<SessionCommand> CreateSetWindowWorkspaceCommand( |
| 759 const SessionID& window_id, | 757 const SessionID& window_id, |
| 760 const std::string& workspace) { | 758 const std::string& workspace) { |
| 761 base::Pickle pickle; | 759 base::Pickle pickle; |
| 762 pickle.WriteBytes(static_cast<const void*>(&window_id), sizeof(window_id)); | 760 pickle.WriteInt(window_id.id()); |
| 763 pickle.WriteString(workspace); | 761 pickle.WriteString(workspace); |
| 764 std::unique_ptr<SessionCommand> command( | 762 std::unique_ptr<SessionCommand> command( |
| 765 new SessionCommand(kCommandSetWindowWorkspace, pickle.size())); | 763 new SessionCommand(kCommandSetWindowWorkspace, pickle)); |
| 766 memcpy(command->contents(), pickle.data(), pickle.size()); | 764 memcpy(command->contents(), pickle.data(), pickle.size()); |
|
sky
2016/05/06 21:31:49
This line shouldn't be necessary anymore.
Tom (Use chromium acct)
2016/05/06 22:14:50
Done.
| |
| 767 return command; | 765 return command; |
| 768 } | 766 } |
| 769 | 767 |
| 770 std::unique_ptr<SessionCommand> CreateTabNavigationPathPrunedFromBackCommand( | 768 std::unique_ptr<SessionCommand> CreateTabNavigationPathPrunedFromBackCommand( |
| 771 const SessionID& tab_id, | 769 const SessionID& tab_id, |
| 772 int count) { | 770 int count) { |
| 773 TabNavigationPathPrunedFromBackPayload payload = { 0 }; | 771 TabNavigationPathPrunedFromBackPayload payload = { 0 }; |
| 774 payload.id = tab_id.id(); | 772 payload.id = tab_id.id(); |
| 775 payload.index = count; | 773 payload.index = count; |
| 776 std::unique_ptr<SessionCommand> command(new SessionCommand( | 774 std::unique_ptr<SessionCommand> command(new SessionCommand( |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 897 AddTabsToWindows(&tabs, &windows); | 895 AddTabsToWindows(&tabs, &windows); |
| 898 SortTabsBasedOnVisualOrderAndPrune(&windows, valid_windows); | 896 SortTabsBasedOnVisualOrderAndPrune(&windows, valid_windows); |
| 899 UpdateSelectedTabIndex(valid_windows); | 897 UpdateSelectedTabIndex(valid_windows); |
| 900 } | 898 } |
| 901 STLDeleteValues(&tabs); | 899 STLDeleteValues(&tabs); |
| 902 // Don't delete contents of windows, that is done by the caller as all | 900 // Don't delete contents of windows, that is done by the caller as all |
| 903 // valid windows are added to valid_windows. | 901 // valid windows are added to valid_windows. |
| 904 } | 902 } |
| 905 | 903 |
| 906 } // namespace sessions | 904 } // namespace sessions |
| OLD | NEW |