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

Side by Side Diff: content/renderer/render_frame_impl.cc

Issue 1693563002: PROTOTYPE: PlzNavigate: use a Mojo data pipe to stream navigation data to the renderer. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Browser sends URLRequest id to the renderer and renderer uses intermediary buffer for data: none he… Created 4 years, 8 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
« no previous file with comments | « content/renderer/render_frame_impl.h ('k') | content/test/test_navigation_url_loader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/renderer/render_frame_impl.h" 5 #include "content/renderer/render_frame_impl.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 #include "content/child/web_url_loader_impl.h" 45 #include "content/child/web_url_loader_impl.h"
46 #include "content/child/web_url_request_util.h" 46 #include "content/child/web_url_request_util.h"
47 #include "content/child/webmessageportchannel_impl.h" 47 #include "content/child/webmessageportchannel_impl.h"
48 #include "content/child/websocket_bridge.h" 48 #include "content/child/websocket_bridge.h"
49 #include "content/child/weburlresponse_extradata_impl.h" 49 #include "content/child/weburlresponse_extradata_impl.h"
50 #include "content/common/accessibility_messages.h" 50 #include "content/common/accessibility_messages.h"
51 #include "content/common/clipboard_messages.h" 51 #include "content/common/clipboard_messages.h"
52 #include "content/common/frame_messages.h" 52 #include "content/common/frame_messages.h"
53 #include "content/common/frame_replication_state.h" 53 #include "content/common/frame_replication_state.h"
54 #include "content/common/input_messages.h" 54 #include "content/common/input_messages.h"
55 #include "content/common/navigation_params.h"
56 #include "content/common/page_messages.h" 55 #include "content/common/page_messages.h"
56 #include "content/common/render_frame_setup.mojom.h"
57 #include "content/common/savable_subframe.h" 57 #include "content/common/savable_subframe.h"
58 #include "content/common/service_worker/service_worker_types.h" 58 #include "content/common/service_worker/service_worker_types.h"
59 #include "content/common/site_isolation_policy.h" 59 #include "content/common/site_isolation_policy.h"
60 #include "content/common/ssl_status_serialization.h" 60 #include "content/common/ssl_status_serialization.h"
61 #include "content/common/swapped_out_messages.h" 61 #include "content/common/swapped_out_messages.h"
62 #include "content/common/view_messages.h" 62 #include "content/common/view_messages.h"
63 #include "content/public/common/bindings_policy.h" 63 #include "content/public/common/bindings_policy.h"
64 #include "content/public/common/browser_side_navigation_policy.h" 64 #include "content/public/common/browser_side_navigation_policy.h"
65 #include "content/public/common/content_constants.h" 65 #include "content/public/common/content_constants.h"
66 #include "content/public/common/content_switches.h" 66 #include "content/public/common/content_switches.h"
67 #include "content/public/common/context_menu_params.h" 67 #include "content/public/common/context_menu_params.h"
68 #include "content/public/common/isolated_world_ids.h" 68 #include "content/public/common/isolated_world_ids.h"
69 #include "content/public/common/page_state.h" 69 #include "content/public/common/page_state.h"
70 #include "content/public/common/resource_response.h"
71 #include "content/public/common/url_constants.h" 70 #include "content/public/common/url_constants.h"
72 #include "content/public/common/url_utils.h" 71 #include "content/public/common/url_utils.h"
73 #include "content/public/renderer/browser_plugin_delegate.h" 72 #include "content/public/renderer/browser_plugin_delegate.h"
74 #include "content/public/renderer/content_renderer_client.h" 73 #include "content/public/renderer/content_renderer_client.h"
75 #include "content/public/renderer/context_menu_client.h" 74 #include "content/public/renderer/context_menu_client.h"
76 #include "content/public/renderer/document_state.h" 75 #include "content/public/renderer/document_state.h"
77 #include "content/public/renderer/navigation_state.h" 76 #include "content/public/renderer/navigation_state.h"
78 #include "content/public/renderer/render_frame_observer.h" 77 #include "content/public/renderer/render_frame_observer.h"
79 #include "content/public/renderer/renderer_ppapi_host.h" 78 #include "content/public/renderer/renderer_ppapi_host.h"
80 #include "content/renderer/accessibility/renderer_accessibility.h" 79 #include "content/renderer/accessibility/renderer_accessibility.h"
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 base::CompareCase::INSENSITIVE_ASCII) && 774 base::CompareCase::INSENSITIVE_ASCII) &&
776 !media::HasPlatformDecoderSupport()) { 775 !media::HasPlatformDecoderSupport()) {
777 return false; 776 return false;
778 } 777 }
779 778
780 // Otherwise enable WMPI if indicated via experiment or command line. 779 // Otherwise enable WMPI if indicated via experiment or command line.
781 return media::IsUnifiedMediaPipelineEnabled(); 780 return media::IsUnifiedMediaPipelineEnabled();
782 } 781 }
783 #endif // defined(OS_ANDROID) 782 #endif // defined(OS_ANDROID)
784 783
784 class DataPipeConsumerHandleReceiverImpl
785 : public DataPipeConsumerHandleReceiver {
786 public:
787 static void CreateService(
788 RenderFrameImpl* rfi,
789 mojo::InterfaceRequest<DataPipeConsumerHandleReceiver> request) {
790 // No leak here because of mojo::StrongBinding usage.
791 new DataPipeConsumerHandleReceiverImpl(rfi, std::move(request));
792 }
793
794 void ReceiveDataPipeConsumerHandle(
795 mojo::ScopedDataPipeConsumerHandle data_consumer_handle,
796 int browser_request_id,
797 int32_t handle_commit_id) override {
798 rfi_->ReceiveNavigationDataPipeConsumerHandle(
799 std::move(data_consumer_handle), browser_request_id, handle_commit_id);
800 }
801
802 private:
803 DataPipeConsumerHandleReceiverImpl(
804 RenderFrameImpl* rfi,
805 mojo::InterfaceRequest<DataPipeConsumerHandleReceiver> request)
806 : rfi_(rfi), binding_(this, std::move(request)) {}
807
808 RenderFrameImpl* rfi_;
809 mojo::StrongBinding<DataPipeConsumerHandleReceiver> binding_;
810 };
811
785 } // namespace 812 } // namespace
786 813
787 // static 814 // static
788 RenderFrameImpl* RenderFrameImpl::Create(RenderViewImpl* render_view, 815 RenderFrameImpl* RenderFrameImpl::Create(RenderViewImpl* render_view,
789 int32_t routing_id) { 816 int32_t routing_id) {
790 DCHECK(routing_id != MSG_ROUTING_NONE); 817 DCHECK(routing_id != MSG_ROUTING_NONE);
791 CreateParams params(render_view, routing_id); 818 CreateParams params(render_view, routing_id);
792 819
793 if (g_create_render_frame_impl) 820 if (g_create_render_frame_impl)
794 return g_create_render_frame_impl(params); 821 return g_create_render_frame_impl(params);
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1009 geolocation_dispatcher_(NULL), 1036 geolocation_dispatcher_(NULL),
1010 push_messaging_dispatcher_(NULL), 1037 push_messaging_dispatcher_(NULL),
1011 presentation_dispatcher_(NULL), 1038 presentation_dispatcher_(NULL),
1012 screen_orientation_dispatcher_(NULL), 1039 screen_orientation_dispatcher_(NULL),
1013 manifest_manager_(NULL), 1040 manifest_manager_(NULL),
1014 accessibility_mode_(AccessibilityModeOff), 1041 accessibility_mode_(AccessibilityModeOff),
1015 renderer_accessibility_(NULL), 1042 renderer_accessibility_(NULL),
1016 media_player_delegate_(NULL), 1043 media_player_delegate_(NULL),
1017 is_using_lofi_(false), 1044 is_using_lofi_(false),
1018 is_pasting_(false), 1045 is_pasting_(false),
1046 latest_browser_request_id_(-1),
1047 latest_handle_commit_id_(-1),
1048 handle_render_thread_(nullptr),
1049 latest_navigation_commit_id_(-1),
1050 navigation_render_thread_(nullptr),
1019 weak_factory_(this) { 1051 weak_factory_(this) {
1020 std::pair<RoutingIDFrameMap::iterator, bool> result = 1052 std::pair<RoutingIDFrameMap::iterator, bool> result =
1021 g_routing_id_frame_map.Get().insert(std::make_pair(routing_id_, this)); 1053 g_routing_id_frame_map.Get().insert(std::make_pair(routing_id_, this));
1022 CHECK(result.second) << "Inserting a duplicate item."; 1054 CHECK(result.second) << "Inserting a duplicate item.";
1023 1055
1024 RenderThread::Get()->AddRoute(routing_id_, this); 1056 RenderThread::Get()->AddRoute(routing_id_, this);
1025 1057
1026 render_view_->RegisterRenderFrame(this); 1058 render_view_->RegisterRenderFrame(this);
1027 1059
1028 // Everything below subclasses RenderFrameObserver and is automatically 1060 // Everything below subclasses RenderFrameObserver and is automatically
(...skipping 3578 matching lines...) Expand 10 before | Expand all | Expand 10 after
4607 void RenderFrameImpl::FocusedNodeChangedForAccessibility(const WebNode& node) { 4639 void RenderFrameImpl::FocusedNodeChangedForAccessibility(const WebNode& node) {
4608 if (renderer_accessibility()) 4640 if (renderer_accessibility())
4609 renderer_accessibility()->AccessibilityFocusedNodeChanged(node); 4641 renderer_accessibility()->AccessibilityFocusedNodeChanged(node);
4610 } 4642 }
4611 4643
4612 // PlzNavigate 4644 // PlzNavigate
4613 void RenderFrameImpl::OnCommitNavigation( 4645 void RenderFrameImpl::OnCommitNavigation(
4614 const ResourceResponseHead& response, 4646 const ResourceResponseHead& response,
4615 const GURL& stream_url, 4647 const GURL& stream_url,
4616 const CommonNavigationParams& common_params, 4648 const CommonNavigationParams& common_params,
4617 const RequestNavigationParams& request_params) { 4649 const RequestNavigationParams& request_params,
4650 int32_t navigation_commit_id) {
4618 CHECK(IsBrowserSideNavigationEnabled()); 4651 CHECK(IsBrowserSideNavigationEnabled());
4619 // This will override the url requested by the WebURLLoader, as well as 4652 navigation_response_ = response;
4620 // provide it with the response to the request. 4653 navigation_stream_url_ = stream_url;
4621 scoped_ptr<StreamOverrideParameters> stream_override( 4654 navigation_common_params_ = common_params;
4622 new StreamOverrideParameters()); 4655 navigation_request_params_ = request_params;
4623 stream_override->stream_url = stream_url;
4624 stream_override->response = response;
4625 4656
4626 NavigateInternal(common_params, StartNavigationParams(), request_params, 4657 latest_navigation_commit_id_ = navigation_commit_id;
4627 std::move(stream_override)); 4658 navigation_render_thread_ = RenderThreadImpl::current();
4659 NavigateIfIPCSynched(navigation_commit_id < 0);
4628 } 4660 }
4629 4661
4630 // PlzNavigate 4662 // PlzNavigate
4663 void RenderFrameImpl::ReceiveNavigationDataPipeConsumerHandle(
4664 mojo::ScopedDataPipeConsumerHandle data_consumer_handle,
4665 int browser_request_id,
4666 int32_t handle_commit_id) {
4667 latest_handle_ = std::move(data_consumer_handle);
4668 latest_browser_request_id_ = browser_request_id;
4669 latest_handle_commit_id_ = handle_commit_id;
4670 handle_render_thread_ = RenderThreadImpl::current();
4671 RenderFrameImpl::NavigateIfIPCSynched(false);
4672 }
4673
4674 void RenderFrameImpl::NavigateIfIPCSynched(bool no_sync_needed) {
4675 if (no_sync_needed ||
4676 latest_navigation_commit_id_ == latest_handle_commit_id_) {
4677 LOG(ERROR) << "*** NAVIGATED with commit id: "
4678 << latest_navigation_commit_id_ << " ***";
4679 if (navigation_render_thread_ != nullptr &&
4680 handle_render_thread_ != nullptr &&
4681 navigation_render_thread_ != handle_render_thread_) {
4682 LOG(ERROR) << "*** AHHHHHHHHHHHHHHH! THREADS DIFFER !!!! ***";
4683 }
4684 // This will override the url requested by the WebURLLoader, as well as
4685 // provide it with the response to the request.
4686 scoped_ptr<StreamOverrideParameters> stream_override(
4687 new StreamOverrideParameters());
4688 stream_override->response = navigation_response_;
4689 stream_override->mojo_handle = no_sync_needed
4690 ? mojo::ScopedDataPipeConsumerHandle()
4691 : std::move(latest_handle_);
4692 stream_override->browser_request_id = latest_browser_request_id_;
4693
4694 NavigateInternal(navigation_common_params_, StartNavigationParams(),
4695 navigation_request_params_, std::move(stream_override));
4696 } else {
4697 LOG(ERROR) << "*** Still waiting on the "
4698 << (latest_navigation_commit_id_ < latest_handle_commit_id_
4699 ? "NAVIGATION"
4700 : "HANDLE")
4701 << " commit id to navigate";
4702 LOG(ERROR) << "*** latest_navigation_commit_id_ : "
4703 << latest_navigation_commit_id_;
4704 LOG(ERROR) << "*** latest_handle_commit_id_ : "
4705 << latest_handle_commit_id_;
4706 }
4707 // TODO: throw away the extra stored data when a newer handle of the other
4708 // type is received.
4709 }
4710
4711 // PlzNavigate
4631 void RenderFrameImpl::OnFailedNavigation( 4712 void RenderFrameImpl::OnFailedNavigation(
4632 const CommonNavigationParams& common_params, 4713 const CommonNavigationParams& common_params,
4633 const RequestNavigationParams& request_params, 4714 const RequestNavigationParams& request_params,
4634 bool has_stale_copy_in_cache, 4715 bool has_stale_copy_in_cache,
4635 int error_code) { 4716 int error_code) {
4636 DCHECK(IsBrowserSideNavigationEnabled()); 4717 DCHECK(IsBrowserSideNavigationEnabled());
4637 bool is_reload = IsReload(common_params.navigation_type); 4718 bool is_reload = IsReload(common_params.navigation_type);
4638 bool is_history_navigation = request_params.page_state.IsValid(); 4719 bool is_history_navigation = request_params.page_state.IsValid();
4639 WebURLRequest::CachePolicy cache_policy = 4720 WebURLRequest::CachePolicy cache_policy =
4640 WebURLRequest::UseProtocolCachePolicy; 4721 WebURLRequest::UseProtocolCachePolicy;
(...skipping 1363 matching lines...) Expand 10 before | Expand all | Expand 10 after
6004 #endif 6085 #endif
6005 return decoder_factory_.get(); 6086 return decoder_factory_.get();
6006 } 6087 }
6007 6088
6008 void RenderFrameImpl::RegisterMojoServices() { 6089 void RenderFrameImpl::RegisterMojoServices() {
6009 // Only main frame have ImageDownloader service. 6090 // Only main frame have ImageDownloader service.
6010 if (!frame_->parent()) { 6091 if (!frame_->parent()) {
6011 GetServiceRegistry()->AddService(base::Bind( 6092 GetServiceRegistry()->AddService(base::Bind(
6012 &ImageDownloaderImpl::CreateMojoService, base::Unretained(this))); 6093 &ImageDownloaderImpl::CreateMojoService, base::Unretained(this)));
6013 } 6094 }
6095
6096 GetServiceRegistry()->AddService<DataPipeConsumerHandleReceiver>(
6097 base::Bind(&DataPipeConsumerHandleReceiverImpl::CreateService,
6098 base::Unretained(this)));
6014 } 6099 }
6015 6100
6016 template <typename Interface> 6101 template <typename Interface>
6017 void RenderFrameImpl::GetInterface(mojo::InterfaceRequest<Interface> request) { 6102 void RenderFrameImpl::GetInterface(mojo::InterfaceRequest<Interface> request) {
6018 GetServiceRegistry()->ConnectToRemoteService(std::move(request)); 6103 GetServiceRegistry()->ConnectToRemoteService(std::move(request));
6019 } 6104 }
6020 6105
6021 mojo::shell::mojom::InterfaceProviderPtr RenderFrameImpl::ConnectToApplication( 6106 mojo::shell::mojom::InterfaceProviderPtr RenderFrameImpl::ConnectToApplication(
6022 const GURL& url) { 6107 const GURL& url) {
6023 if (!connector_) 6108 if (!connector_)
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
6068 int match_count, 6153 int match_count,
6069 int ordinal, 6154 int ordinal,
6070 const WebRect& selection_rect, 6155 const WebRect& selection_rect,
6071 bool final_status_update) { 6156 bool final_status_update) {
6072 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, 6157 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count,
6073 selection_rect, ordinal, 6158 selection_rect, ordinal,
6074 final_status_update)); 6159 final_status_update));
6075 } 6160 }
6076 6161
6077 } // namespace content 6162 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_frame_impl.h ('k') | content/test/test_navigation_url_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698