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

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

Issue 818833004: Remove deprecated methods from Pickle. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 12 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 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 527
528 GetTab(tab_id, tabs)->user_agent_override.swap(user_agent_override); 528 GetTab(tab_id, tabs)->user_agent_override.swap(user_agent_override);
529 break; 529 break;
530 } 530 }
531 531
532 case kCommandSessionStorageAssociated: { 532 case kCommandSessionStorageAssociated: {
533 scoped_ptr<Pickle> command_pickle(command->PayloadAsPickle()); 533 scoped_ptr<Pickle> command_pickle(command->PayloadAsPickle());
534 SessionID::id_type command_tab_id; 534 SessionID::id_type command_tab_id;
535 std::string session_storage_persistent_id; 535 std::string session_storage_persistent_id;
536 PickleIterator iter(*command_pickle.get()); 536 PickleIterator iter(*command_pickle.get());
537 if (!command_pickle->ReadInt(&iter, &command_tab_id) || 537 if (!iter.ReadInt(&command_tab_id) ||
538 !command_pickle->ReadString(&iter, &session_storage_persistent_id)) 538 !iter.ReadString(&session_storage_persistent_id))
539 return true; 539 return true;
540 // Associate the session storage back. 540 // Associate the session storage back.
541 GetTab(command_tab_id, tabs)->session_storage_persistent_id = 541 GetTab(command_tab_id, tabs)->session_storage_persistent_id =
542 session_storage_persistent_id; 542 session_storage_persistent_id;
543 break; 543 break;
544 } 544 }
545 545
546 case kCommandSetActiveWindow: { 546 case kCommandSetActiveWindow: {
547 ActiveWindowPayload payload; 547 ActiveWindowPayload payload;
548 if (!command->GetPayload(&payload, sizeof(payload))) { 548 if (!command->GetPayload(&payload, sizeof(payload))) {
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 for (ScopedVector<SessionCommand>::const_reverse_iterator i = 768 for (ScopedVector<SessionCommand>::const_reverse_iterator i =
769 base_session_service->pending_commands().rbegin(); 769 base_session_service->pending_commands().rbegin();
770 i != base_session_service->pending_commands().rend(); ++i) { 770 i != base_session_service->pending_commands().rend(); ++i) {
771 SessionCommand* existing_command = *i; 771 SessionCommand* existing_command = *i;
772 if ((*command)->id() == kCommandUpdateTabNavigation && 772 if ((*command)->id() == kCommandUpdateTabNavigation &&
773 existing_command->id() == kCommandUpdateTabNavigation) { 773 existing_command->id() == kCommandUpdateTabNavigation) {
774 scoped_ptr<Pickle> command_pickle((*command)->PayloadAsPickle()); 774 scoped_ptr<Pickle> command_pickle((*command)->PayloadAsPickle());
775 PickleIterator iterator(*command_pickle); 775 PickleIterator iterator(*command_pickle);
776 SessionID::id_type command_tab_id; 776 SessionID::id_type command_tab_id;
777 int command_nav_index; 777 int command_nav_index;
778 if (!command_pickle->ReadInt(&iterator, &command_tab_id) || 778 if (!iterator.ReadInt(&command_tab_id) ||
779 !command_pickle->ReadInt(&iterator, &command_nav_index)) { 779 !iterator.ReadInt(&command_nav_index)) {
780 return false; 780 return false;
781 } 781 }
782 SessionID::id_type existing_tab_id; 782 SessionID::id_type existing_tab_id;
783 int existing_nav_index; 783 int existing_nav_index;
784 { 784 {
785 // Creating a pickle like this means the Pickle references the data from 785 // Creating a pickle like this means the Pickle references the data from
786 // the command. Make sure we delete the pickle before the command, else 786 // the command. Make sure we delete the pickle before the command, else
787 // the pickle references deleted memory. 787 // the pickle references deleted memory.
788 scoped_ptr<Pickle> existing_pickle(existing_command->PayloadAsPickle()); 788 scoped_ptr<Pickle> existing_pickle(existing_command->PayloadAsPickle());
789 iterator = PickleIterator(*existing_pickle); 789 iterator = PickleIterator(*existing_pickle);
790 if (!existing_pickle->ReadInt(&iterator, &existing_tab_id) || 790 if (!iterator.ReadInt(&existing_tab_id) ||
791 !existing_pickle->ReadInt(&iterator, &existing_nav_index)) { 791 !iterator.ReadInt(&existing_nav_index)) {
792 return false; 792 return false;
793 } 793 }
794 } 794 }
795 if (existing_tab_id == command_tab_id && 795 if (existing_tab_id == command_tab_id &&
796 existing_nav_index == command_nav_index) { 796 existing_nav_index == command_nav_index) {
797 // existing_command is an update for the same tab/index pair. Replace 797 // existing_command is an update for the same tab/index pair. Replace
798 // it with the new one. We need to add to the end of the list just in 798 // it with the new one. We need to add to the end of the list just in
799 // case there is a prune command after the update command. 799 // case there is a prune command after the update command.
800 base_session_service->EraseCommand(*(i.base() - 1)); 800 base_session_service->EraseCommand(*(i.base() - 1));
801 base_session_service->AppendRebuildCommand((*command).Pass()); 801 base_session_service->AppendRebuildCommand((*command).Pass());
(...skipping 26 matching lines...) Expand all
828 AddTabsToWindows(&tabs, &windows); 828 AddTabsToWindows(&tabs, &windows);
829 SortTabsBasedOnVisualOrderAndPrune(&windows, valid_windows); 829 SortTabsBasedOnVisualOrderAndPrune(&windows, valid_windows);
830 UpdateSelectedTabIndex(valid_windows); 830 UpdateSelectedTabIndex(valid_windows);
831 } 831 }
832 STLDeleteValues(&tabs); 832 STLDeleteValues(&tabs);
833 // Don't delete contents of windows, that is done by the caller as all 833 // Don't delete contents of windows, that is done by the caller as all
834 // valid windows are added to valid_windows. 834 // valid windows are added to valid_windows.
835 } 835 }
836 836
837 } // namespace sessions 837 } // namespace sessions
OLDNEW
« no previous file with comments | « components/sessions/base_session_service_commands.cc ('k') | content/browser/loader/resource_dispatcher_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698