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

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

Issue 2932453002: PlzNavigate: Release StreamHandle. (Closed)
Patch Set: Experiment: Use a RenderFrameObserver. Created 3 years, 6 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/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 5108 matching lines...) Expand 10 before | Expand all | Expand 10 after
5119 5119
5120 for (auto& observer : observers_) 5120 for (auto& observer : observers_)
5121 observer.FocusedNodeChanged(node); 5121 observer.FocusedNodeChanged(node);
5122 } 5122 }
5123 5123
5124 void RenderFrameImpl::FocusedNodeChangedForAccessibility(const WebNode& node) { 5124 void RenderFrameImpl::FocusedNodeChangedForAccessibility(const WebNode& node) {
5125 if (render_accessibility()) 5125 if (render_accessibility())
5126 render_accessibility()->AccessibilityFocusedNodeChanged(node); 5126 render_accessibility()->AccessibilityFocusedNodeChanged(node);
5127 } 5127 }
5128 5128
5129 // PlzNavigate: Used to delete the StreamHandle that live on the browser side.
5130 class StreamHandleDeleter : public RenderFrameObserver {
5131 public:
5132 StreamHandleDeleter(RenderFrame* render_frame)
5133 : RenderFrameObserver(render_frame) {}
5134 void OnDestruct() override {}
5135 void OnStreamHandleConsumed(const GURL& stream_handle_url) {
5136 if (!render_frame())
5137 return;
5138 static_cast<RenderFrameImpl*>(render_frame())
5139 ->StreamHandleConsumed(stream_handle_url);
5140 }
5141 };
5142
5129 // PlzNavigate 5143 // PlzNavigate
5130 void RenderFrameImpl::OnCommitNavigation( 5144 void RenderFrameImpl::OnCommitNavigation(
5131 const ResourceResponseHead& response, 5145 const ResourceResponseHead& response,
5132 const GURL& stream_url, 5146 const GURL& stream_url,
5133 const FrameMsg_CommitDataNetworkService_Params& commit_data, 5147 const FrameMsg_CommitDataNetworkService_Params& commit_data,
5134 const CommonNavigationParams& common_params, 5148 const CommonNavigationParams& common_params,
5135 const RequestNavigationParams& request_params) { 5149 const RequestNavigationParams& request_params) {
5136 CHECK(IsBrowserSideNavigationEnabled()); 5150 CHECK(IsBrowserSideNavigationEnabled());
5137 // This will override the url requested by the WebURLLoader, as well as 5151 // This will override the url requested by the WebURLLoader, as well as
5138 // provide it with the response to the request. 5152 // provide it with the response to the request.
5139 std::unique_ptr<StreamOverrideParameters> stream_override( 5153 std::unique_ptr<StreamOverrideParameters> stream_override(
5140 new StreamOverrideParameters()); 5154 new StreamOverrideParameters());
5141 stream_override->stream_url = stream_url; 5155 stream_override->stream_url = stream_url;
5142 stream_override->consumer_handle = 5156 stream_override->consumer_handle =
5143 mojo::ScopedDataPipeConsumerHandle(commit_data.handle); 5157 mojo::ScopedDataPipeConsumerHandle(commit_data.handle);
5144 stream_override->response = response; 5158 stream_override->response = response;
5145 stream_override->redirects = request_params.redirects; 5159 stream_override->redirects = request_params.redirects;
5146 stream_override->redirect_responses = request_params.redirect_response; 5160 stream_override->redirect_responses = request_params.redirect_response;
5147 stream_override->redirect_infos = request_params.redirect_infos; 5161 stream_override->redirect_infos = request_params.redirect_infos;
5148 5162
5163 // PlzNavigate: Notify the browser that it can released its |stream_handle_|
5164 // when the |stream_override| object is no more used. This is a temporary
5165 // solution until mojo is used.
5166 stream_override->on_delete = base::BindOnce(
5167 [](std::unique_ptr<StreamHandleDeleter> stream_handle_deleter,
5168 const GURL& url) {
5169 stream_handle_deleter->OnStreamHandleConsumed(url);
clamy 2017/06/09 14:57:42 Why not binding the RenderFrameImpl directly with
arthursonzogni 2017/06/12 09:30:15 I thought base::weak_ptr was sort of the the same
5170 },
5171 base::MakeUnique<StreamHandleDeleter>(this));
5172
5149 if (commit_data.url_loader_factory.is_valid()) { 5173 if (commit_data.url_loader_factory.is_valid()) {
5150 // Chrome doesn't use interface versioning. 5174 // Chrome doesn't use interface versioning.
5151 url_loader_factory_.Bind(mojom::URLLoaderFactoryPtrInfo( 5175 url_loader_factory_.Bind(mojom::URLLoaderFactoryPtrInfo(
5152 mojo::ScopedMessagePipeHandle(commit_data.url_loader_factory), 0u)); 5176 mojo::ScopedMessagePipeHandle(commit_data.url_loader_factory), 0u));
5153 } 5177 }
5154 5178
5155 // If the request was initiated in the context of a user gesture then make 5179 // If the request was initiated in the context of a user gesture then make
5156 // sure that the navigation also executes in the context of a user gesture. 5180 // sure that the navigation also executes in the context of a user gesture.
5157 std::unique_ptr<blink::WebScopedUserGesture> gesture( 5181 std::unique_ptr<blink::WebScopedUserGesture> gesture(
5158 request_params.has_user_gesture ? new blink::WebScopedUserGesture(frame_) 5182 request_params.has_user_gesture ? new blink::WebScopedUserGesture(frame_)
(...skipping 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after
6242 selection_range_ != range || 6266 selection_range_ != range ||
6243 selection_text_ != text) { 6267 selection_text_ != text) {
6244 selection_text_ = text; 6268 selection_text_ = text;
6245 selection_text_offset_ = offset; 6269 selection_text_offset_ = offset;
6246 selection_range_ = range; 6270 selection_range_ = range;
6247 SetSelectedText(text, offset, range); 6271 SetSelectedText(text, offset, range);
6248 } 6272 }
6249 GetRenderWidget()->UpdateSelectionBounds(); 6273 GetRenderWidget()->UpdateSelectionBounds();
6250 } 6274 }
6251 6275
6276 void RenderFrameImpl::StreamHandleConsumed(const GURL& stream_url) {
6277 Send(new FrameHostMsg_StreamHandleConsumed(routing_id_, stream_url));
6278 }
6279
6252 void RenderFrameImpl::InitializeUserMediaClient() { 6280 void RenderFrameImpl::InitializeUserMediaClient() {
6253 RenderThreadImpl* render_thread = RenderThreadImpl::current(); 6281 RenderThreadImpl* render_thread = RenderThreadImpl::current();
6254 if (!render_thread) // Will be NULL during unit tests. 6282 if (!render_thread) // Will be NULL during unit tests.
6255 return; 6283 return;
6256 6284
6257 #if BUILDFLAG(ENABLE_WEBRTC) 6285 #if BUILDFLAG(ENABLE_WEBRTC)
6258 DCHECK(!web_user_media_client_); 6286 DCHECK(!web_user_media_client_);
6259 web_user_media_client_ = new UserMediaClientImpl( 6287 web_user_media_client_ = new UserMediaClientImpl(
6260 this, RenderThreadImpl::current()->GetPeerConnectionDependencyFactory(), 6288 this, RenderThreadImpl::current()->GetPeerConnectionDependencyFactory(),
6261 base::MakeUnique<MediaStreamDispatcher>(this), 6289 base::MakeUnique<MediaStreamDispatcher>(this),
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
6858 policy(info.default_policy), 6886 policy(info.default_policy),
6859 replaces_current_history_item(info.replaces_current_history_item), 6887 replaces_current_history_item(info.replaces_current_history_item),
6860 history_navigation_in_new_child_frame( 6888 history_navigation_in_new_child_frame(
6861 info.is_history_navigation_in_new_child_frame), 6889 info.is_history_navigation_in_new_child_frame),
6862 client_redirect(info.is_client_redirect), 6890 client_redirect(info.is_client_redirect),
6863 cache_disabled(info.is_cache_disabled), 6891 cache_disabled(info.is_cache_disabled),
6864 form(info.form), 6892 form(info.form),
6865 source_location(info.source_location) {} 6893 source_location(info.source_location) {}
6866 6894
6867 } // namespace content 6895 } // namespace content
OLDNEW
« content/browser/frame_host/render_frame_host_impl.h ('K') | « content/renderer/render_frame_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698