| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/browser/frame_host/navigator_impl.h" | 5 #include "content/browser/frame_host/navigator_impl.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "content/browser/frame_host/frame_tree.h" | 10 #include "content/browser/frame_host/frame_tree.h" |
| (...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 // ongoing request b) which is browser or user-initiated and c) the renderer | 643 // ongoing request b) which is browser or user-initiated and c) the renderer |
| 644 // request is not user-initiated. | 644 // request is not user-initiated. |
| 645 if (ongoing_navigation_request && | 645 if (ongoing_navigation_request && |
| 646 (ongoing_navigation_request->browser_initiated() || | 646 (ongoing_navigation_request->browser_initiated() || |
| 647 ongoing_navigation_request->begin_params().has_user_gesture) && | 647 ongoing_navigation_request->begin_params().has_user_gesture) && |
| 648 !begin_params.has_user_gesture) { | 648 !begin_params.has_user_gesture) { |
| 649 return; | 649 return; |
| 650 } | 650 } |
| 651 | 651 |
| 652 // In all other cases the current navigation, if any, is canceled and a new | 652 // In all other cases the current navigation, if any, is canceled and a new |
| 653 // NavigationRequest is created and stored in the map. Actual cancellation | 653 // NavigationRequest is created and stored in the map. |
| 654 // happens when the existing request map entry is replaced and destroyed. | 654 if (ongoing_navigation_request) |
| 655 CancelNavigation(frame_tree_node); |
| 656 |
| 655 scoped_ptr<NavigationRequest> navigation_request = | 657 scoped_ptr<NavigationRequest> navigation_request = |
| 656 NavigationRequest::CreateRendererInitiated( | 658 NavigationRequest::CreateRendererInitiated( |
| 657 frame_tree_node, common_params, begin_params, body, | 659 frame_tree_node, common_params, begin_params, body, |
| 658 controller_->GetLastCommittedEntryIndex(), | 660 controller_->GetLastCommittedEntryIndex(), |
| 659 controller_->GetEntryCount()); | 661 controller_->GetEntryCount()); |
| 660 navigation_request_map_.set( | 662 navigation_request_map_.set( |
| 661 frame_tree_node->frame_tree_node_id(), navigation_request.Pass()); | 663 frame_tree_node->frame_tree_node_id(), navigation_request.Pass()); |
| 662 | 664 |
| 663 if (frame_tree_node->IsMainFrame()) | 665 if (frame_tree_node->IsMainFrame()) |
| 664 navigation_data_.reset(); | 666 navigation_data_.reset(); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 781 int64 frame_tree_node_id = frame_tree_node->frame_tree_node_id(); | 783 int64 frame_tree_node_id = frame_tree_node->frame_tree_node_id(); |
| 782 FrameMsg_Navigate_Type::Value navigation_type = | 784 FrameMsg_Navigate_Type::Value navigation_type = |
| 783 GetNavigationType(controller_->GetBrowserContext(), entry, reload_type); | 785 GetNavigationType(controller_->GetBrowserContext(), entry, reload_type); |
| 784 scoped_ptr<NavigationRequest> navigation_request = | 786 scoped_ptr<NavigationRequest> navigation_request = |
| 785 NavigationRequest::CreateBrowserInitiated(frame_tree_node, entry, | 787 NavigationRequest::CreateBrowserInitiated(frame_tree_node, entry, |
| 786 navigation_type, | 788 navigation_type, |
| 787 navigation_start, controller_); | 789 navigation_start, controller_); |
| 788 // TODO(clamy): Check if navigations are blocked and if so store the | 790 // TODO(clamy): Check if navigations are blocked and if so store the |
| 789 // parameters. | 791 // parameters. |
| 790 | 792 |
| 791 // If there is an ongoing request, replace it. | 793 // If there is an ongoing request, cancel and replace it. |
| 794 NavigationRequest* ongoing_request = |
| 795 navigation_request_map_.get(frame_tree_node->frame_tree_node_id()); |
| 796 if (ongoing_request) |
| 797 CancelNavigation(frame_tree_node); |
| 798 |
| 792 navigation_request_map_.set(frame_tree_node_id, navigation_request.Pass()); | 799 navigation_request_map_.set(frame_tree_node_id, navigation_request.Pass()); |
| 793 | 800 |
| 794 // Have the current renderer execute its beforeUnload event if needed. If it | 801 // Have the current renderer execute its beforeUnload event if needed. If it |
| 795 // is not needed (eg. the renderer is not live), BeginNavigation should get | 802 // is not needed (eg. the renderer is not live), BeginNavigation should get |
| 796 // called. | 803 // called. |
| 797 NavigationRequest* request_to_send = | 804 NavigationRequest* request_to_send = |
| 798 navigation_request_map_.get(frame_tree_node_id); | 805 navigation_request_map_.get(frame_tree_node_id); |
| 799 request_to_send->SetWaitingForRendererResponse(); | 806 request_to_send->SetWaitingForRendererResponse(); |
| 800 frame_tree_node->current_frame_host()->DispatchBeforeUnload(true); | 807 frame_tree_node->current_frame_host()->DispatchBeforeUnload(true); |
| 801 } | 808 } |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 866 "Navigation.TimeToCommit_ExistingRenderer_BeforeUnloadDiscounted", | 873 "Navigation.TimeToCommit_ExistingRenderer_BeforeUnloadDiscounted", |
| 867 time_to_commit); | 874 time_to_commit); |
| 868 UMA_HISTOGRAM_TIMES( | 875 UMA_HISTOGRAM_TIMES( |
| 869 "Navigation.TimeToURLJobStart_ExistingRenderer_BeforeUnloadDiscounted", | 876 "Navigation.TimeToURLJobStart_ExistingRenderer_BeforeUnloadDiscounted", |
| 870 time_to_network); | 877 time_to_network); |
| 871 } | 878 } |
| 872 navigation_data_.reset(); | 879 navigation_data_.reset(); |
| 873 } | 880 } |
| 874 | 881 |
| 875 } // namespace content | 882 } // namespace content |
| OLD | NEW |