summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-16 19:58:08 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-16 19:58:08 +0000
commit5b35a6be09ab4a22ed9c5e0a073463a2ef630ec5 (patch)
tree00bdf30d37b70e4f3b027c7a5dc49784e08be98b
parent65e9cdbe8cf977e04bc264fe6d70cc5b2b0242a1 (diff)
downloadchromium_src-5b35a6be09ab4a22ed9c5e0a073463a2ef630ec5.zip
chromium_src-5b35a6be09ab4a22ed9c5e0a073463a2ef630ec5.tar.gz
chromium_src-5b35a6be09ab4a22ed9c5e0a073463a2ef630ec5.tar.bz2
Get rid of stashing a frame pointer with ResourceRequest and just store the routing id directly. This simplifies the renderer code and also allow this code to be used in worker processes, where we don't have a frame.
Review URL: http://codereview.chromium.org/46026 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11763 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--DEPS2
-rw-r--r--chrome/renderer/render_view.cc6
-rw-r--r--chrome/renderer/render_view.h3
-rw-r--r--chrome/renderer/renderer_glue.cc21
-rw-r--r--webkit/glue/resource_fetcher.cc4
-rw-r--r--webkit/glue/resource_handle_impl.cc45
-rw-r--r--webkit/glue/resource_loader_bridge.h14
-rw-r--r--webkit/glue/unittest_test_server.h5
-rw-r--r--webkit/glue/webframeloaderclient_impl.cc20
-rw-r--r--webkit/glue/webplugin_impl.cc12
-rw-r--r--webkit/glue/weburlrequest.h3
-rw-r--r--webkit/glue/weburlrequest_impl.cc4
-rw-r--r--webkit/glue/weburlrequest_impl.h1
-rw-r--r--webkit/tools/test_shell/simple_resource_loader_bridge.cc10
-rw-r--r--webkit/tools/test_shell/test_shell_tests.vcproj4
15 files changed, 73 insertions, 81 deletions
diff --git a/DEPS b/DEPS
index 57ccf65..4cf7416 100644
--- a/DEPS
+++ b/DEPS
@@ -19,7 +19,7 @@ deps = {
"http://googletest.googlecode.com/svn/trunk@167",
"src/third_party/WebKit":
- "/trunk/deps/third_party/WebKit@11756",
+ "/trunk/deps/third_party/WebKit@11758",
"src/third_party/icu38":
"/trunk/deps/third_party/icu38@11496",
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 000443e..cf3a6e8 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -1508,6 +1508,12 @@ void RenderView::DidCompleteClientRedirect(WebView* webview,
completed_client_redirect_src_ = source;
}
+void RenderView::WillSendRequest(WebView* webview,
+ uint32 identifier,
+ WebRequest* request) {
+ request->SetRequestorID(routing_id_);
+}
+
void RenderView::BindDOMAutomationController(WebFrame* webframe) {
dom_automation_controller_.set_message_sender(this);
dom_automation_controller_.set_routing_id(routing_id_);
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index 47472db..e928750 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -215,6 +215,9 @@ class RenderView : public RenderWidget,
virtual void DidCompleteClientRedirect(WebView* webview,
WebFrame* frame,
const GURL& source);
+ virtual void WillSendRequest(WebView* webview,
+ uint32 identifier,
+ WebRequest* request);
virtual void WindowObjectCleared(WebFrame* webframe);
virtual void DocumentElementAvailable(WebFrame* webframe);
diff --git a/chrome/renderer/renderer_glue.cc b/chrome/renderer/renderer_glue.cc
index 997748a..f741ffd 100644
--- a/chrome/renderer/renderer_glue.cc
+++ b/chrome/renderer/renderer_glue.cc
@@ -21,7 +21,6 @@
#include "chrome/renderer/net/render_dns_master.h"
#include "chrome/renderer/render_process.h"
#include "chrome/renderer/render_thread.h"
-#include "chrome/renderer/render_view.h"
#include "googleurl/src/url_util.h"
#include "webkit/glue/scoped_clipboard_writer_glue.h"
#include "webkit/glue/webframe.h"
@@ -230,7 +229,6 @@ webkit_glue::ScreenInfo GetScreenInfo(gfx::NativeViewId window) {
// static factory function
ResourceLoaderBridge* ResourceLoaderBridge::Create(
- WebFrame* webframe,
const std::string& method,
const GURL& url,
const GURL& policy_url,
@@ -239,25 +237,12 @@ ResourceLoaderBridge* ResourceLoaderBridge::Create(
int load_flags,
int origin_pid,
ResourceType::Type resource_type,
- bool mixed_content) {
- // TODO(darin): we need to eliminate the webframe parameter because webkit
- // does not always supply it (see ResourceHandle::loadResourceSynchronously).
- // Instead we should add context to ResourceRequest, which will be easy to do
- // once we merge to the latest WebKit (r23806 at least).
- if (!webframe) {
- NOTREACHED() << "no webframe";
- return NULL;
- }
-
- if (!webframe->GetView()->GetDelegate())
- return NULL;
-
- RenderView* rv = static_cast<RenderView*>(webframe->GetView()->GetDelegate());
- int route_id = rv->routing_id();
+ bool mixed_content,
+ int routing_id) {
ResourceDispatcher* dispatch = RenderThread::current()->resource_dispatcher();
return dispatch->CreateBridge(method, url, policy_url, referrer, headers,
load_flags, origin_pid, resource_type,
- mixed_content, 0, route_id);
+ mixed_content, 0, routing_id);
}
void NotifyCacheStats() {
diff --git a/webkit/glue/resource_fetcher.cc b/webkit/glue/resource_fetcher.cc
index d4980c1..9d6379c 100644
--- a/webkit/glue/resource_fetcher.cc
+++ b/webkit/glue/resource_fetcher.cc
@@ -9,6 +9,7 @@
MSVC_PUSH_WARNING_LEVEL(0);
#include "FrameLoader.h"
+#include "FrameLoaderClient.h"
#include "ResourceHandle.h"
#include "ResourceRequest.h"
MSVC_POP_WARNING();
@@ -56,7 +57,8 @@ void ResourceFetcher::Start(WebCore::Frame* frame) {
}
WebCore::ResourceRequest request(webkit_glue::GURLToKURL(url_));
- request.setFrame(frame);
+ WebCore::ResourceResponse response;
+ frame_loader->client()->dispatchWillSendRequest(NULL, 0, request, response);
loader_ = ResourceHandle::create(request, this, NULL, false, false);
}
diff --git a/webkit/glue/resource_handle_impl.cc b/webkit/glue/resource_handle_impl.cc
index 961e788..be5704c 100644
--- a/webkit/glue/resource_handle_impl.cc
+++ b/webkit/glue/resource_handle_impl.cc
@@ -28,9 +28,7 @@
MSVC_PUSH_WARNING_LEVEL(0);
#include "CString.h"
-#include "Console.h"
#include "DocLoader.h"
-#include "DOMWindow.h"
#include "FormData.h"
#include "FrameLoader.h"
#include "Page.h"
@@ -52,7 +50,6 @@ MSVC_POP_WARNING();
#include "webkit/glue/glue_util.h"
#include "webkit/glue/multipart_response_delegate.h"
#include "webkit/glue/resource_loader_bridge.h"
-#include "webkit/glue/webframe_impl.h"
#include "net/base/data_url.h"
#include "net/base/net_errors.h"
#include "net/base/net_util.h"
@@ -312,10 +309,6 @@ bool ResourceHandleInternal::Start(
ResourceLoaderBridge::SyncLoadResponse* sync_load_response) {
DCHECK(!bridge_.get());
- // The WebFrame is the Frame's FrameWinClient
- WebFrameImpl* webframe =
- request_.frame() ? WebFrameImpl::FromFrame(request_.frame()) : NULL;
-
CString method = request_.httpMethod().latin1();
GURL referrer(webkit_glue::StringToStdString(request_.httpReferrer()));
@@ -333,17 +326,6 @@ bool ResourceHandleInternal::Start(
client_ = feed_client_proxy_.get();
}
- // Inherit the policy URL from the request's frame. However, if the request
- // is for a main frame, the current document's policyBaseURL is the old
- // document, so we leave policyURL empty to indicate that the request is a
- // first-party request.
- GURL policy_url;
- if (request_.targetType() != ResourceRequest::TargetIsMainFrame &&
- request_.frame() && request_.frame()->document()) {
- policy_url = GURL(webkit_glue::StringToStdString(
- request_.frame()->document()->policyBaseURL()));
- }
-
switch (request_.cachePolicy()) {
case ReloadIgnoringCacheData:
// Required by LayoutTests/http/tests/misc/refresh-headers.php
@@ -394,27 +376,16 @@ bool ResourceHandleInternal::Start(
(*it).second == "max-age=0")
continue;
- // WinInet dies if blank headers are set. TODO(darin): Is this still an
- // issue now that we are using WinHTTP?
- if ((*it).first.isEmpty()) {
- webframe->frame()->domWindow()->console()->addMessage(
- JSMessageSource,
- ErrorMessageLevel,
- "Refused to set blank header",
- 1,
- String());
- continue;
- }
if (!headerBuf.isEmpty())
headerBuf.append(crlf);
headerBuf.append((*it).first + sep + (*it).second);
}
// TODO(jcampan): in the non out-of-process plugin case the request does not
- // have a origin_pid. Find a better place to set this.
- int origin_pid = request_.originPid();
- if (origin_pid == 0)
- origin_pid = base::GetCurrentProcId();
+ // have a requestor_pid. Find a better place to set this.
+ int requestor_pid = request_.requestorProcessID();
+ if (requestor_pid == 0)
+ requestor_pid = base::GetCurrentProcId();
bool mixed_content =
webkit_glue::KURLToGURL(request_.mainDocumentURL()).SchemeIsSecure() &&
@@ -444,16 +415,16 @@ bool ResourceHandleInternal::Start(
// TODO(brettw) this should take parameter encoding into account when
// creating the GURLs.
bridge_.reset(ResourceLoaderBridge::Create(
- webframe,
webkit_glue::CStringToStdString(method),
url,
- policy_url,
+ webkit_glue::KURLToGURL(request_.policyURL()),
referrer,
webkit_glue::CStringToStdString(headerBuf.latin1()),
load_flags_,
- origin_pid,
+ requestor_pid,
FromTargetType(request_.targetType()),
- mixed_content));
+ mixed_content,
+ request_.requestorID()));
if (!bridge_.get())
return false;
diff --git a/webkit/glue/resource_loader_bridge.h b/webkit/glue/resource_loader_bridge.h
index bd5ad42..482ca84 100644
--- a/webkit/glue/resource_loader_bridge.h
+++ b/webkit/glue/resource_loader_bridge.h
@@ -144,9 +144,6 @@ class ResourceLoaderBridge {
// the standard MIME header encoding rules. The headers parameter can also
// be null if no extra request headers need to be set.
//
- // The WebFrame passed to this function provides context about the origin
- // of the resource request.
- //
// policy_url is the URL of the document in the top-level window, which may be
// checked by the third-party cookie blocking policy.
//
@@ -157,16 +154,19 @@ class ResourceLoaderBridge {
//
// request_type indicates if the current request is the main frame load, a
// sub-frame load, or a sub objects load.
- static ResourceLoaderBridge* Create(WebFrame* frame,
- const std::string& method,
+ //
+ // routing_id passed to this function allows it to be associated with a
+ // frame's network context.
+ static ResourceLoaderBridge* Create(const std::string& method,
const GURL& url,
const GURL& policy_url,
const GURL& referrer,
const std::string& headers,
int load_flags,
- int origin_pid,
+ int requestor_pid,
ResourceType::Type request_type,
- bool mixed_content);
+ bool mixed_content,
+ int routing_id);
// Call this method before calling Start() to append a chunk of binary data
// to the request body. May only be used with HTTP(S) POST requests.
diff --git a/webkit/glue/unittest_test_server.h b/webkit/glue/unittest_test_server.h
index ad1e28a..9476ab5 100644
--- a/webkit/glue/unittest_test_server.h
+++ b/webkit/glue/unittest_test_server.h
@@ -38,7 +38,7 @@ class UnittestTestServer : public HTTPTestServer {
virtual bool MakeGETRequest(const std::string& page_name) {
GURL url(TestServerPage(page_name));
scoped_ptr<ResourceLoaderBridge> loader(
- ResourceLoaderBridge::Create(NULL, "GET",
+ ResourceLoaderBridge::Create("GET",
url,
url, // policy_url
GURL(), // no referrer
@@ -46,7 +46,8 @@ class UnittestTestServer : public HTTPTestServer {
net::LOAD_NORMAL,
0,
ResourceType::SUB_RESOURCE,
- false));
+ false,
+ 0));
EXPECT_TRUE(loader.get());
ResourceLoaderBridge::SyncLoadResponse resp;
diff --git a/webkit/glue/webframeloaderclient_impl.cc b/webkit/glue/webframeloaderclient_impl.cc
index 7855cb6..1eda695 100644
--- a/webkit/glue/webframeloaderclient_impl.cc
+++ b/webkit/glue/webframeloaderclient_impl.cc
@@ -195,13 +195,21 @@ static ResourceRequest::TargetType DetermineTargetTypeFromLoader(
void WebFrameLoaderClient::dispatchWillSendRequest(
DocumentLoader* loader, unsigned long identifier, ResourceRequest& request,
const ResourceResponse& redirectResponse) {
- // We set the Frame on the ResourceRequest to provide load context to the
- // ResourceHandle implementation.
- request.setFrame(webframe_->frame());
- // We want to distinguish between a request for a document to be loaded into
- // the main frame, a sub-frame, or the sub-objects in that document.
- request.setTargetType(DetermineTargetTypeFromLoader(loader));
+ if (loader) {
+ // We want to distinguish between a request for a document to be loaded into
+ // the main frame, a sub-frame, or the sub-objects in that document.
+ request.setTargetType(DetermineTargetTypeFromLoader(loader));
+ }
+
+ // Inherit the policy URL from the request's frame. However, if the request
+ // is for a main frame, the current document's policyBaseURL is the old
+ // document, so we leave policyURL empty to indicate that the request is a
+ // first-party request.
+ if (request.targetType() != ResourceRequest::TargetIsMainFrame &&
+ webframe_->frame()->document()) {
+ request.setPolicyURL(webframe_->frame()->document()->policyBaseURL());
+ }
// FrameLoader::loadEmptyDocumentSynchronously() creates an empty document
// with no URL. We don't like that, so we'll rename it to about:blank.
diff --git a/webkit/glue/webplugin_impl.cc b/webkit/glue/webplugin_impl.cc
index 5027d5a..2bb5916 100644
--- a/webkit/glue/webplugin_impl.cc
+++ b/webkit/glue/webplugin_impl.cc
@@ -1241,9 +1241,8 @@ bool WebPluginImpl::InitiateHTTPRequest(int resource_id,
ClientInfo info;
info.id = resource_id;
info.client = client;
- info.request.setFrame(frame());
info.request.setURL(kurl);
- info.request.setOriginPid(delegate_->GetProcessId());
+ info.request.setRequestorProcessID(delegate_->GetProcessId());
info.request.setTargetType(WebCore::ResourceRequest::TargetIsObject);
info.request.setHTTPMethod(method);
@@ -1268,8 +1267,13 @@ bool WebPluginImpl::InitiateHTTPRequest(int resource_id,
SetPostData(&info.request, buf, buf_len);
}
- info.handle = WebCore::ResourceHandle::create(info.request, this, frame(),
- false, false);
+ // Sets the routing id to associate the ResourceRequest with the RenderView.
+ WebCore::ResourceResponse response;
+ frame()->loader()->client()->dispatchWillSendRequest(
+ NULL, 0, info.request, response);
+
+ info.handle = WebCore::ResourceHandle::create(
+ info.request, this, NULL, false, false);
if (!info.handle) {
return false;
}
diff --git a/webkit/glue/weburlrequest.h b/webkit/glue/weburlrequest.h
index 537b87d..94d14c4 100644
--- a/webkit/glue/weburlrequest.h
+++ b/webkit/glue/weburlrequest.h
@@ -123,6 +123,9 @@ class WebRequest {
// Set the request upload data.
virtual void SetUploadData(const net::UploadData& data) = 0;
+ // Sets the requestor id.
+ virtual void SetRequestorID(int requestor_id) = 0;
+
virtual ~WebRequest() { }
};
diff --git a/webkit/glue/weburlrequest_impl.cc b/webkit/glue/weburlrequest_impl.cc
index 1549201..9a06f92 100644
--- a/webkit/glue/weburlrequest_impl.cc
+++ b/webkit/glue/weburlrequest_impl.cc
@@ -202,6 +202,10 @@ void WebRequestImpl::SetUploadData(const net::UploadData& data)
request_.resourceRequest().setHTTPBody(formdata);
}
+void WebRequestImpl::SetRequestorID(int requestor_id) {
+ request_.resourceRequest().setRequestorID(requestor_id);
+}
+
// static
WebRequest* WebRequest::Create(const GURL& url) {
return new WebRequestImpl(url);
diff --git a/webkit/glue/weburlrequest_impl.h b/webkit/glue/weburlrequest_impl.h
index 3ce55b0..968dbc0 100644
--- a/webkit/glue/weburlrequest_impl.h
+++ b/webkit/glue/weburlrequest_impl.h
@@ -46,6 +46,7 @@ class WebRequestImpl : public WebRequest {
virtual bool HasUploadData() const;
virtual void GetUploadData(net::UploadData* data) const;
virtual void SetUploadData(const net::UploadData& data);
+ virtual void SetRequestorID(int requestor_id);
// WebRequestImpl
const WebCore::FrameLoadRequest& frame_load_request() const {
diff --git a/webkit/tools/test_shell/simple_resource_loader_bridge.cc b/webkit/tools/test_shell/simple_resource_loader_bridge.cc
index 0c10c966..0763246 100644
--- a/webkit/tools/test_shell/simple_resource_loader_bridge.cc
+++ b/webkit/tools/test_shell/simple_resource_loader_bridge.cc
@@ -544,18 +544,18 @@ namespace webkit_glue {
// factory function
ResourceLoaderBridge* ResourceLoaderBridge::Create(
- WebFrame* webframe,
const std::string& method,
const GURL& url,
const GURL& policy_url,
const GURL& referrer,
const std::string& headers,
int load_flags,
- int origin_pid,
+ int requestor_pid,
ResourceType::Type request_type,
- bool mixed_contents) {
- return new ResourceLoaderBridgeImpl(method, url, policy_url, referrer,
- headers, load_flags);
+ bool mixed_contents,
+ int routing_id) {
+ return new ResourceLoaderBridgeImpl(method, url, policy_url,
+ referrer, headers, load_flags);
}
// Issue the proxy resolve request on the io thread, and wait
diff --git a/webkit/tools/test_shell/test_shell_tests.vcproj b/webkit/tools/test_shell/test_shell_tests.vcproj
index 1f6cdf7..bc1fea7 100644
--- a/webkit/tools/test_shell/test_shell_tests.vcproj
+++ b/webkit/tools/test_shell/test_shell_tests.vcproj
@@ -287,6 +287,10 @@
>
</File>
<File
+ RelativePath=".\unittest_test_server.h"
+ >
+ </File>
+ <File
RelativePath=".\webview_host.h"
>
</File>