diff options
author | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-19 00:46:33 +0000 |
---|---|---|
committer | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-19 00:46:33 +0000 |
commit | 46b0d4aacbf25108badc143e09f91064fc0b0472 (patch) | |
tree | d1ec74ba60c5c7ae6fd683ad7b685095434e6f03 /webkit/glue | |
parent | 08ae5f310a475f73807df520fa0b50cf7138c4f5 (diff) | |
download | chromium_src-46b0d4aacbf25108badc143e09f91064fc0b0472.zip chromium_src-46b0d4aacbf25108badc143e09f91064fc0b0472.tar.gz chromium_src-46b0d4aacbf25108badc143e09f91064fc0b0472.tar.bz2 |
Add a CreateBridge method to the ChildThread.
The intent is to allow unit-tests that use render view
to override ChildThread::CreateBridge() to provide their
own resource loading.
This is used by the upcoming translate unit-test.
BUG=None
TEST=None
Review URL: http://codereview.chromium.org/503032
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35014 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue')
-rw-r--r-- | webkit/glue/media/media_resource_loader_bridge_factory.cc | 28 | ||||
-rw-r--r-- | webkit/glue/resource_loader_bridge.cc | 12 | ||||
-rw-r--r-- | webkit/glue/resource_loader_bridge.h | 88 | ||||
-rw-r--r-- | webkit/glue/unittest_test_server.h | 27 | ||||
-rw-r--r-- | webkit/glue/weburlloader_impl.cc | 28 |
5 files changed, 108 insertions, 75 deletions
diff --git a/webkit/glue/media/media_resource_loader_bridge_factory.cc b/webkit/glue/media/media_resource_loader_bridge_factory.cc index 0c3d6ab..1961bcc 100644 --- a/webkit/glue/media/media_resource_loader_bridge_factory.cc +++ b/webkit/glue/media/media_resource_loader_bridge_factory.cc @@ -36,19 +36,21 @@ ResourceLoaderBridge* MediaResourceLoaderBridgeFactory::CreateBridge( int load_flags, int64 first_byte_position, int64 last_byte_position) { - return webkit_glue::ResourceLoaderBridge::Create( - "GET", - url, - url, - referrer_, - frame_origin_, - main_frame_origin_, - GenerateHeaders(first_byte_position, last_byte_position), - load_flags, - origin_pid_, - ResourceType::MEDIA, - appcache_host_id_, - routing_id_); + webkit_glue::ResourceLoaderBridge::RequestInfo request_info; + request_info.method = "GET"; + request_info.url = url; + request_info.first_party_for_cookies = url; + request_info.referrer = referrer_; + request_info.frame_origin = frame_origin_; + request_info.main_frame_origin = main_frame_origin_; + request_info.headers = GenerateHeaders(first_byte_position, + last_byte_position); + request_info.load_flags = load_flags; + request_info.requestor_pid = origin_pid_; + request_info.request_type = ResourceType::MEDIA; + request_info.appcache_host_id = appcache_host_id_; + request_info.routing_id = routing_id_; + return webkit_glue::ResourceLoaderBridge::Create(request_info); } // static diff --git a/webkit/glue/resource_loader_bridge.cc b/webkit/glue/resource_loader_bridge.cc index fd8eee3..8b22508 100644 --- a/webkit/glue/resource_loader_bridge.cc +++ b/webkit/glue/resource_loader_bridge.cc @@ -9,6 +9,18 @@ namespace webkit_glue { +ResourceLoaderBridge::RequestInfo::RequestInfo() + : load_flags(0), + requestor_pid(0), + request_type(ResourceType::MAIN_FRAME), + request_context(0), + appcache_host_id(0), + routing_id(0) { +} + +ResourceLoaderBridge::RequestInfo::~RequestInfo() { +} + ResourceLoaderBridge::ResponseInfo::ResponseInfo() { content_length = -1; appcache_id = appcache::kNoCacheId; diff --git a/webkit/glue/resource_loader_bridge.h b/webkit/glue/resource_loader_bridge.h index aac2331..95ed6ac 100644 --- a/webkit/glue/resource_loader_bridge.h +++ b/webkit/glue/resource_loader_bridge.h @@ -38,6 +38,54 @@ namespace webkit_glue { class ResourceLoaderBridge { public: + // Structure used when calling ResourceLoaderBridge::Create(). + struct RequestInfo { + RequestInfo(); + ~RequestInfo(); + + // HTTP-style method name (e.g., "GET" or "POST"). + std::string method; + + // Absolute URL encoded in ASCII per the rules of RFC-2396. + GURL url; + + // URL of the document in the top-level window, which may be checked by the + // third-party cookie blocking policy. + GURL first_party_for_cookies; + + // Optional parameter, a URL with similar constraints in how it must be + // encoded as the url member. + GURL referrer; + + std::string frame_origin; + std::string main_frame_origin; + + // For HTTP(S) requests, the headers parameter can be a \r\n-delimited and + // \r\n-terminated list of MIME headers. They should be ASCII-encoded using + // the standard MIME header encoding rules. The headers parameter can also + // be null if no extra request headers need to be set. + std::string headers; + + // Composed of the values defined in url_request_load_flags.h. + int load_flags; + + // Process id of the process making the request. + int requestor_pid; + + // Indicates if the current request is the main frame load, a sub-frame + // load, or a sub objects load. + ResourceType::Type request_type; + + // Used for plugin to browser requests. + uint32 request_context; + + // Identifies that appcache host this request is associated with. + int appcache_host_id; + + // Used to associated the bridge with a frame's network context. + int routing_id; + }; + struct ResponseInfo { ResponseInfo(); ~ResponseInfo(); @@ -144,45 +192,11 @@ class ResourceLoaderBridge { // INCLUDING during processing of callbacks. virtual ~ResourceLoaderBridge(); - // Call this method to make a new instance. The method name is a HTTP-style - // method name (e.g., "GET" or "POST"). The URL should be an absolute URL - // encoded in ASCII per the rules of RFC-2396. The referrer parameter is - // optional (may be NULL) and is a URL with similar constraints in how it - // must be encoded. + // Call this method to make a new instance. // // For HTTP(S) POST requests, the AppendDataToUpload and AppendFileToUpload // methods may be called to construct the body of the request. - // - // For HTTP(S) requests, the headers parameter can be a \r\n-delimited and - // \r\n-terminated list of MIME headers. They should be ASCII-encoded using - // the standard MIME header encoding rules. The headers parameter can also - // be null if no extra request headers need to be set. - // - // first_party_for_cookies is the URL of the document in the top-level - // window, which may be checked by the third-party cookie blocking policy. - // - // load_flags is composed of the values defined in url_request_load_flags.h - // - // request_type indicates if the current request is the main frame load, a - // sub-frame load, or a sub objects load. - // - // appcache_host_id identifies that appcache host this request is - // associated with. - // - // 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& first_party_for_cookies, - const GURL& referrer, - const std::string& frame_origin, - const std::string& main_frame_origin, - const std::string& headers, - int load_flags, - int requestor_pid, - ResourceType::Type request_type, - int appcache_host_id, - int routing_id); + static ResourceLoaderBridge* Create(const RequestInfo& request_info); // 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. @@ -232,7 +246,7 @@ class ResourceLoaderBridge { ResourceLoaderBridge(); private: - DISALLOW_EVIL_CONSTRUCTORS(ResourceLoaderBridge); + DISALLOW_COPY_AND_ASSIGN(ResourceLoaderBridge); }; } // namespace webkit_glue diff --git a/webkit/glue/unittest_test_server.h b/webkit/glue/unittest_test_server.h index 44caa29..0b3c7d2 100644 --- a/webkit/glue/unittest_test_server.h +++ b/webkit/glue/unittest_test_server.h @@ -35,19 +35,22 @@ class UnittestTestServer : public HTTPTestServer { virtual bool MakeGETRequest(const std::string& page_name) { GURL url(TestServerPage(page_name)); + webkit_glue::ResourceLoaderBridge::RequestInfo request_info; + request_info.method = "GET"; + request_info.url = url; + request_info.first_party_for_cookies = url; + request_info.referrer = GURL(); // No referrer. + request_info.frame_origin = "null"; + request_info.main_frame_origin = "null"; + request_info.headers = std::string(); // No extra headers. + request_info.load_flags = net::LOAD_NORMAL; + request_info.requestor_pid = 0; + request_info.request_type = ResourceType::SUB_RESOURCE; + request_info.request_context = 0; + request_info.appcache_host_id = appcache::kNoHostId; + request_info.routing_id = 0; scoped_ptr<ResourceLoaderBridge> loader( - ResourceLoaderBridge::Create("GET", - url, - url, // first_party_for_cookies - GURL(), // no referrer - std::string(), // no extra headers - "null", // frame_origin - "null", // main_frame_origin - net::LOAD_NORMAL, - 0, - ResourceType::SUB_RESOURCE, - appcache::kNoHostId, - 0)); + ResourceLoaderBridge::Create(request_info)); EXPECT_TRUE(loader.get()); ResourceLoaderBridge::SyncLoadResponse resp; diff --git a/webkit/glue/weburlloader_impl.cc b/webkit/glue/weburlloader_impl.cc index 44d6f82..df2a601 100644 --- a/webkit/glue/weburlloader_impl.cc +++ b/webkit/glue/weburlloader_impl.cc @@ -338,19 +338,21 @@ void WebURLLoaderImpl::Context::Start( // TODO(brettw) this should take parameter encoding into account when // creating the GURLs. - bridge_.reset(ResourceLoaderBridge::Create( - method, - url, - request.firstPartyForCookies(), - referrer_url, - frame_origin, - main_frame_origin, - flattener.GetBuffer(), - load_flags, - requestor_pid, - FromTargetType(request.targetType()), - request.appCacheHostID(), - request.requestorID())); + + webkit_glue::ResourceLoaderBridge::RequestInfo request_info; + request_info.method = method; + request_info.url = url; + request_info.first_party_for_cookies = request.firstPartyForCookies(); + request_info.referrer = referrer_url; + request_info.frame_origin = frame_origin; + request_info.main_frame_origin = main_frame_origin; + request_info.headers = flattener.GetBuffer(); + request_info.load_flags = load_flags; + request_info.requestor_pid = requestor_pid; + request_info.request_type = FromTargetType(request.targetType()); + request_info.appcache_host_id = request.appCacheHostID(); + request_info.routing_id = request.requestorID(); + bridge_.reset(ResourceLoaderBridge::Create(request_info)); if (!request.httpBody().isNull()) { // GET and HEAD requests shouldn't have http bodies. |