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

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: 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 #include "media/base/media_switches.h" 138 #include "media/base/media_switches.h"
139 #include "media/blink/url_index.h" 139 #include "media/blink/url_index.h"
140 #include "media/blink/webencryptedmediaclient_impl.h" 140 #include "media/blink/webencryptedmediaclient_impl.h"
141 #include "media/blink/webmediaplayer_impl.h" 141 #include "media/blink/webmediaplayer_impl.h"
142 #include "media/renderers/gpu_video_accelerator_factories.h" 142 #include "media/renderers/gpu_video_accelerator_factories.h"
143 #include "mojo/common/url_type_converters.h" 143 #include "mojo/common/url_type_converters.h"
144 #include "net/base/data_url.h" 144 #include "net/base/data_url.h"
145 #include "net/base/net_errors.h" 145 #include "net/base/net_errors.h"
146 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 146 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
147 #include "net/http/http_util.h" 147 #include "net/http/http_util.h"
148 #include "third_party/WebKit/public/platform/URLConversion.h"
148 #include "third_party/WebKit/public/platform/WebData.h" 149 #include "third_party/WebKit/public/platform/WebData.h"
149 #include "third_party/WebKit/public/platform/WebStorageQuotaCallbacks.h" 150 #include "third_party/WebKit/public/platform/WebStorageQuotaCallbacks.h"
150 #include "third_party/WebKit/public/platform/WebString.h" 151 #include "third_party/WebKit/public/platform/WebString.h"
151 #include "third_party/WebKit/public/platform/WebURL.h" 152 #include "third_party/WebKit/public/platform/WebURL.h"
152 #include "third_party/WebKit/public/platform/WebURLError.h" 153 #include "third_party/WebKit/public/platform/WebURLError.h"
153 #include "third_party/WebKit/public/platform/WebURLResponse.h" 154 #include "third_party/WebKit/public/platform/WebURLResponse.h"
154 #include "third_party/WebKit/public/platform/WebVector.h" 155 #include "third_party/WebKit/public/platform/WebVector.h"
155 #include "third_party/WebKit/public/platform/modules/webusb/WebUSBClient.h" 156 #include "third_party/WebKit/public/platform/modules/webusb/WebUSBClient.h"
156 #include "third_party/WebKit/public/web/WebColorSuggestion.h" 157 #include "third_party/WebKit/public/web/WebColorSuggestion.h"
157 #include "third_party/WebKit/public/web/WebDocument.h" 158 #include "third_party/WebKit/public/web/WebDocument.h"
(...skipping 2188 matching lines...) Expand 10 before | Expand all | Expand 10 after
2346 ->CreateBrowserPluginDelegate(this, kBrowserPluginMimeType, 2347 ->CreateBrowserPluginDelegate(this, kBrowserPluginMimeType,
2347 GURL(params.url)) 2348 GURL(params.url))
2348 ->GetWeakPtr()); 2349 ->GetWeakPtr());
2349 } 2350 }
2350 2351
2351 #if defined(ENABLE_PLUGINS) 2352 #if defined(ENABLE_PLUGINS)
2352 WebPluginInfo info; 2353 WebPluginInfo info;
2353 std::string mime_type; 2354 std::string mime_type;
2354 bool found = false; 2355 bool found = false;
2355 WebString top_origin = frame->top()->securityOrigin().toString(); 2356 WebString top_origin = frame->top()->securityOrigin().toString();
2356 Send(new FrameHostMsg_GetPluginInfo(routing_id_, params.url, GURL(top_origin), 2357 Send(new FrameHostMsg_GetPluginInfo(routing_id_, params.url,
2358 blink::WebStringToGURL(top_origin),
2357 params.mimeType.utf8(), &found, &info, 2359 params.mimeType.utf8(), &found, &info,
2358 &mime_type)); 2360 &mime_type));
2359 if (!found) 2361 if (!found)
2360 return NULL; 2362 return NULL;
2361 2363
2362 WebPluginParams params_to_use = params; 2364 WebPluginParams params_to_use = params;
2363 params_to_use.mimeType = WebString::fromUTF8(mime_type); 2365 params_to_use.mimeType = WebString::fromUTF8(mime_type);
2364 return CreatePlugin(frame, info, params_to_use, nullptr /* throttler */); 2366 return CreatePlugin(frame, info, params_to_use, nullptr /* throttler */);
2365 #else 2367 #else
2366 return NULL; 2368 return NULL;
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
2874 // DocumentState::referred_by_prefetcher_ is true if we are 2876 // DocumentState::referred_by_prefetcher_ is true if we are
2875 // navigating from a page that used prefetching using a link on that 2877 // navigating from a page that used prefetching using a link on that
2876 // page. We are early enough in the request process here that we 2878 // page. We are early enough in the request process here that we
2877 // can still see the DocumentState of the previous page and set 2879 // can still see the DocumentState of the previous page and set
2878 // this value appropriately. 2880 // this value appropriately.
2879 // TODO(gavinp): catch the important case of navigation in a new 2881 // TODO(gavinp): catch the important case of navigation in a new
2880 // renderer process. 2882 // renderer process.
2881 if (webview) { 2883 if (webview) {
2882 if (WebFrame* old_frame = webview->mainFrame()) { 2884 if (WebFrame* old_frame = webview->mainFrame()) {
2883 const WebURLRequest& original_request = datasource->originalRequest(); 2885 const WebURLRequest& original_request = datasource->originalRequest();
2884 const GURL referrer( 2886 const GURL referrer(blink::WebStringToGURL(
2885 original_request.httpHeaderField(WebString::fromUTF8("Referer"))); 2887 original_request.httpHeaderField(WebString::fromUTF8("Referer"))));
2886 if (!referrer.is_empty() && old_frame->isWebLocalFrame() && 2888 if (!referrer.is_empty() && old_frame->isWebLocalFrame() &&
2887 DocumentState::FromDataSource(old_frame->dataSource()) 2889 DocumentState::FromDataSource(old_frame->dataSource())
2888 ->was_prefetcher()) { 2890 ->was_prefetcher()) {
2889 for (; old_frame; old_frame = old_frame->traverseNext(false)) { 2891 for (; old_frame; old_frame = old_frame->traverseNext(false)) {
2890 WebDataSource* old_frame_datasource = old_frame->dataSource(); 2892 WebDataSource* old_frame_datasource = old_frame->dataSource();
2891 if (old_frame_datasource && 2893 if (old_frame_datasource &&
2892 referrer == GURL(old_frame_datasource->request().url())) { 2894 referrer == GURL(old_frame_datasource->request().url())) {
2893 document_state->set_was_referred_by_prefetcher(true); 2895 document_state->set_was_referred_by_prefetcher(true);
2894 break; 2896 break;
2895 } 2897 }
(...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after
3748 WebFrame* parent = frame->parent(); 3750 WebFrame* parent = frame->parent();
3749 int parent_routing_id = parent ? GetRoutingIdForFrameOrProxy(parent) : -1; 3751 int parent_routing_id = parent ? GetRoutingIdForFrameOrProxy(parent) : -1;
3750 3752
3751 RequestExtraData* extra_data = new RequestExtraData(); 3753 RequestExtraData* extra_data = new RequestExtraData();
3752 extra_data->set_visibility_state(render_view_->visibilityState()); 3754 extra_data->set_visibility_state(render_view_->visibilityState());
3753 extra_data->set_custom_user_agent(custom_user_agent); 3755 extra_data->set_custom_user_agent(custom_user_agent);
3754 extra_data->set_requested_with(requested_with); 3756 extra_data->set_requested_with(requested_with);
3755 extra_data->set_render_frame_id(routing_id_); 3757 extra_data->set_render_frame_id(routing_id_);
3756 extra_data->set_is_main_frame(!parent); 3758 extra_data->set_is_main_frame(!parent);
3757 extra_data->set_frame_origin( 3759 extra_data->set_frame_origin(
3758 GURL(frame->document().securityOrigin().toString())); 3760 blink::WebStringToGURL(frame->document().securityOrigin().toString()));
3759 extra_data->set_parent_is_main_frame(parent && !parent->parent()); 3761 extra_data->set_parent_is_main_frame(parent && !parent->parent());
3760 extra_data->set_parent_render_frame_id(parent_routing_id); 3762 extra_data->set_parent_render_frame_id(parent_routing_id);
3761 extra_data->set_allow_download( 3763 extra_data->set_allow_download(
3762 navigation_state->common_params().allow_download); 3764 navigation_state->common_params().allow_download);
3763 extra_data->set_transition_type(transition_type); 3765 extra_data->set_transition_type(transition_type);
3764 extra_data->set_should_replace_current_entry(should_replace_current_entry); 3766 extra_data->set_should_replace_current_entry(should_replace_current_entry);
3765 extra_data->set_transferred_request_child_id( 3767 extra_data->set_transferred_request_child_id(
3766 navigation_state->start_params().transferred_request_child_id); 3768 navigation_state->start_params().transferred_request_child_id);
3767 extra_data->set_transferred_request_request_id( 3769 extra_data->set_transferred_request_request_id(
3768 navigation_state->start_params().transferred_request_request_id); 3770 navigation_state->start_params().transferred_request_request_id);
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
3991 blink::WebStorageQuotaCallbacks callbacks) { 3993 blink::WebStorageQuotaCallbacks callbacks) {
3992 DCHECK(!frame_ || frame_ == frame); 3994 DCHECK(!frame_ || frame_ == frame);
3993 WebSecurityOrigin origin = frame->document().securityOrigin(); 3995 WebSecurityOrigin origin = frame->document().securityOrigin();
3994 if (origin.isUnique()) { 3996 if (origin.isUnique()) {
3995 // Unique origins cannot store persistent state. 3997 // Unique origins cannot store persistent state.
3996 callbacks.didFail(blink::WebStorageQuotaErrorAbort); 3998 callbacks.didFail(blink::WebStorageQuotaErrorAbort);
3997 return; 3999 return;
3998 } 4000 }
3999 ChildThreadImpl::current()->quota_dispatcher()->RequestStorageQuota( 4001 ChildThreadImpl::current()->quota_dispatcher()->RequestStorageQuota(
4000 render_view_->GetRoutingID(), 4002 render_view_->GetRoutingID(),
4001 GURL(origin.toString()), 4003 blink::WebStringToGURL(origin.toString()),
4002 static_cast<storage::StorageType>(type), 4004 static_cast<storage::StorageType>(type),
4003 requested_size, 4005 requested_size,
4004 QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper(callbacks)); 4006 QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper(callbacks));
4005 } 4007 }
4006 4008
4007 void RenderFrameImpl::willOpenWebSocket(blink::WebSocketHandle* handle) { 4009 void RenderFrameImpl::willOpenWebSocket(blink::WebSocketHandle* handle) {
4008 WebSocketBridge* impl = static_cast<WebSocketBridge*>(handle); 4010 WebSocketBridge* impl = static_cast<WebSocketBridge*>(handle);
4009 impl->set_render_frame_id(routing_id_); 4011 impl->set_render_frame_id(routing_id_);
4010 } 4012 }
4011 4013
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
4145 4147
4146 bool RenderFrameImpl::allowWebGL(blink::WebLocalFrame* frame, 4148 bool RenderFrameImpl::allowWebGL(blink::WebLocalFrame* frame,
4147 bool default_value) { 4149 bool default_value) {
4148 DCHECK(!frame_ || frame_ == frame); 4150 DCHECK(!frame_ || frame_ == frame);
4149 if (!default_value) 4151 if (!default_value)
4150 return false; 4152 return false;
4151 4153
4152 bool blocked = true; 4154 bool blocked = true;
4153 Send(new FrameHostMsg_Are3DAPIsBlocked( 4155 Send(new FrameHostMsg_Are3DAPIsBlocked(
4154 routing_id_, 4156 routing_id_,
4155 GURL(frame->top()->securityOrigin().toString()), 4157 blink::WebStringToGURL(frame->top()->securityOrigin().toString()),
4156 THREE_D_API_TYPE_WEBGL, 4158 THREE_D_API_TYPE_WEBGL,
4157 &blocked)); 4159 &blocked));
4158 return !blocked; 4160 return !blocked;
4159 } 4161 }
4160 4162
4161 void RenderFrameImpl::didLoseWebGLContext(blink::WebLocalFrame* frame, 4163 void RenderFrameImpl::didLoseWebGLContext(blink::WebLocalFrame* frame,
4162 int arb_robustness_status_code) { 4164 int arb_robustness_status_code) {
4163 DCHECK(!frame_ || frame_ == frame); 4165 DCHECK(!frame_ || frame_ == frame);
4164 Send(new FrameHostMsg_DidLose3DContext( 4166 Send(new FrameHostMsg_DidLose3DContext(
4165 GURL(frame->top()->securityOrigin().toString()), 4167 blink::WebStringToGURL(frame->top()->securityOrigin().toString()),
4166 THREE_D_API_TYPE_WEBGL, 4168 THREE_D_API_TYPE_WEBGL,
4167 arb_robustness_status_code)); 4169 arb_robustness_status_code));
4168 } 4170 }
4169 4171
4170 blink::WebScreenOrientationClient* 4172 blink::WebScreenOrientationClient*
4171 RenderFrameImpl::webScreenOrientationClient() { 4173 RenderFrameImpl::webScreenOrientationClient() {
4172 if (!screen_orientation_dispatcher_) 4174 if (!screen_orientation_dispatcher_)
4173 screen_orientation_dispatcher_ = new ScreenOrientationDispatcher(this); 4175 screen_orientation_dispatcher_ = new ScreenOrientationDispatcher(this);
4174 return screen_orientation_dispatcher_; 4176 return screen_orientation_dispatcher_;
4175 } 4177 }
(...skipping 1591 matching lines...) Expand 10 before | Expand all | Expand 10 after
5767 media::ConvertToSwitchOutputDeviceCB(web_callbacks); 5769 media::ConvertToSwitchOutputDeviceCB(web_callbacks);
5768 scoped_refptr<media::AudioOutputDevice> device = 5770 scoped_refptr<media::AudioOutputDevice> device =
5769 AudioDeviceFactory::NewOutputDevice(routing_id_, 0, sink_id.utf8(), 5771 AudioDeviceFactory::NewOutputDevice(routing_id_, 0, sink_id.utf8(),
5770 security_origin); 5772 security_origin);
5771 media::OutputDeviceStatus status = device->GetDeviceStatus(); 5773 media::OutputDeviceStatus status = device->GetDeviceStatus();
5772 device->Stop(); 5774 device->Stop();
5773 callback.Run(status); 5775 callback.Run(status);
5774 } 5776 }
5775 5777
5776 } // namespace content 5778 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/pepper_plugin_instance_impl.cc ('k') | content/renderer/render_frame_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698