| 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 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 &tab_id, | 537 &tab_id, |
| 538 &user_agent_override)) { | 538 &user_agent_override)) { |
| 539 return true; | 539 return true; |
| 540 } | 540 } |
| 541 | 541 |
| 542 GetTab(tab_id, tabs)->user_agent_override.swap(user_agent_override); | 542 GetTab(tab_id, tabs)->user_agent_override.swap(user_agent_override); |
| 543 break; | 543 break; |
| 544 } | 544 } |
| 545 | 545 |
| 546 case kCommandSessionStorageAssociated: { | 546 case kCommandSessionStorageAssociated: { |
| 547 scoped_ptr<base::Pickle> command_pickle(command->PayloadAsPickle()); | 547 std::unique_ptr<base::Pickle> command_pickle( |
| 548 command->PayloadAsPickle()); |
| 548 SessionID::id_type command_tab_id; | 549 SessionID::id_type command_tab_id; |
| 549 std::string session_storage_persistent_id; | 550 std::string session_storage_persistent_id; |
| 550 base::PickleIterator iter(*command_pickle.get()); | 551 base::PickleIterator iter(*command_pickle.get()); |
| 551 if (!iter.ReadInt(&command_tab_id) || | 552 if (!iter.ReadInt(&command_tab_id) || |
| 552 !iter.ReadString(&session_storage_persistent_id)) | 553 !iter.ReadString(&session_storage_persistent_id)) |
| 553 return true; | 554 return true; |
| 554 // Associate the session storage back. | 555 // Associate the session storage back. |
| 555 GetTab(command_tab_id, tabs)->session_storage_persistent_id = | 556 GetTab(command_tab_id, tabs)->session_storage_persistent_id = |
| 556 session_storage_persistent_id; | 557 session_storage_persistent_id; |
| 557 break; | 558 break; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 584 // the command set for specific implementations. | 585 // the command set for specific implementations. |
| 585 DVLOG(1) << "Failed reading an unknown command " << command->id(); | 586 DVLOG(1) << "Failed reading an unknown command " << command->id(); |
| 586 return true; | 587 return true; |
| 587 } | 588 } |
| 588 } | 589 } |
| 589 return true; | 590 return true; |
| 590 } | 591 } |
| 591 | 592 |
| 592 } // namespace | 593 } // namespace |
| 593 | 594 |
| 594 scoped_ptr<SessionCommand> CreateSetSelectedTabInWindowCommand( | 595 std::unique_ptr<SessionCommand> CreateSetSelectedTabInWindowCommand( |
| 595 const SessionID& window_id, | 596 const SessionID& window_id, |
| 596 int index) { | 597 int index) { |
| 597 SelectedTabInIndexPayload payload = { 0 }; | 598 SelectedTabInIndexPayload payload = { 0 }; |
| 598 payload.id = window_id.id(); | 599 payload.id = window_id.id(); |
| 599 payload.index = index; | 600 payload.index = index; |
| 600 scoped_ptr<SessionCommand> command( | 601 std::unique_ptr<SessionCommand> command( |
| 601 new SessionCommand(kCommandSetSelectedTabInIndex, sizeof(payload))); | 602 new SessionCommand(kCommandSetSelectedTabInIndex, sizeof(payload))); |
| 602 memcpy(command->contents(), &payload, sizeof(payload)); | 603 memcpy(command->contents(), &payload, sizeof(payload)); |
| 603 return command; | 604 return command; |
| 604 } | 605 } |
| 605 | 606 |
| 606 scoped_ptr<SessionCommand> CreateSetTabWindowCommand(const SessionID& window_id, | 607 std::unique_ptr<SessionCommand> CreateSetTabWindowCommand( |
| 607 const SessionID& tab_id) { | 608 const SessionID& window_id, |
| 609 const SessionID& tab_id) { |
| 608 SessionID::id_type payload[] = { window_id.id(), tab_id.id() }; | 610 SessionID::id_type payload[] = { window_id.id(), tab_id.id() }; |
| 609 scoped_ptr<SessionCommand> command( | 611 std::unique_ptr<SessionCommand> command( |
| 610 new SessionCommand(kCommandSetTabWindow, sizeof(payload))); | 612 new SessionCommand(kCommandSetTabWindow, sizeof(payload))); |
| 611 memcpy(command->contents(), payload, sizeof(payload)); | 613 memcpy(command->contents(), payload, sizeof(payload)); |
| 612 return command; | 614 return command; |
| 613 } | 615 } |
| 614 | 616 |
| 615 scoped_ptr<SessionCommand> CreateSetWindowBoundsCommand( | 617 std::unique_ptr<SessionCommand> CreateSetWindowBoundsCommand( |
| 616 const SessionID& window_id, | 618 const SessionID& window_id, |
| 617 const gfx::Rect& bounds, | 619 const gfx::Rect& bounds, |
| 618 ui::WindowShowState show_state) { | 620 ui::WindowShowState show_state) { |
| 619 WindowBoundsPayload3 payload = { 0 }; | 621 WindowBoundsPayload3 payload = { 0 }; |
| 620 payload.window_id = window_id.id(); | 622 payload.window_id = window_id.id(); |
| 621 payload.x = bounds.x(); | 623 payload.x = bounds.x(); |
| 622 payload.y = bounds.y(); | 624 payload.y = bounds.y(); |
| 623 payload.w = bounds.width(); | 625 payload.w = bounds.width(); |
| 624 payload.h = bounds.height(); | 626 payload.h = bounds.height(); |
| 625 payload.show_state = ShowStateToPersistedShowState(show_state); | 627 payload.show_state = ShowStateToPersistedShowState(show_state); |
| 626 scoped_ptr<SessionCommand> command( | 628 std::unique_ptr<SessionCommand> command( |
| 627 new SessionCommand(kCommandSetWindowBounds3, sizeof(payload))); | 629 new SessionCommand(kCommandSetWindowBounds3, sizeof(payload))); |
| 628 memcpy(command->contents(), &payload, sizeof(payload)); | 630 memcpy(command->contents(), &payload, sizeof(payload)); |
| 629 return command; | 631 return command; |
| 630 } | 632 } |
| 631 | 633 |
| 632 scoped_ptr<SessionCommand> CreateSetTabIndexInWindowCommand( | 634 std::unique_ptr<SessionCommand> CreateSetTabIndexInWindowCommand( |
| 633 const SessionID& tab_id, | 635 const SessionID& tab_id, |
| 634 int new_index) { | 636 int new_index) { |
| 635 TabIndexInWindowPayload payload = { 0 }; | 637 TabIndexInWindowPayload payload = { 0 }; |
| 636 payload.id = tab_id.id(); | 638 payload.id = tab_id.id(); |
| 637 payload.index = new_index; | 639 payload.index = new_index; |
| 638 scoped_ptr<SessionCommand> command( | 640 std::unique_ptr<SessionCommand> command( |
| 639 new SessionCommand(kCommandSetTabIndexInWindow, sizeof(payload))); | 641 new SessionCommand(kCommandSetTabIndexInWindow, sizeof(payload))); |
| 640 memcpy(command->contents(), &payload, sizeof(payload)); | 642 memcpy(command->contents(), &payload, sizeof(payload)); |
| 641 return command; | 643 return command; |
| 642 } | 644 } |
| 643 | 645 |
| 644 scoped_ptr<SessionCommand> CreateTabClosedCommand( | 646 std::unique_ptr<SessionCommand> CreateTabClosedCommand( |
| 645 const SessionID::id_type tab_id) { | 647 const SessionID::id_type tab_id) { |
| 646 ClosedPayload payload; | 648 ClosedPayload payload; |
| 647 // Because of what appears to be a compiler bug setting payload to {0} doesn't | 649 // Because of what appears to be a compiler bug setting payload to {0} doesn't |
| 648 // set the padding to 0, resulting in Purify reporting an UMR when we write | 650 // set the padding to 0, resulting in Purify reporting an UMR when we write |
| 649 // the structure to disk. To avoid this we explicitly memset the struct. | 651 // the structure to disk. To avoid this we explicitly memset the struct. |
| 650 memset(&payload, 0, sizeof(payload)); | 652 memset(&payload, 0, sizeof(payload)); |
| 651 payload.id = tab_id; | 653 payload.id = tab_id; |
| 652 payload.close_time = base::Time::Now().ToInternalValue(); | 654 payload.close_time = base::Time::Now().ToInternalValue(); |
| 653 scoped_ptr<SessionCommand> command( | 655 std::unique_ptr<SessionCommand> command( |
| 654 new SessionCommand(kCommandTabClosed, sizeof(payload))); | 656 new SessionCommand(kCommandTabClosed, sizeof(payload))); |
| 655 memcpy(command->contents(), &payload, sizeof(payload)); | 657 memcpy(command->contents(), &payload, sizeof(payload)); |
| 656 return command; | 658 return command; |
| 657 } | 659 } |
| 658 | 660 |
| 659 scoped_ptr<SessionCommand> CreateWindowClosedCommand( | 661 std::unique_ptr<SessionCommand> CreateWindowClosedCommand( |
| 660 const SessionID::id_type window_id) { | 662 const SessionID::id_type window_id) { |
| 661 ClosedPayload payload; | 663 ClosedPayload payload; |
| 662 // See comment in CreateTabClosedCommand as to why we do this. | 664 // See comment in CreateTabClosedCommand as to why we do this. |
| 663 memset(&payload, 0, sizeof(payload)); | 665 memset(&payload, 0, sizeof(payload)); |
| 664 payload.id = window_id; | 666 payload.id = window_id; |
| 665 payload.close_time = base::Time::Now().ToInternalValue(); | 667 payload.close_time = base::Time::Now().ToInternalValue(); |
| 666 scoped_ptr<SessionCommand> command( | 668 std::unique_ptr<SessionCommand> command( |
| 667 new SessionCommand(kCommandWindowClosed, sizeof(payload))); | 669 new SessionCommand(kCommandWindowClosed, sizeof(payload))); |
| 668 memcpy(command->contents(), &payload, sizeof(payload)); | 670 memcpy(command->contents(), &payload, sizeof(payload)); |
| 669 return command; | 671 return command; |
| 670 } | 672 } |
| 671 | 673 |
| 672 scoped_ptr<SessionCommand> CreateSetSelectedNavigationIndexCommand( | 674 std::unique_ptr<SessionCommand> CreateSetSelectedNavigationIndexCommand( |
| 673 const SessionID& tab_id, | 675 const SessionID& tab_id, |
| 674 int index) { | 676 int index) { |
| 675 SelectedNavigationIndexPayload payload = { 0 }; | 677 SelectedNavigationIndexPayload payload = { 0 }; |
| 676 payload.id = tab_id.id(); | 678 payload.id = tab_id.id(); |
| 677 payload.index = index; | 679 payload.index = index; |
| 678 scoped_ptr<SessionCommand> command( | 680 std::unique_ptr<SessionCommand> command( |
| 679 new SessionCommand(kCommandSetSelectedNavigationIndex, sizeof(payload))); | 681 new SessionCommand(kCommandSetSelectedNavigationIndex, sizeof(payload))); |
| 680 memcpy(command->contents(), &payload, sizeof(payload)); | 682 memcpy(command->contents(), &payload, sizeof(payload)); |
| 681 return command; | 683 return command; |
| 682 } | 684 } |
| 683 | 685 |
| 684 scoped_ptr<SessionCommand> CreateSetWindowTypeCommand( | 686 std::unique_ptr<SessionCommand> CreateSetWindowTypeCommand( |
| 685 const SessionID& window_id, | 687 const SessionID& window_id, |
| 686 SessionWindow::WindowType type) { | 688 SessionWindow::WindowType type) { |
| 687 WindowTypePayload payload = { 0 }; | 689 WindowTypePayload payload = { 0 }; |
| 688 payload.id = window_id.id(); | 690 payload.id = window_id.id(); |
| 689 payload.index = static_cast<int32_t>(type); | 691 payload.index = static_cast<int32_t>(type); |
| 690 scoped_ptr<SessionCommand> command( | 692 std::unique_ptr<SessionCommand> command( |
| 691 new SessionCommand( kCommandSetWindowType, sizeof(payload))); | 693 new SessionCommand(kCommandSetWindowType, sizeof(payload))); |
| 692 memcpy(command->contents(), &payload, sizeof(payload)); | 694 memcpy(command->contents(), &payload, sizeof(payload)); |
| 693 return command; | 695 return command; |
| 694 } | 696 } |
| 695 | 697 |
| 696 scoped_ptr<SessionCommand> CreatePinnedStateCommand( | 698 std::unique_ptr<SessionCommand> CreatePinnedStateCommand( |
| 697 const SessionID& tab_id, | 699 const SessionID& tab_id, |
| 698 bool is_pinned) { | 700 bool is_pinned) { |
| 699 PinnedStatePayload payload = { 0 }; | 701 PinnedStatePayload payload = { 0 }; |
| 700 payload.tab_id = tab_id.id(); | 702 payload.tab_id = tab_id.id(); |
| 701 payload.pinned_state = is_pinned; | 703 payload.pinned_state = is_pinned; |
| 702 scoped_ptr<SessionCommand> command( | 704 std::unique_ptr<SessionCommand> command( |
| 703 new SessionCommand(kCommandSetPinnedState, sizeof(payload))); | 705 new SessionCommand(kCommandSetPinnedState, sizeof(payload))); |
| 704 memcpy(command->contents(), &payload, sizeof(payload)); | 706 memcpy(command->contents(), &payload, sizeof(payload)); |
| 705 return command; | 707 return command; |
| 706 } | 708 } |
| 707 | 709 |
| 708 scoped_ptr<SessionCommand> CreateSessionStorageAssociatedCommand( | 710 std::unique_ptr<SessionCommand> CreateSessionStorageAssociatedCommand( |
| 709 const SessionID& tab_id, | 711 const SessionID& tab_id, |
| 710 const std::string& session_storage_persistent_id) { | 712 const std::string& session_storage_persistent_id) { |
| 711 base::Pickle pickle; | 713 base::Pickle pickle; |
| 712 pickle.WriteInt(tab_id.id()); | 714 pickle.WriteInt(tab_id.id()); |
| 713 pickle.WriteString(session_storage_persistent_id); | 715 pickle.WriteString(session_storage_persistent_id); |
| 714 return scoped_ptr<SessionCommand>( | 716 return std::unique_ptr<SessionCommand>( |
| 715 new SessionCommand(kCommandSessionStorageAssociated, pickle)); | 717 new SessionCommand(kCommandSessionStorageAssociated, pickle)); |
| 716 } | 718 } |
| 717 | 719 |
| 718 scoped_ptr<SessionCommand> CreateSetActiveWindowCommand( | 720 std::unique_ptr<SessionCommand> CreateSetActiveWindowCommand( |
| 719 const SessionID& window_id) { | 721 const SessionID& window_id) { |
| 720 ActiveWindowPayload payload = 0; | 722 ActiveWindowPayload payload = 0; |
| 721 payload = window_id.id(); | 723 payload = window_id.id(); |
| 722 scoped_ptr<SessionCommand> command( | 724 std::unique_ptr<SessionCommand> command( |
| 723 new SessionCommand(kCommandSetActiveWindow, sizeof(payload))); | 725 new SessionCommand(kCommandSetActiveWindow, sizeof(payload))); |
| 724 memcpy(command->contents(), &payload, sizeof(payload)); | 726 memcpy(command->contents(), &payload, sizeof(payload)); |
| 725 return command; | 727 return command; |
| 726 } | 728 } |
| 727 | 729 |
| 728 scoped_ptr<SessionCommand> CreateLastActiveTimeCommand( | 730 std::unique_ptr<SessionCommand> CreateLastActiveTimeCommand( |
| 729 const SessionID& tab_id, | 731 const SessionID& tab_id, |
| 730 base::TimeTicks last_active_time) { | 732 base::TimeTicks last_active_time) { |
| 731 LastActiveTimePayload payload = {0}; | 733 LastActiveTimePayload payload = {0}; |
| 732 payload.tab_id = tab_id.id(); | 734 payload.tab_id = tab_id.id(); |
| 733 payload.last_active_time = last_active_time.ToInternalValue(); | 735 payload.last_active_time = last_active_time.ToInternalValue(); |
| 734 scoped_ptr<SessionCommand> command( | 736 std::unique_ptr<SessionCommand> command( |
| 735 new SessionCommand(kCommandLastActiveTime, sizeof(payload))); | 737 new SessionCommand(kCommandLastActiveTime, sizeof(payload))); |
| 736 memcpy(command->contents(), &payload, sizeof(payload)); | 738 memcpy(command->contents(), &payload, sizeof(payload)); |
| 737 return command; | 739 return command; |
| 738 } | 740 } |
| 739 | 741 |
| 740 scoped_ptr<SessionCommand> CreateTabNavigationPathPrunedFromBackCommand( | 742 std::unique_ptr<SessionCommand> CreateTabNavigationPathPrunedFromBackCommand( |
| 741 const SessionID& tab_id, | 743 const SessionID& tab_id, |
| 742 int count) { | 744 int count) { |
| 743 TabNavigationPathPrunedFromBackPayload payload = { 0 }; | 745 TabNavigationPathPrunedFromBackPayload payload = { 0 }; |
| 744 payload.id = tab_id.id(); | 746 payload.id = tab_id.id(); |
| 745 payload.index = count; | 747 payload.index = count; |
| 746 scoped_ptr<SessionCommand> command( | 748 std::unique_ptr<SessionCommand> command(new SessionCommand( |
| 747 new SessionCommand(kCommandTabNavigationPathPrunedFromBack, | 749 kCommandTabNavigationPathPrunedFromBack, sizeof(payload))); |
| 748 sizeof(payload))); | |
| 749 memcpy(command->contents(), &payload, sizeof(payload)); | 750 memcpy(command->contents(), &payload, sizeof(payload)); |
| 750 return command; | 751 return command; |
| 751 } | 752 } |
| 752 | 753 |
| 753 scoped_ptr<SessionCommand> CreateTabNavigationPathPrunedFromFrontCommand( | 754 std::unique_ptr<SessionCommand> CreateTabNavigationPathPrunedFromFrontCommand( |
| 754 const SessionID& tab_id, | 755 const SessionID& tab_id, |
| 755 int count) { | 756 int count) { |
| 756 TabNavigationPathPrunedFromFrontPayload payload = { 0 }; | 757 TabNavigationPathPrunedFromFrontPayload payload = { 0 }; |
| 757 payload.id = tab_id.id(); | 758 payload.id = tab_id.id(); |
| 758 payload.index = count; | 759 payload.index = count; |
| 759 scoped_ptr<SessionCommand> command( | 760 std::unique_ptr<SessionCommand> command(new SessionCommand( |
| 760 new SessionCommand(kCommandTabNavigationPathPrunedFromFront, | 761 kCommandTabNavigationPathPrunedFromFront, sizeof(payload))); |
| 761 sizeof(payload))); | |
| 762 memcpy(command->contents(), &payload, sizeof(payload)); | 762 memcpy(command->contents(), &payload, sizeof(payload)); |
| 763 return command; | 763 return command; |
| 764 } | 764 } |
| 765 | 765 |
| 766 scoped_ptr<SessionCommand> CreateUpdateTabNavigationCommand( | 766 std::unique_ptr<SessionCommand> CreateUpdateTabNavigationCommand( |
| 767 const SessionID& tab_id, | 767 const SessionID& tab_id, |
| 768 const sessions::SerializedNavigationEntry& navigation) { | 768 const sessions::SerializedNavigationEntry& navigation) { |
| 769 return CreateUpdateTabNavigationCommand(kCommandUpdateTabNavigation, | 769 return CreateUpdateTabNavigationCommand(kCommandUpdateTabNavigation, |
| 770 tab_id.id(), | 770 tab_id.id(), |
| 771 navigation); | 771 navigation); |
| 772 } | 772 } |
| 773 | 773 |
| 774 scoped_ptr<SessionCommand> CreateSetTabExtensionAppIDCommand( | 774 std::unique_ptr<SessionCommand> CreateSetTabExtensionAppIDCommand( |
| 775 const SessionID& tab_id, | 775 const SessionID& tab_id, |
| 776 const std::string& extension_id) { | 776 const std::string& extension_id) { |
| 777 return CreateSetTabExtensionAppIDCommand(kCommandSetExtensionAppID, | 777 return CreateSetTabExtensionAppIDCommand(kCommandSetExtensionAppID, |
| 778 tab_id.id(), | 778 tab_id.id(), |
| 779 extension_id); | 779 extension_id); |
| 780 } | 780 } |
| 781 | 781 |
| 782 scoped_ptr<SessionCommand> CreateSetTabUserAgentOverrideCommand( | 782 std::unique_ptr<SessionCommand> CreateSetTabUserAgentOverrideCommand( |
| 783 const SessionID& tab_id, | 783 const SessionID& tab_id, |
| 784 const std::string& user_agent_override) { | 784 const std::string& user_agent_override) { |
| 785 return CreateSetTabUserAgentOverrideCommand(kCommandSetTabUserAgentOverride, | 785 return CreateSetTabUserAgentOverrideCommand(kCommandSetTabUserAgentOverride, |
| 786 tab_id.id(), | 786 tab_id.id(), |
| 787 user_agent_override); | 787 user_agent_override); |
| 788 } | 788 } |
| 789 | 789 |
| 790 scoped_ptr<SessionCommand> CreateSetWindowAppNameCommand( | 790 std::unique_ptr<SessionCommand> CreateSetWindowAppNameCommand( |
| 791 const SessionID& window_id, | 791 const SessionID& window_id, |
| 792 const std::string& app_name) { | 792 const std::string& app_name) { |
| 793 return CreateSetWindowAppNameCommand(kCommandSetWindowAppName, | 793 return CreateSetWindowAppNameCommand(kCommandSetWindowAppName, |
| 794 window_id.id(), | 794 window_id.id(), |
| 795 app_name); | 795 app_name); |
| 796 } | 796 } |
| 797 | 797 |
| 798 bool ReplacePendingCommand(BaseSessionService* base_session_service, | 798 bool ReplacePendingCommand(BaseSessionService* base_session_service, |
| 799 scoped_ptr<SessionCommand>* command) { | 799 std::unique_ptr<SessionCommand>* command) { |
| 800 // We optimize page navigations, which can happen quite frequently and | 800 // We optimize page navigations, which can happen quite frequently and |
| 801 // is expensive. And activation is like Highlander, there can only be one! | 801 // is expensive. And activation is like Highlander, there can only be one! |
| 802 if ((*command)->id() != kCommandUpdateTabNavigation && | 802 if ((*command)->id() != kCommandUpdateTabNavigation && |
| 803 (*command)->id() != kCommandSetActiveWindow) { | 803 (*command)->id() != kCommandSetActiveWindow) { |
| 804 return false; | 804 return false; |
| 805 } | 805 } |
| 806 for (ScopedVector<SessionCommand>::const_reverse_iterator i = | 806 for (ScopedVector<SessionCommand>::const_reverse_iterator i = |
| 807 base_session_service->pending_commands().rbegin(); | 807 base_session_service->pending_commands().rbegin(); |
| 808 i != base_session_service->pending_commands().rend(); ++i) { | 808 i != base_session_service->pending_commands().rend(); ++i) { |
| 809 SessionCommand* existing_command = *i; | 809 SessionCommand* existing_command = *i; |
| 810 if ((*command)->id() == kCommandUpdateTabNavigation && | 810 if ((*command)->id() == kCommandUpdateTabNavigation && |
| 811 existing_command->id() == kCommandUpdateTabNavigation) { | 811 existing_command->id() == kCommandUpdateTabNavigation) { |
| 812 scoped_ptr<base::Pickle> command_pickle((*command)->PayloadAsPickle()); | 812 std::unique_ptr<base::Pickle> command_pickle( |
| 813 (*command)->PayloadAsPickle()); |
| 813 base::PickleIterator iterator(*command_pickle); | 814 base::PickleIterator iterator(*command_pickle); |
| 814 SessionID::id_type command_tab_id; | 815 SessionID::id_type command_tab_id; |
| 815 int command_nav_index; | 816 int command_nav_index; |
| 816 if (!iterator.ReadInt(&command_tab_id) || | 817 if (!iterator.ReadInt(&command_tab_id) || |
| 817 !iterator.ReadInt(&command_nav_index)) { | 818 !iterator.ReadInt(&command_nav_index)) { |
| 818 return false; | 819 return false; |
| 819 } | 820 } |
| 820 SessionID::id_type existing_tab_id; | 821 SessionID::id_type existing_tab_id; |
| 821 int existing_nav_index; | 822 int existing_nav_index; |
| 822 { | 823 { |
| 823 // Creating a pickle like this means the Pickle references the data from | 824 // Creating a pickle like this means the Pickle references the data from |
| 824 // the command. Make sure we delete the pickle before the command, else | 825 // the command. Make sure we delete the pickle before the command, else |
| 825 // the pickle references deleted memory. | 826 // the pickle references deleted memory. |
| 826 scoped_ptr<base::Pickle> existing_pickle( | 827 std::unique_ptr<base::Pickle> existing_pickle( |
| 827 existing_command->PayloadAsPickle()); | 828 existing_command->PayloadAsPickle()); |
| 828 iterator = base::PickleIterator(*existing_pickle); | 829 iterator = base::PickleIterator(*existing_pickle); |
| 829 if (!iterator.ReadInt(&existing_tab_id) || | 830 if (!iterator.ReadInt(&existing_tab_id) || |
| 830 !iterator.ReadInt(&existing_nav_index)) { | 831 !iterator.ReadInt(&existing_nav_index)) { |
| 831 return false; | 832 return false; |
| 832 } | 833 } |
| 833 } | 834 } |
| 834 if (existing_tab_id == command_tab_id && | 835 if (existing_tab_id == command_tab_id && |
| 835 existing_nav_index == command_nav_index) { | 836 existing_nav_index == command_nav_index) { |
| 836 // existing_command is an update for the same tab/index pair. Replace | 837 // existing_command is an update for the same tab/index pair. Replace |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 868 AddTabsToWindows(&tabs, &windows); | 869 AddTabsToWindows(&tabs, &windows); |
| 869 SortTabsBasedOnVisualOrderAndPrune(&windows, valid_windows); | 870 SortTabsBasedOnVisualOrderAndPrune(&windows, valid_windows); |
| 870 UpdateSelectedTabIndex(valid_windows); | 871 UpdateSelectedTabIndex(valid_windows); |
| 871 } | 872 } |
| 872 STLDeleteValues(&tabs); | 873 STLDeleteValues(&tabs); |
| 873 // Don't delete contents of windows, that is done by the caller as all | 874 // Don't delete contents of windows, that is done by the caller as all |
| 874 // valid windows are added to valid_windows. | 875 // valid windows are added to valid_windows. |
| 875 } | 876 } |
| 876 | 877 |
| 877 } // namespace sessions | 878 } // namespace sessions |
| OLD | NEW |