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

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

Issue 1568073002: Reduce string copies in GURL creation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mac Created 4 years, 11 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 #include "content/common/frame_messages.h" 50 #include "content/common/frame_messages.h"
51 #include "content/common/frame_replication_state.h" 51 #include "content/common/frame_replication_state.h"
52 #include "content/common/input_messages.h" 52 #include "content/common/input_messages.h"
53 #include "content/common/navigation_params.h" 53 #include "content/common/navigation_params.h"
54 #include "content/common/savable_subframe.h" 54 #include "content/common/savable_subframe.h"
55 #include "content/common/service_worker/service_worker_types.h" 55 #include "content/common/service_worker/service_worker_types.h"
56 #include "content/common/site_isolation_policy.h" 56 #include "content/common/site_isolation_policy.h"
57 #include "content/common/ssl_status_serialization.h" 57 #include "content/common/ssl_status_serialization.h"
58 #include "content/common/swapped_out_messages.h" 58 #include "content/common/swapped_out_messages.h"
59 #include "content/common/view_messages.h" 59 #include "content/common/view_messages.h"
60 #include "content/public/child/url_conversion.h"
60 #include "content/public/common/bindings_policy.h" 61 #include "content/public/common/bindings_policy.h"
61 #include "content/public/common/browser_side_navigation_policy.h" 62 #include "content/public/common/browser_side_navigation_policy.h"
62 #include "content/public/common/content_constants.h" 63 #include "content/public/common/content_constants.h"
63 #include "content/public/common/content_switches.h" 64 #include "content/public/common/content_switches.h"
64 #include "content/public/common/context_menu_params.h" 65 #include "content/public/common/context_menu_params.h"
65 #include "content/public/common/isolated_world_ids.h" 66 #include "content/public/common/isolated_world_ids.h"
66 #include "content/public/common/page_state.h" 67 #include "content/public/common/page_state.h"
67 #include "content/public/common/resource_response.h" 68 #include "content/public/common/resource_response.h"
68 #include "content/public/common/url_constants.h" 69 #include "content/public/common/url_constants.h"
69 #include "content/public/common/url_utils.h" 70 #include "content/public/common/url_utils.h"
(...skipping 2228 matching lines...) Expand 10 before | Expand all | Expand 10 after
2298 ->CreateBrowserPluginDelegate(this, kBrowserPluginMimeType, 2299 ->CreateBrowserPluginDelegate(this, kBrowserPluginMimeType,
2299 GURL(params.url)) 2300 GURL(params.url))
2300 ->GetWeakPtr()); 2301 ->GetWeakPtr());
2301 } 2302 }
2302 2303
2303 #if defined(ENABLE_PLUGINS) 2304 #if defined(ENABLE_PLUGINS)
2304 WebPluginInfo info; 2305 WebPluginInfo info;
2305 std::string mime_type; 2306 std::string mime_type;
2306 bool found = false; 2307 bool found = false;
2307 WebString top_origin = frame->top()->securityOrigin().toString(); 2308 WebString top_origin = frame->top()->securityOrigin().toString();
2308 Send(new FrameHostMsg_GetPluginInfo(routing_id_, params.url, GURL(top_origin), 2309 Send(new FrameHostMsg_GetPluginInfo(routing_id_, params.url,
2310 WebStringToGURL(top_origin),
2309 params.mimeType.utf8(), &found, &info, 2311 params.mimeType.utf8(), &found, &info,
2310 &mime_type)); 2312 &mime_type));
2311 if (!found) 2313 if (!found)
2312 return NULL; 2314 return NULL;
2313 2315
2314 WebPluginParams params_to_use = params; 2316 WebPluginParams params_to_use = params;
2315 params_to_use.mimeType = WebString::fromUTF8(mime_type); 2317 params_to_use.mimeType = WebString::fromUTF8(mime_type);
2316 return CreatePlugin(frame, info, params_to_use, nullptr /* throttler */); 2318 return CreatePlugin(frame, info, params_to_use, nullptr /* throttler */);
2317 #else 2319 #else
2318 return NULL; 2320 return NULL;
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
2804 // DocumentState::referred_by_prefetcher_ is true if we are 2806 // DocumentState::referred_by_prefetcher_ is true if we are
2805 // navigating from a page that used prefetching using a link on that 2807 // navigating from a page that used prefetching using a link on that
2806 // page. We are early enough in the request process here that we 2808 // page. We are early enough in the request process here that we
2807 // can still see the DocumentState of the previous page and set 2809 // can still see the DocumentState of the previous page and set
2808 // this value appropriately. 2810 // this value appropriately.
2809 // TODO(gavinp): catch the important case of navigation in a new 2811 // TODO(gavinp): catch the important case of navigation in a new
2810 // renderer process. 2812 // renderer process.
2811 if (webview) { 2813 if (webview) {
2812 if (WebFrame* old_frame = webview->mainFrame()) { 2814 if (WebFrame* old_frame = webview->mainFrame()) {
2813 const WebURLRequest& original_request = datasource->originalRequest(); 2815 const WebURLRequest& original_request = datasource->originalRequest();
2814 const GURL referrer( 2816 const GURL referrer(WebStringToGURL(
2815 original_request.httpHeaderField(WebString::fromUTF8("Referer"))); 2817 original_request.httpHeaderField(WebString::fromUTF8("Referer"))));
2816 if (!referrer.is_empty() && old_frame->isWebLocalFrame() && 2818 if (!referrer.is_empty() && old_frame->isWebLocalFrame() &&
2817 DocumentState::FromDataSource(old_frame->dataSource()) 2819 DocumentState::FromDataSource(old_frame->dataSource())
2818 ->was_prefetcher()) { 2820 ->was_prefetcher()) {
2819 for (; old_frame; old_frame = old_frame->traverseNext(false)) { 2821 for (; old_frame; old_frame = old_frame->traverseNext(false)) {
2820 WebDataSource* old_frame_datasource = old_frame->dataSource(); 2822 WebDataSource* old_frame_datasource = old_frame->dataSource();
2821 if (old_frame_datasource && 2823 if (old_frame_datasource &&
2822 referrer == GURL(old_frame_datasource->request().url())) { 2824 referrer == GURL(old_frame_datasource->request().url())) {
2823 document_state->set_was_referred_by_prefetcher(true); 2825 document_state->set_was_referred_by_prefetcher(true);
2824 break; 2826 break;
2825 } 2827 }
(...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after
3673 WebFrame* parent = frame->parent(); 3675 WebFrame* parent = frame->parent();
3674 int parent_routing_id = parent ? GetRoutingIdForFrameOrProxy(parent) : -1; 3676 int parent_routing_id = parent ? GetRoutingIdForFrameOrProxy(parent) : -1;
3675 3677
3676 RequestExtraData* extra_data = new RequestExtraData(); 3678 RequestExtraData* extra_data = new RequestExtraData();
3677 extra_data->set_visibility_state(render_view_->visibilityState()); 3679 extra_data->set_visibility_state(render_view_->visibilityState());
3678 extra_data->set_custom_user_agent(custom_user_agent); 3680 extra_data->set_custom_user_agent(custom_user_agent);
3679 extra_data->set_requested_with(requested_with); 3681 extra_data->set_requested_with(requested_with);
3680 extra_data->set_render_frame_id(routing_id_); 3682 extra_data->set_render_frame_id(routing_id_);
3681 extra_data->set_is_main_frame(!parent); 3683 extra_data->set_is_main_frame(!parent);
3682 extra_data->set_frame_origin( 3684 extra_data->set_frame_origin(
3683 GURL(frame->document().securityOrigin().toString())); 3685 WebStringToGURL(frame->document().securityOrigin().toString()));
3684 extra_data->set_parent_is_main_frame(parent && !parent->parent()); 3686 extra_data->set_parent_is_main_frame(parent && !parent->parent());
3685 extra_data->set_parent_render_frame_id(parent_routing_id); 3687 extra_data->set_parent_render_frame_id(parent_routing_id);
3686 extra_data->set_allow_download( 3688 extra_data->set_allow_download(
3687 navigation_state->common_params().allow_download); 3689 navigation_state->common_params().allow_download);
3688 extra_data->set_transition_type(transition_type); 3690 extra_data->set_transition_type(transition_type);
3689 extra_data->set_should_replace_current_entry(should_replace_current_entry); 3691 extra_data->set_should_replace_current_entry(should_replace_current_entry);
3690 extra_data->set_transferred_request_child_id( 3692 extra_data->set_transferred_request_child_id(
3691 navigation_state->start_params().transferred_request_child_id); 3693 navigation_state->start_params().transferred_request_child_id);
3692 extra_data->set_transferred_request_request_id( 3694 extra_data->set_transferred_request_request_id(
3693 navigation_state->start_params().transferred_request_request_id); 3695 navigation_state->start_params().transferred_request_request_id);
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
3916 blink::WebStorageQuotaCallbacks callbacks) { 3918 blink::WebStorageQuotaCallbacks callbacks) {
3917 DCHECK(!frame_ || frame_ == frame); 3919 DCHECK(!frame_ || frame_ == frame);
3918 WebSecurityOrigin origin = frame->document().securityOrigin(); 3920 WebSecurityOrigin origin = frame->document().securityOrigin();
3919 if (origin.isUnique()) { 3921 if (origin.isUnique()) {
3920 // Unique origins cannot store persistent state. 3922 // Unique origins cannot store persistent state.
3921 callbacks.didFail(blink::WebStorageQuotaErrorAbort); 3923 callbacks.didFail(blink::WebStorageQuotaErrorAbort);
3922 return; 3924 return;
3923 } 3925 }
3924 ChildThreadImpl::current()->quota_dispatcher()->RequestStorageQuota( 3926 ChildThreadImpl::current()->quota_dispatcher()->RequestStorageQuota(
3925 render_view_->GetRoutingID(), 3927 render_view_->GetRoutingID(),
3926 GURL(origin.toString()), 3928 WebStringToGURL(origin.toString()),
3927 static_cast<storage::StorageType>(type), 3929 static_cast<storage::StorageType>(type),
3928 requested_size, 3930 requested_size,
3929 QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper(callbacks)); 3931 QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper(callbacks));
3930 } 3932 }
3931 3933
3932 void RenderFrameImpl::willOpenWebSocket(blink::WebSocketHandle* handle) { 3934 void RenderFrameImpl::willOpenWebSocket(blink::WebSocketHandle* handle) {
3933 WebSocketBridge* impl = static_cast<WebSocketBridge*>(handle); 3935 WebSocketBridge* impl = static_cast<WebSocketBridge*>(handle);
3934 impl->set_render_frame_id(routing_id_); 3936 impl->set_render_frame_id(routing_id_);
3935 } 3937 }
3936 3938
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
4070 4072
4071 bool RenderFrameImpl::allowWebGL(blink::WebLocalFrame* frame, 4073 bool RenderFrameImpl::allowWebGL(blink::WebLocalFrame* frame,
4072 bool default_value) { 4074 bool default_value) {
4073 DCHECK(!frame_ || frame_ == frame); 4075 DCHECK(!frame_ || frame_ == frame);
4074 if (!default_value) 4076 if (!default_value)
4075 return false; 4077 return false;
4076 4078
4077 bool blocked = true; 4079 bool blocked = true;
4078 Send(new FrameHostMsg_Are3DAPIsBlocked( 4080 Send(new FrameHostMsg_Are3DAPIsBlocked(
4079 routing_id_, 4081 routing_id_,
4080 GURL(frame->top()->securityOrigin().toString()), 4082 WebStringToGURL(frame->top()->securityOrigin().toString()),
4081 THREE_D_API_TYPE_WEBGL, 4083 THREE_D_API_TYPE_WEBGL,
4082 &blocked)); 4084 &blocked));
4083 return !blocked; 4085 return !blocked;
4084 } 4086 }
4085 4087
4086 void RenderFrameImpl::didLoseWebGLContext(blink::WebLocalFrame* frame, 4088 void RenderFrameImpl::didLoseWebGLContext(blink::WebLocalFrame* frame,
4087 int arb_robustness_status_code) { 4089 int arb_robustness_status_code) {
4088 DCHECK(!frame_ || frame_ == frame); 4090 DCHECK(!frame_ || frame_ == frame);
4089 Send(new FrameHostMsg_DidLose3DContext( 4091 Send(new FrameHostMsg_DidLose3DContext(
4090 GURL(frame->top()->securityOrigin().toString()), 4092 WebStringToGURL(frame->top()->securityOrigin().toString()),
4091 THREE_D_API_TYPE_WEBGL, 4093 THREE_D_API_TYPE_WEBGL,
4092 arb_robustness_status_code)); 4094 arb_robustness_status_code));
4093 } 4095 }
4094 4096
4095 blink::WebScreenOrientationClient* 4097 blink::WebScreenOrientationClient*
4096 RenderFrameImpl::webScreenOrientationClient() { 4098 RenderFrameImpl::webScreenOrientationClient() {
4097 if (!screen_orientation_dispatcher_) 4099 if (!screen_orientation_dispatcher_)
4098 screen_orientation_dispatcher_ = new ScreenOrientationDispatcher(this); 4100 screen_orientation_dispatcher_ = new ScreenOrientationDispatcher(this);
4099 return screen_orientation_dispatcher_; 4101 return screen_orientation_dispatcher_;
4100 } 4102 }
(...skipping 1583 matching lines...) Expand 10 before | Expand all | Expand 10 after
5684 media::ConvertToSwitchOutputDeviceCB(web_callbacks); 5686 media::ConvertToSwitchOutputDeviceCB(web_callbacks);
5685 scoped_refptr<media::AudioOutputDevice> device = 5687 scoped_refptr<media::AudioOutputDevice> device =
5686 AudioDeviceFactory::NewOutputDevice(routing_id_, 0, sink_id.utf8(), 5688 AudioDeviceFactory::NewOutputDevice(routing_id_, 0, sink_id.utf8(),
5687 security_origin); 5689 security_origin);
5688 media::OutputDeviceStatus status = device->GetDeviceStatus(); 5690 media::OutputDeviceStatus status = device->GetDeviceStatus();
5689 device->Stop(); 5691 device->Stop();
5690 callback.Run(status); 5692 callback.Run(status);
5691 } 5693 }
5692 5694
5693 } // namespace content 5695 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698