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

Side by Side Diff: content/browser/frame_host/render_frame_host_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: Created 4 years, 10 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 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/render_frame_host_impl.h" 5 #include "content/browser/frame_host/render_frame_host_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/containers/hash_tables.h" 10 #include "base/containers/hash_tables.h"
(...skipping 1901 matching lines...) Expand 10 before | Expand all | Expand 10 after
1912 1912
1913 void RenderFrameHostImpl::NavigateToInterstitialURL(const GURL& data_url) { 1913 void RenderFrameHostImpl::NavigateToInterstitialURL(const GURL& data_url) {
1914 DCHECK(data_url.SchemeIs(url::kDataScheme)); 1914 DCHECK(data_url.SchemeIs(url::kDataScheme));
1915 CommonNavigationParams common_params( 1915 CommonNavigationParams common_params(
1916 data_url, Referrer(), ui::PAGE_TRANSITION_LINK, 1916 data_url, Referrer(), ui::PAGE_TRANSITION_LINK,
1917 FrameMsg_Navigate_Type::NORMAL, false, false, base::TimeTicks::Now(), 1917 FrameMsg_Navigate_Type::NORMAL, false, false, base::TimeTicks::Now(),
1918 FrameMsg_UILoadMetricsReportType::NO_REPORT, GURL(), GURL(), LOFI_OFF, 1918 FrameMsg_UILoadMetricsReportType::NO_REPORT, GURL(), GURL(), LOFI_OFF,
1919 base::TimeTicks::Now()); 1919 base::TimeTicks::Now());
1920 if (IsBrowserSideNavigationEnabled()) { 1920 if (IsBrowserSideNavigationEnabled()) {
1921 CommitNavigation(nullptr, nullptr, common_params, 1921 CommitNavigation(nullptr, nullptr, common_params,
1922 RequestNavigationParams()); 1922 RequestNavigationParams(), mojo::ScopedDataPipeConsumerHand le());
1923 } else { 1923 } else {
1924 Navigate(common_params, StartNavigationParams(), RequestNavigationParams()); 1924 Navigate(common_params, StartNavigationParams(), RequestNavigationParams());
1925 } 1925 }
1926 } 1926 }
1927 1927
1928 void RenderFrameHostImpl::OpenURL(const FrameHostMsg_OpenURL_Params& params, 1928 void RenderFrameHostImpl::OpenURL(const FrameHostMsg_OpenURL_Params& params,
1929 SiteInstance* source_site_instance) { 1929 SiteInstance* source_site_instance) {
1930 GURL validated_url(params.url); 1930 GURL validated_url(params.url);
1931 GetProcess()->FilterURL(false, &validated_url); 1931 GetProcess()->FilterURL(false, &validated_url);
1932 1932
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
2042 render_view_host_->GetWidget()->delegate()->RendererUnresponsive( 2042 render_view_host_->GetWidget()->delegate()->RendererUnresponsive(
2043 render_view_host_->GetWidget()); 2043 render_view_host_->GetWidget());
2044 } 2044 }
2045 } 2045 }
2046 2046
2047 // PlzNavigate 2047 // PlzNavigate
2048 void RenderFrameHostImpl::CommitNavigation( 2048 void RenderFrameHostImpl::CommitNavigation(
2049 ResourceResponse* response, 2049 ResourceResponse* response,
2050 scoped_ptr<StreamHandle> body, 2050 scoped_ptr<StreamHandle> body,
2051 const CommonNavigationParams& common_params, 2051 const CommonNavigationParams& common_params,
2052 const RequestNavigationParams& request_params) { 2052 const RequestNavigationParams& request_params,
2053 DCHECK((response && body.get()) || 2053 mojo::ScopedDataPipeConsumerHandle data_consumer_handle = mojo::ScopedDataPi peConsumerHandle()) {
2054 DCHECK((response && (body.get() || data_consumer_handle.is_valid())) ||
2054 !ShouldMakeNetworkRequestForURL(common_params.url)); 2055 !ShouldMakeNetworkRequestForURL(common_params.url));
2055 UpdatePermissionsForNavigation(common_params, request_params); 2056 UpdatePermissionsForNavigation(common_params, request_params);
2056 2057
2057 // Get back to a clean state, in case we start a new navigation without 2058 // Get back to a clean state, in case we start a new navigation without
2058 // completing a RFH swap or unload handler. 2059 // completing a RFH swap or unload handler.
2059 SetState(RenderFrameHostImpl::STATE_DEFAULT); 2060 SetState(RenderFrameHostImpl::STATE_DEFAULT);
2060 2061
2062 // SENDS THE CONSUMER DATA HANDLE TO THE RENDERER VIA MOJO
2063 // TODO: OPTIMIZE THIS
2064 // - SEE IF THERE'S A WAY TO BIND THE SERVER EARLIER THEN THIS. Is there a
2065 // notification received by the browser that a RenderFrame was created on the renderer?
2066 // - POSSIBLY STORE THE REFERENCE SOMEWHERE... IS THAT EVEN NEEDED OR IS MOJO
2067 // SMART ABOUT CACHING BOUND REMOTE REFERENCES?
2068 int32_t current_commit_id = -1;
2069 if (data_consumer_handle.is_valid()) {
2070 static int32_t commit_id = 0;
2071 DataPipeConsumerHandleReceiverPtr consumer_receiver;
2072 GetServiceRegistry()->ConnectToRemoteService(mojo::GetProxy(&consumer_receiv er));
2073 current_commit_id = ++commit_id;
2074 consumer_receiver->ReceiveDataPipeConsumerHandle(
2075 std::move(data_consumer_handle), current_commit_id);
2076 }
2077
2061 const GURL body_url = body.get() ? body->GetURL() : GURL(); 2078 const GURL body_url = body.get() ? body->GetURL() : GURL();
2062 const ResourceResponseHead head = response ? 2079 const ResourceResponseHead head = response ?
2063 response->head : ResourceResponseHead(); 2080 response->head : ResourceResponseHead();
2064 Send(new FrameMsg_CommitNavigation(routing_id_, head, body_url, common_params, 2081 Send(new FrameMsg_CommitNavigation(routing_id_, head, body_url, common_params,
2065 request_params)); 2082 request_params, current_commit_id));
2066 2083
2067 // TODO(clamy): Release the stream handle once the renderer has finished 2084 // TODO(clamy): Release the stream handle once the renderer has finished
2068 // reading it. 2085 // reading it.
2069 stream_handle_ = std::move(body); 2086 stream_handle_ = std::move(body);
2070 2087
2071 // When navigating to a Javascript url, no commit is expected from the 2088 // When navigating to a Javascript url, no commit is expected from the
2072 // RenderFrameHost, nor should the throbber start. 2089 // RenderFrameHost, nor should the throbber start.
2073 if (!common_params.url.SchemeIs(url::kJavaScriptScheme)) { 2090 if (!common_params.url.SchemeIs(url::kJavaScriptScheme)) {
2074 pending_commit_ = true; 2091 pending_commit_ = true;
2075 is_loading_ = true; 2092 is_loading_ = true;
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
2553 *dst = src; 2570 *dst = src;
2554 2571
2555 if (src.routing_id != -1) 2572 if (src.routing_id != -1)
2556 dst->tree_id = RoutingIDToAXTreeID(src.routing_id); 2573 dst->tree_id = RoutingIDToAXTreeID(src.routing_id);
2557 2574
2558 if (src.parent_routing_id != -1) 2575 if (src.parent_routing_id != -1)
2559 dst->parent_tree_id = RoutingIDToAXTreeID(src.parent_routing_id); 2576 dst->parent_tree_id = RoutingIDToAXTreeID(src.parent_routing_id);
2560 } 2577 }
2561 2578
2562 } // namespace content 2579 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698