diff options
| author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-24 01:23:34 +0000 |
|---|---|---|
| committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-24 01:23:34 +0000 |
| commit | 2336ffec2176cdd2aa3c98ee4a3f1ce1e84fc408 (patch) | |
| tree | dc735317f1d63ab8fe44b0b01fd6e46b63c770fe | |
| parent | 4bbc81d76526eb451eb9fbeb82cd99d245f324e2 (diff) | |
| download | chromium_src-2336ffec2176cdd2aa3c98ee4a3f1ce1e84fc408.zip chromium_src-2336ffec2176cdd2aa3c98ee4a3f1ce1e84fc408.tar.gz chromium_src-2336ffec2176cdd2aa3c98ee4a3f1ce1e84fc408.tar.bz2 | |
Move ResourceResponse struct into the Content API, since it's used in Chrome. While at it, I also made the ResourceResponse wrapper just derive from ResourceResponseHead, so that the parameters are accessed directly, instead of having to go through a member variable.
BUG=98716
Review URL: http://codereview.chromium.org/8680036
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111471 0039d316-1c4b-4281-b951-d872f2087c98
41 files changed, 233 insertions, 220 deletions
diff --git a/chrome/browser/download/download_throttling_resource_handler.cc b/chrome/browser/download/download_throttling_resource_handler.cc index 70f26ae..a65f984 100644 --- a/chrome/browser/download/download_throttling_resource_handler.cc +++ b/chrome/browser/download/download_throttling_resource_handler.cc @@ -11,7 +11,7 @@ #include "content/browser/renderer_host/resource_dispatcher_host.h" #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" #include "content/browser/resource_context.h" -#include "content/common/resource_response.h" +#include "content/public/common/resource_response.h" #include "net/base/io_buffer.h" #include "net/base/mime_sniffer.h" @@ -65,7 +65,7 @@ bool DownloadThrottlingResourceHandler::OnUploadProgress(int request_id, bool DownloadThrottlingResourceHandler::OnRequestRedirected( int request_id, const GURL& url, - ResourceResponse* response, + content::ResourceResponse* response, bool* defer) { DCHECK(!request_closed_); if (request_allowed_) { @@ -77,7 +77,7 @@ bool DownloadThrottlingResourceHandler::OnRequestRedirected( bool DownloadThrottlingResourceHandler::OnResponseStarted( int request_id, - ResourceResponse* response) { + content::ResourceResponse* response) { DCHECK(!request_closed_); if (request_allowed_) return next_handler_->OnResponseStarted(request_id, response); diff --git a/chrome/browser/download/download_throttling_resource_handler.h b/chrome/browser/download/download_throttling_resource_handler.h index 5c13a16..5e9cba5 100644 --- a/chrome/browser/download/download_throttling_resource_handler.h +++ b/chrome/browser/download/download_throttling_resource_handler.h @@ -46,10 +46,10 @@ class DownloadThrottlingResourceHandler uint64 size) OVERRIDE; virtual bool OnRequestRedirected(int request_id, const GURL& url, - ResourceResponse* response, + content::ResourceResponse* response, bool* defer) OVERRIDE; virtual bool OnResponseStarted(int request_id, - ResourceResponse* response) OVERRIDE; + content::ResourceResponse* response) OVERRIDE; virtual bool OnWillStart(int request_id, const GURL& url, bool* defer) OVERRIDE; @@ -87,7 +87,7 @@ class DownloadThrottlingResourceHandler // Response supplied to OnResponseStarted. Only non-null if OnResponseStarted // is invoked. - scoped_refptr<ResourceResponse> response_; + scoped_refptr<content::ResourceResponse> response_; // If we're created by way of BufferedEventHandler we'll get one request for // a buffer. This is that buffer. diff --git a/chrome/browser/net/load_timing_observer.cc b/chrome/browser/net/load_timing_observer.cc index 58963cb..f0d33e2 100644 --- a/chrome/browser/net/load_timing_observer.cc +++ b/chrome/browser/net/load_timing_observer.cc @@ -6,7 +6,7 @@ #include "base/time.h" #include "chrome/browser/net/chrome_net_log.h" -#include "content/common/resource_response.h" +#include "content/public/common/resource_response.h" #include "content/public/browser/browser_thread.h" #include "net/base/load_flags.h" #include "net/url_request/url_request.h" @@ -99,8 +99,9 @@ void LoadTimingObserver::OnAddEntry(net::NetLog::EventType type, } // static -void LoadTimingObserver::PopulateTimingInfo(net::URLRequest* request, - ResourceResponse* response) { +void LoadTimingObserver::PopulateTimingInfo( + net::URLRequest* request, + content::ResourceResponse* response) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); if (!(request->load_flags() & net::LOAD_ENABLE_LOAD_TIMING)) return; @@ -115,9 +116,9 @@ void LoadTimingObserver::PopulateTimingInfo(net::URLRequest* request, LoadTimingObserver::URLRequestRecord* record = observer->GetURLRequestRecord(source_id); if (record) { - response->response_head.connection_id = record->socket_log_id; - response->response_head.connection_reused = record->socket_reused; - response->response_head.load_timing = record->timing; + response->connection_id = record->socket_log_id; + response->connection_reused = record->socket_reused; + response->load_timing = record->timing; } } diff --git a/chrome/browser/net/load_timing_observer.h b/chrome/browser/net/load_timing_observer.h index 444c3d4..a44a3be 100644 --- a/chrome/browser/net/load_timing_observer.h +++ b/chrome/browser/net/load_timing_observer.h @@ -13,12 +13,14 @@ #include "net/base/net_log.h" #include "webkit/glue/resource_loader_bridge.h" +namespace content { +struct ResourceResponse; +} + namespace net { class URLRequest; } // namespace net -struct ResourceResponse; - // LoadTimingObserver watches the NetLog event stream and collects the network // timing information. // @@ -72,7 +74,7 @@ class LoadTimingObserver : public ChromeNetLog::ThreadSafeObserverImpl { net::NetLog::EventParameters* params) OVERRIDE; static void PopulateTimingInfo(net::URLRequest* request, - ResourceResponse* response); + content::ResourceResponse* response); private: FRIEND_TEST_ALL_PREFIXES(LoadTimingObserverTest, diff --git a/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc b/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc index 0f3a7a8..2ad3a5d 100644 --- a/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc +++ b/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc @@ -306,7 +306,7 @@ bool ChromeResourceDispatcherHostDelegate::ShouldForceDownloadResource( void ChromeResourceDispatcherHostDelegate::OnResponseStarted( net::URLRequest* request, - ResourceResponse* response, + content::ResourceResponse* response, ResourceMessageFilter* filter) { LoadTimingObserver::PopulateTimingInfo(request, response); @@ -339,7 +339,7 @@ void ChromeResourceDispatcherHostDelegate::OnResponseStarted( void ChromeResourceDispatcherHostDelegate::OnRequestRedirected( net::URLRequest* request, - ResourceResponse* response, + content::ResourceResponse* response, ResourceMessageFilter* filter) { LoadTimingObserver::PopulateTimingInfo(request, response); } diff --git a/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.h b/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.h index 6aab52d..0fc5cb6 100644 --- a/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.h +++ b/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.h @@ -74,11 +74,11 @@ class ChromeResourceDispatcherHostDelegate const GURL& url, const std::string& mime_type) OVERRIDE; virtual void OnResponseStarted( net::URLRequest* request, - ResourceResponse* response, + content::ResourceResponse* response, ResourceMessageFilter* filter) OVERRIDE; virtual void OnRequestRedirected( net::URLRequest* request, - ResourceResponse* response, + content::ResourceResponse* response, ResourceMessageFilter* filter) OVERRIDE; private: diff --git a/chrome/browser/renderer_host/offline_resource_handler.cc b/chrome/browser/renderer_host/offline_resource_handler.cc index 66e4cee..536e27cc 100644 --- a/chrome/browser/renderer_host/offline_resource_handler.cc +++ b/chrome/browser/renderer_host/offline_resource_handler.cc @@ -54,16 +54,18 @@ bool OfflineResourceHandler::OnUploadProgress(int request_id, return next_handler_->OnUploadProgress(request_id, position, size); } -bool OfflineResourceHandler::OnRequestRedirected(int request_id, - const GURL& new_url, - ResourceResponse* response, - bool* defer) { +bool OfflineResourceHandler::OnRequestRedirected( + int request_id, + const GURL& new_url, + content::ResourceResponse* response, + bool* defer) { return next_handler_->OnRequestRedirected( request_id, new_url, response, defer); } -bool OfflineResourceHandler::OnResponseStarted(int request_id, - ResourceResponse* response) { +bool OfflineResourceHandler::OnResponseStarted( + int request_id, + content::ResourceResponse* response) { return next_handler_->OnResponseStarted(request_id, response); } diff --git a/chrome/browser/renderer_host/offline_resource_handler.h b/chrome/browser/renderer_host/offline_resource_handler.h index 2966c0d..b28d5f7 100644 --- a/chrome/browser/renderer_host/offline_resource_handler.h +++ b/chrome/browser/renderer_host/offline_resource_handler.h @@ -35,9 +35,9 @@ class OfflineResourceHandler : public ResourceHandler { virtual bool OnUploadProgress(int request_id, uint64 position, uint64 size) OVERRIDE; virtual bool OnRequestRedirected(int request_id, const GURL& new_url, - ResourceResponse* response, bool* defer) OVERRIDE; + content::ResourceResponse* response, bool* defer) OVERRIDE; virtual bool OnResponseStarted(int request_id, - ResourceResponse* response) OVERRIDE; + content::ResourceResponse* response) OVERRIDE; virtual bool OnWillStart(int request_id, const GURL& url, bool* defer) OVERRIDE; virtual bool OnWillRead(int request_id, net::IOBuffer** buf, int* buf_size, diff --git a/chrome/browser/renderer_host/safe_browsing_resource_handler.cc b/chrome/browser/renderer_host/safe_browsing_resource_handler.cc index 97a2bb9..2d97154 100644 --- a/chrome/browser/renderer_host/safe_browsing_resource_handler.cc +++ b/chrome/browser/renderer_host/safe_browsing_resource_handler.cc @@ -12,7 +12,7 @@ #include "content/browser/renderer_host/global_request_id.h" #include "content/browser/renderer_host/resource_dispatcher_host.h" #include "content/browser/renderer_host/resource_message_filter.h" -#include "content/common/resource_response.h" +#include "content/public/common/resource_response.h" #include "net/base/io_buffer.h" #include "net/base/load_flags.h" #include "net/base/net_errors.h" @@ -70,7 +70,7 @@ bool SafeBrowsingResourceHandler::OnUploadProgress(int request_id, bool SafeBrowsingResourceHandler::OnRequestRedirected( int request_id, const GURL& new_url, - ResourceResponse* response, + content::ResourceResponse* response, bool* defer) { CHECK(state_ == STATE_NONE); CHECK(defer_state_ == DEFERRED_NONE); @@ -98,7 +98,7 @@ bool SafeBrowsingResourceHandler::OnRequestRedirected( } bool SafeBrowsingResourceHandler::OnResponseStarted( - int request_id, ResourceResponse* response) { + int request_id, content::ResourceResponse* response) { CHECK(state_ == STATE_NONE); CHECK(defer_state_ == DEFERRED_NONE); return next_handler_->OnResponseStarted(request_id, response); @@ -334,7 +334,7 @@ void SafeBrowsingResourceHandler::ResumeRedirect() { // Retrieve the details for the paused OnReceivedRedirect(). int request_id = deferred_request_id_; GURL redirect_url = deferred_url_; - scoped_refptr<ResourceResponse> redirect_response = + scoped_refptr<content::ResourceResponse> redirect_response = deferred_redirect_response_; ClearDeferredRequestInfo(); diff --git a/chrome/browser/renderer_host/safe_browsing_resource_handler.h b/chrome/browser/renderer_host/safe_browsing_resource_handler.h index bc5bdf9..a1a8470 100644 --- a/chrome/browser/renderer_host/safe_browsing_resource_handler.h +++ b/chrome/browser/renderer_host/safe_browsing_resource_handler.h @@ -54,10 +54,10 @@ class SafeBrowsingResourceHandler : public ResourceHandler, virtual bool OnUploadProgress( int request_id, uint64 position, uint64 size) OVERRIDE; virtual bool OnRequestRedirected( - int request_id, const GURL& new_url, ResourceResponse* response, + int request_id, const GURL& new_url, content::ResourceResponse* response, bool* defer) OVERRIDE; virtual bool OnResponseStarted( - int request_id, ResourceResponse* response) OVERRIDE; + int request_id, content::ResourceResponse* response) OVERRIDE; virtual bool OnWillStart( int request_id, const GURL& url, bool* defer) OVERRIDE; virtual bool OnWillRead( @@ -152,7 +152,7 @@ class SafeBrowsingResourceHandler : public ResourceHandler, // valid to access these members when defer_state_ != DEFERRED_NONE. GURL deferred_url_; int deferred_request_id_; - scoped_refptr<ResourceResponse> deferred_redirect_response_; + scoped_refptr<content::ResourceResponse> deferred_redirect_response_; scoped_refptr<ResourceHandler> next_handler_; int render_process_host_id_; diff --git a/content/browser/debugger/devtools_netlog_observer.cc b/content/browser/debugger/devtools_netlog_observer.cc index 023ced3..98492b2 100644 --- a/content/browser/debugger/devtools_netlog_observer.cc +++ b/content/browser/debugger/devtools_netlog_observer.cc @@ -7,9 +7,9 @@ #include "base/string_tokenizer.h" #include "base/string_util.h" #include "base/values.h" -#include "content/common/resource_response.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/content_browser_client.h" +#include "content/public/common/resource_response.h" #include "net/base/load_flags.h" #include "net/http/http_net_log_params.h" #include "net/http/http_response_headers.h" @@ -260,8 +260,9 @@ DevToolsNetLogObserver* DevToolsNetLogObserver::GetInstance() { } // static -void DevToolsNetLogObserver::PopulateResponseInfo(net::URLRequest* request, - ResourceResponse* response) { +void DevToolsNetLogObserver::PopulateResponseInfo( + net::URLRequest* request, + content::ResourceResponse* response) { if (!(request->load_flags() & net::LOAD_REPORT_RAW_HEADERS)) return; @@ -270,7 +271,7 @@ void DevToolsNetLogObserver::PopulateResponseInfo(net::URLRequest* request, DevToolsNetLogObserver::GetInstance(); if (dev_tools_net_log_observer == NULL) return; - response->response_head.devtools_info = + response->devtools_info = dev_tools_net_log_observer->GetResourceInfo(source_id); } diff --git a/content/browser/debugger/devtools_netlog_observer.h b/content/browser/debugger/devtools_netlog_observer.h index 3fe2765..0a92dc1 100644 --- a/content/browser/debugger/devtools_netlog_observer.h +++ b/content/browser/debugger/devtools_netlog_observer.h @@ -11,12 +11,14 @@ #include "net/base/net_log.h" #include "webkit/glue/resource_loader_bridge.h" +namespace content { +struct ResourceResponse; +} + namespace net { class URLRequest; } // namespace net -struct ResourceResponse; - // DevToolsNetLogObserver watches the NetLog event stream and collects the // stuff that may be of interest to DevTools. Currently, this only includes // actual HTTP/SPDY headers sent and received over the network. @@ -59,7 +61,8 @@ class DevToolsNetLogObserver : public net::NetLog::ThreadSafeObserver { // Must be called on the IO thread. May return NULL if no observers // are active. static DevToolsNetLogObserver* GetInstance(); - static void PopulateResponseInfo(net::URLRequest*, ResourceResponse*); + static void PopulateResponseInfo(net::URLRequest*, + content::ResourceResponse*); static int GetAndResetEncodedDataLength(net::URLRequest* request); private: diff --git a/content/browser/download/download_resource_handler.cc b/content/browser/download/download_resource_handler.cc index 1c11dd4..82c9a3e 100644 --- a/content/browser/download/download_resource_handler.cc +++ b/content/browser/download/download_resource_handler.cc @@ -21,8 +21,8 @@ #include "content/browser/renderer_host/global_request_id.h" #include "content/browser/renderer_host/resource_dispatcher_host.h" #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" -#include "content/common/resource_response.h" #include "content/public/browser/browser_thread.h" +#include "content/public/common/resource_response.h" #include "net/base/io_buffer.h" #include "net/base/net_errors.h" #include "net/http/http_response_headers.h" @@ -65,16 +65,18 @@ bool DownloadResourceHandler::OnUploadProgress(int request_id, } // Not needed, as this event handler ought to be the final resource. -bool DownloadResourceHandler::OnRequestRedirected(int request_id, - const GURL& url, - ResourceResponse* response, - bool* defer) { +bool DownloadResourceHandler::OnRequestRedirected( + int request_id, + const GURL& url, + content::ResourceResponse* response, + bool* defer) { return true; } // Send the download creation information to the download thread. -bool DownloadResourceHandler::OnResponseStarted(int request_id, - ResourceResponse* response) { +bool DownloadResourceHandler::OnResponseStarted( + int request_id, + content::ResourceResponse* response) { DCHECK(download_id_.IsValid()); VLOG(20) << __FUNCTION__ << "()" << DebugString() << " request_id = " << request_id; @@ -87,7 +89,7 @@ bool DownloadResourceHandler::OnResponseStarted(int request_id, request_->GetResponseHeaderByName("content-disposition", &content_disposition); set_content_disposition(content_disposition); - set_content_length(response->response_head.content_length); + set_content_length(response->content_length); const ResourceDispatcherHostRequestInfo* request_info = ResourceDispatcherHost::InfoForRequest(request_); @@ -106,7 +108,7 @@ bool DownloadResourceHandler::OnResponseStarted(int request_id, info->download_id = download_id_; info->has_user_gesture = request_info->has_user_gesture(); info->content_disposition = content_disposition_; - info->mime_type = response->response_head.mime_type; + info->mime_type = response->mime_type; download_stats::RecordDownloadMimeType(info->mime_type); DownloadRequestHandle request_handle(rdh_, global_id_.child_id, @@ -118,8 +120,8 @@ bool DownloadResourceHandler::OnResponseStarted(int request_id, CallStartedCB(net::OK); std::string content_type_header; - if (!response->response_head.headers || - !response->response_head.headers->GetMimeType(&content_type_header)) + if (!response->headers || + !response->headers->GetMimeType(&content_type_header)) content_type_header = ""; info->original_mime_type = content_type_header; diff --git a/content/browser/download/download_resource_handler.h b/content/browser/download/download_resource_handler.h index 72bf588..38a3f68 100644 --- a/content/browser/download/download_resource_handler.h +++ b/content/browser/download/download_resource_handler.h @@ -56,12 +56,12 @@ class DownloadResourceHandler : public ResourceHandler { // Not needed, as this event handler ought to be the final resource. virtual bool OnRequestRedirected(int request_id, const GURL& url, - ResourceResponse* response, + content::ResourceResponse* response, bool* defer) OVERRIDE; // Send the download creation information to the download thread. virtual bool OnResponseStarted(int request_id, - ResourceResponse* response) OVERRIDE; + content::ResourceResponse* response) OVERRIDE; // Pass-through implementation. virtual bool OnWillStart(int request_id, diff --git a/content/browser/download/save_file_resource_handler.cc b/content/browser/download/save_file_resource_handler.cc index 146e0df..0fd6b55 100644 --- a/content/browser/download/save_file_resource_handler.cc +++ b/content/browser/download/save_file_resource_handler.cc @@ -33,16 +33,18 @@ bool SaveFileResourceHandler::OnUploadProgress(int request_id, return true; } -bool SaveFileResourceHandler::OnRequestRedirected(int request_id, - const GURL& url, - ResourceResponse* response, - bool* defer) { +bool SaveFileResourceHandler::OnRequestRedirected( + int request_id, + const GURL& url, + content::ResourceResponse* response, + bool* defer) { final_url_ = url; return true; } -bool SaveFileResourceHandler::OnResponseStarted(int request_id, - ResourceResponse* response) { +bool SaveFileResourceHandler::OnResponseStarted( + int request_id, + content::ResourceResponse* response) { save_id_ = save_manager_->GetNextId(); // |save_manager_| consumes (deletes): SaveFileCreateInfo* info = new SaveFileCreateInfo; diff --git a/content/browser/download/save_file_resource_handler.h b/content/browser/download/save_file_resource_handler.h index e814091..8215c1e 100644 --- a/content/browser/download/save_file_resource_handler.h +++ b/content/browser/download/save_file_resource_handler.h @@ -30,12 +30,12 @@ class SaveFileResourceHandler : public ResourceHandler { // URL to match original request. virtual bool OnRequestRedirected(int request_id, const GURL& url, - ResourceResponse* response, + content::ResourceResponse* response, bool* defer) OVERRIDE; // Sends the download creation information to the download thread. virtual bool OnResponseStarted(int request_id, - ResourceResponse* response) OVERRIDE; + content::ResourceResponse* response) OVERRIDE; // Pass-through implementation. virtual bool OnWillStart(int request_id, diff --git a/content/browser/renderer_host/async_resource_handler.cc b/content/browser/renderer_host/async_resource_handler.cc index 235a569..9f7577f 100644 --- a/content/browser/renderer_host/async_resource_handler.cc +++ b/content/browser/renderer_host/async_resource_handler.cc @@ -17,10 +17,10 @@ #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" #include "content/browser/renderer_host/resource_message_filter.h" #include "content/browser/resource_context.h" -#include "content/common/resource_response.h" #include "content/common/resource_messages.h" #include "content/common/view_messages.h" #include "content/public/browser/resource_dispatcher_host_delegate.h" +#include "content/public/common/resource_response.h" #include "net/base/io_buffer.h" #include "net/base/load_flags.h" #include "net/base/net_log.h" @@ -98,10 +98,11 @@ bool AsyncResourceHandler::OnUploadProgress(int request_id, position, size)); } -bool AsyncResourceHandler::OnRequestRedirected(int request_id, - const GURL& new_url, - ResourceResponse* response, - bool* defer) { +bool AsyncResourceHandler::OnRequestRedirected( + int request_id, + const GURL& new_url, + content::ResourceResponse* response, + bool* defer) { *defer = true; net::URLRequest* request = rdh_->GetURLRequest( GlobalRequestID(filter_->child_id(), request_id)); @@ -110,11 +111,12 @@ bool AsyncResourceHandler::OnRequestRedirected(int request_id, DevToolsNetLogObserver::PopulateResponseInfo(request, response); return filter_->Send(new ResourceMsg_ReceivedRedirect( - routing_id_, request_id, new_url, response->response_head)); + routing_id_, request_id, new_url, *response)); } -bool AsyncResourceHandler::OnResponseStarted(int request_id, - ResourceResponse* response) { +bool AsyncResourceHandler::OnResponseStarted( + int request_id, + content::ResourceResponse* response) { // For changes to the main frame, inform the renderer of the new URL's // per-host settings before the request actually commits. This way the // renderer will be able to set these precisely at the time the @@ -142,7 +144,7 @@ bool AsyncResourceHandler::OnResponseStarted(int request_id, } filter_->Send(new ResourceMsg_ReceivedResponse( - routing_id_, request_id, response->response_head)); + routing_id_, request_id, *response)); if (request->response_info().metadata) { std::vector<char> copy(request->response_info().metadata->data(), diff --git a/content/browser/renderer_host/async_resource_handler.h b/content/browser/renderer_host/async_resource_handler.h index 38d1fb6..34f7bc9 100644 --- a/content/browser/renderer_host/async_resource_handler.h +++ b/content/browser/renderer_host/async_resource_handler.h @@ -30,10 +30,10 @@ class AsyncResourceHandler : public ResourceHandler { uint64 size) OVERRIDE; virtual bool OnRequestRedirected(int request_id, const GURL& new_url, - ResourceResponse* response, + content::ResourceResponse* response, bool* defer) OVERRIDE; virtual bool OnResponseStarted(int request_id, - ResourceResponse* response) OVERRIDE; + content::ResourceResponse* response) OVERRIDE; virtual bool OnWillStart(int request_id, const GURL& url, bool* defer) OVERRIDE; diff --git a/content/browser/renderer_host/buffered_resource_handler.cc b/content/browser/renderer_host/buffered_resource_handler.cc index 826b156..6423c15 100644 --- a/content/browser/renderer_host/buffered_resource_handler.cc +++ b/content/browser/renderer_host/buffered_resource_handler.cc @@ -18,10 +18,10 @@ #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" #include "content/browser/renderer_host/x509_user_cert_resource_handler.h" #include "content/browser/resource_context.h" -#include "content/common/resource_response.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/content_browser_client.h" #include "content/public/browser/resource_dispatcher_host_delegate.h" +#include "content/public/common/resource_response.h" #include "net/base/io_buffer.h" #include "net/base/mime_sniffer.h" #include "net/base/mime_util.h" @@ -78,16 +78,18 @@ bool BufferedResourceHandler::OnUploadProgress(int request_id, return real_handler_->OnUploadProgress(request_id, position, size); } -bool BufferedResourceHandler::OnRequestRedirected(int request_id, - const GURL& new_url, - ResourceResponse* response, - bool* defer) { +bool BufferedResourceHandler::OnRequestRedirected( + int request_id, + const GURL& new_url, + content::ResourceResponse* response, + bool* defer) { return real_handler_->OnRequestRedirected( request_id, new_url, response, defer); } -bool BufferedResourceHandler::OnResponseStarted(int request_id, - ResourceResponse* response) { +bool BufferedResourceHandler::OnResponseStarted( + int request_id, + content::ResourceResponse* response) { response_ = response; if (!DelayResponse()) return CompleteResponseStarted(request_id, false); @@ -175,8 +177,7 @@ bool BufferedResourceHandler::DelayResponse() { const bool sniffing_blocked = LowerCaseEqualsASCII(content_type_options, "nosniff"); const bool not_modified_status = - response_->response_head.headers && - response_->response_head.headers->response_code() == 304; + response_->headers && response_->headers->response_code() == 304; const bool we_would_like_to_sniff = not_modified_status ? false : net::ShouldSniffMimeType(request_->url(), mime_type); @@ -196,7 +197,7 @@ bool BufferedResourceHandler::DelayResponse() { // mime type. What's a browser to do? Turns out, we're supposed to treat // the response as "text/plain". This is the most secure option. mime_type.assign("text/plain"); - response_->response_head.mime_type.assign(mime_type); + response_->mime_type.assign(mime_type); } if (mime_type == "application/rss+xml" || @@ -209,7 +210,7 @@ bool BufferedResourceHandler::DelayResponse() { // response. In the future, when we have an RSS feed previewer, we can // remove this logic. mime_type.assign("text/plain"); - response_->response_head.mime_type.assign(mime_type); + response_->mime_type.assign(mime_type); } if (!not_modified_status && ShouldWaitForPlugins()) { @@ -256,7 +257,7 @@ bool BufferedResourceHandler::KeepBuffering(int bytes_read) { } } sniff_content_ = false; - response_->response_head.mime_type.assign(new_type); + response_->mime_type.assign(new_type); // We just sniffed the mime type, maybe there is a doctype to process. if (ShouldWaitForPlugins()) @@ -284,8 +285,8 @@ bool BufferedResourceHandler::CompleteResponseStarted(int request_id, // This is entirely similar to how DownloadThrottlingResourceHandler // works except we are doing it for an X.509 client certificates. - if (response_->response_head.headers && // Can be NULL if FTP. - response_->response_head.headers->response_code() / 100 != 2) { + if (response_->headers && // Can be NULL if FTP. + response_->headers->response_code() / 100 != 2) { // The response code indicates that this is an error page, but we are // expecting an X.509 user certificate. We follow Firefox here and show // our own error page instead of handling the error page as a @@ -306,8 +307,8 @@ bool BufferedResourceHandler::CompleteResponseStarted(int request_id, // download thread. // TODO(paulg): Only download if the context from the renderer allows it. if (info->allow_download() && ShouldDownload(NULL)) { - if (response_->response_head.headers && // Can be NULL if FTP. - response_->response_head.headers->response_code() / 100 != 2) { + if (response_->headers && // Can be NULL if FTP. + response_->headers->response_code() / 100 != 2) { // The response code indicates that this is an error page, but we don't // know how to display the content. We follow Firefox here and show our // own error page instead of triggering a download. @@ -366,7 +367,7 @@ bool BufferedResourceHandler::ShouldWaitForPlugins() { bool BufferedResourceHandler::ShouldDownload(bool* need_plugin_list) { if (need_plugin_list) *need_plugin_list = false; - std::string type = StringToLowerASCII(response_->response_head.mime_type); + std::string type = StringToLowerASCII(response_->mime_type); std::string disposition; request_->GetResponseHeaderByName("content-disposition", &disposition); disposition = StringToLowerASCII(disposition); diff --git a/content/browser/renderer_host/buffered_resource_handler.h b/content/browser/renderer_host/buffered_resource_handler.h index f9afcb9..299e258 100644 --- a/content/browser/renderer_host/buffered_resource_handler.h +++ b/content/browser/renderer_host/buffered_resource_handler.h @@ -33,10 +33,10 @@ class BufferedResourceHandler : public ResourceHandler { uint64 size) OVERRIDE; virtual bool OnRequestRedirected(int request_id, const GURL& new_url, - ResourceResponse* response, + content::ResourceResponse* response, bool* defer) OVERRIDE; virtual bool OnResponseStarted(int request_id, - ResourceResponse* response) OVERRIDE; + content::ResourceResponse* response) OVERRIDE; virtual bool OnWillStart(int request_id, const GURL& url, bool* defer) OVERRIDE; @@ -85,7 +85,7 @@ class BufferedResourceHandler : public ResourceHandler { void OnPluginsLoaded(const std::vector<webkit::WebPluginInfo>& plugins); scoped_refptr<ResourceHandler> real_handler_; - scoped_refptr<ResourceResponse> response_; + scoped_refptr<content::ResourceResponse> response_; ResourceDispatcherHost* host_; net::URLRequest* request_; scoped_refptr<net::IOBuffer> read_buffer_; diff --git a/content/browser/renderer_host/cross_site_resource_handler.cc b/content/browser/renderer_host/cross_site_resource_handler.cc index 1394253..72740fc 100644 --- a/content/browser/renderer_host/cross_site_resource_handler.cc +++ b/content/browser/renderer_host/cross_site_resource_handler.cc @@ -13,7 +13,7 @@ #include "content/browser/renderer_host/render_view_host_notification_task.h" #include "content/browser/renderer_host/resource_dispatcher_host.h" #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" -#include "content/common/resource_response.h" +#include "content/public/common/resource_response.h" #include "net/base/io_buffer.h" #include "net/http/http_response_headers.h" @@ -39,18 +39,20 @@ bool CrossSiteResourceHandler::OnUploadProgress(int request_id, return next_handler_->OnUploadProgress(request_id, position, size); } -bool CrossSiteResourceHandler::OnRequestRedirected(int request_id, - const GURL& new_url, - ResourceResponse* response, - bool* defer) { +bool CrossSiteResourceHandler::OnRequestRedirected( + int request_id, + const GURL& new_url, + content::ResourceResponse* response, + bool* defer) { // We should not have started the transition before being redirected. DCHECK(!in_cross_site_transition_); return next_handler_->OnRequestRedirected( request_id, new_url, response, defer); } -bool CrossSiteResourceHandler::OnResponseStarted(int request_id, - ResourceResponse* response) { +bool CrossSiteResourceHandler::OnResponseStarted( + int request_id, + content::ResourceResponse* response) { // At this point, we know that the response is safe to send back to the // renderer: it is not a download, and it has passed the SSL and safe // browsing checks. @@ -80,8 +82,7 @@ bool CrossSiteResourceHandler::OnResponseStarted(int request_id, // cross-site navigation, since we are unable to tell when to destroy it. // See RenderViewHostManager::RendererAbortedProvisionalLoad. if (info->is_download() || - (response->response_head.headers && - response->response_head.headers->response_code() == 204)) { + (response->headers && response->headers->response_code() == 204)) { return next_handler_->OnResponseStarted(request_id, response); } @@ -190,7 +191,7 @@ CrossSiteResourceHandler::~CrossSiteResourceHandler() {} // telling the old RenderViewHost to run its onunload handler. void CrossSiteResourceHandler::StartCrossSiteTransition( int request_id, - ResourceResponse* response, + content::ResourceResponse* response, const GlobalRequestID& global_id) { in_cross_site_transition_ = true; request_id_ = request_id; diff --git a/content/browser/renderer_host/cross_site_resource_handler.h b/content/browser/renderer_host/cross_site_resource_handler.h index eadbf64..a27a7ee 100644 --- a/content/browser/renderer_host/cross_site_resource_handler.h +++ b/content/browser/renderer_host/cross_site_resource_handler.h @@ -30,10 +30,10 @@ class CrossSiteResourceHandler : public ResourceHandler { uint64 size) OVERRIDE; virtual bool OnRequestRedirected(int request_id, const GURL& new_url, - ResourceResponse* response, + content::ResourceResponse* response, bool* defer) OVERRIDE; virtual bool OnResponseStarted(int request_id, - ResourceResponse* response) OVERRIDE; + content::ResourceResponse* response) OVERRIDE; virtual bool OnWillStart(int request_id, const GURL& url, bool* defer) OVERRIDE; @@ -59,7 +59,7 @@ class CrossSiteResourceHandler : public ResourceHandler { // telling the old RenderViewHost to run its onunload handler. void StartCrossSiteTransition( int request_id, - ResourceResponse* response, + content::ResourceResponse* response, const GlobalRequestID& global_id); scoped_refptr<ResourceHandler> next_handler_; @@ -71,7 +71,7 @@ class CrossSiteResourceHandler : public ResourceHandler { bool completed_during_transition_; net::URLRequestStatus completed_status_; std::string completed_security_info_; - ResourceResponse* response_; + content::ResourceResponse* response_; ResourceDispatcherHost* rdh_; DISALLOW_COPY_AND_ASSIGN(CrossSiteResourceHandler); diff --git a/content/browser/renderer_host/redirect_to_file_resource_handler.cc b/content/browser/renderer_host/redirect_to_file_resource_handler.cc index dc107fe..3290e5b 100644 --- a/content/browser/renderer_host/redirect_to_file_resource_handler.cc +++ b/content/browser/renderer_host/redirect_to_file_resource_handler.cc @@ -11,7 +11,7 @@ #include "base/platform_file.h" #include "base/task.h" #include "content/browser/renderer_host/resource_dispatcher_host.h" -#include "content/common/resource_response.h" +#include "content/public/common/resource_response.h" #include "net/base/file_stream.h" #include "net/base/io_buffer.h" #include "net/base/mime_sniffer.h" @@ -50,7 +50,7 @@ bool RedirectToFileResourceHandler::OnUploadProgress(int request_id, bool RedirectToFileResourceHandler::OnRequestRedirected( int request_id, const GURL& new_url, - ResourceResponse* response, + content::ResourceResponse* response, bool* defer) { return next_handler_->OnRequestRedirected(request_id, new_url, response, defer); @@ -58,10 +58,10 @@ bool RedirectToFileResourceHandler::OnRequestRedirected( bool RedirectToFileResourceHandler::OnResponseStarted( int request_id, - ResourceResponse* response) { - if (response->response_head.status.is_success()) { + content::ResourceResponse* response) { + if (response->status.is_success()) { DCHECK(deletable_file_ && !deletable_file_->path().empty()); - response->response_head.download_file_path = deletable_file_->path(); + response->download_file_path = deletable_file_->path(); } return next_handler_->OnResponseStarted(request_id, response); } diff --git a/content/browser/renderer_host/redirect_to_file_resource_handler.h b/content/browser/renderer_host/redirect_to_file_resource_handler.h index 63ed429..b810b05 100644 --- a/content/browser/renderer_host/redirect_to_file_resource_handler.h +++ b/content/browser/renderer_host/redirect_to_file_resource_handler.h @@ -39,10 +39,10 @@ class RedirectToFileResourceHandler : public ResourceHandler { uint64 size) OVERRIDE; virtual bool OnRequestRedirected(int request_id, const GURL& new_url, - ResourceResponse* response, + content::ResourceResponse* response, bool* defer) OVERRIDE; virtual bool OnResponseStarted(int request_id, - ResourceResponse* response) OVERRIDE; + content::ResourceResponse* response) OVERRIDE; virtual bool OnWillStart(int request_id, const GURL& url, bool* defer) OVERRIDE; diff --git a/content/browser/renderer_host/resource_dispatcher_host.cc b/content/browser/renderer_host/resource_dispatcher_host.cc index de6f0af..60367f9 100644 --- a/content/browser/renderer_host/resource_dispatcher_host.cc +++ b/content/browser/renderer_host/resource_dispatcher_host.cc @@ -83,6 +83,7 @@ using base::Time; using base::TimeDelta; using base::TimeTicks; using content::BrowserThread; +using content::ResourceResponse; using webkit_blob::DeletableFileReference; // ---------------------------------------------------------------------------- @@ -141,7 +142,7 @@ void AbortRequestBeforeItStarts(ResourceMessageFilter* filter, net::URLRequestStatus status(net::URLRequestStatus::FAILED, net::ERR_ABORTED); if (sync_result) { - SyncLoadResult result; + content::SyncLoadResult result; result.status = status; ResourceHostMsg_SyncLoad::WriteReplyParams(sync_result, result); filter->Send(sync_result); @@ -202,23 +203,21 @@ bool ShouldServiceRequest(ChildProcessInfo::ProcessType process_type, void PopulateResourceResponse(net::URLRequest* request, ResourceResponse* response) { - response->response_head.status = request->status(); - response->response_head.request_time = request->request_time(); - response->response_head.response_time = request->response_time(); - response->response_head.headers = request->response_headers(); - request->GetCharset(&response->response_head.charset); - response->response_head.content_length = request->GetExpectedContentSize(); - request->GetMimeType(&response->response_head.mime_type); - response->response_head.was_fetched_via_spdy = - request->was_fetched_via_spdy(); - response->response_head.was_npn_negotiated = request->was_npn_negotiated(); - response->response_head.was_fetched_via_proxy = - request->was_fetched_via_proxy(); - response->response_head.socket_address = request->GetSocketAddress(); + response->status = request->status(); + response->request_time = request->request_time(); + response->response_time = request->response_time(); + response->headers = request->response_headers(); + request->GetCharset(&response->charset); + response->content_length = request->GetExpectedContentSize(); + request->GetMimeType(&response->mime_type); + response->was_fetched_via_spdy = request->was_fetched_via_spdy(); + response->was_npn_negotiated = request->was_npn_negotiated(); + response->was_fetched_via_proxy = request->was_fetched_via_proxy(); + response->socket_address = request->GetSocketAddress(); appcache::AppCacheInterceptor::GetExtraResponseInfo( request, - &response->response_head.appcache_id, - &response->response_head.appcache_manifest_url); + &response->appcache_id, + &response->appcache_manifest_url); } void RemoveDownloadFileFromChildSecurityPolicy(int child_id, @@ -1403,7 +1402,7 @@ bool ResourceDispatcherHost::CompleteResponseStarted(net::URLRequest* request) { int cert_id = CertStore::GetInstance()->StoreCert(request->ssl_info().cert, info->child_id()); - response->response_head.security_info = + response->security_info = SSLManager::SerializeSecurityInfo( cert_id, request->ssl_info().cert_status, request->ssl_info().security_bits, diff --git a/content/browser/renderer_host/resource_dispatcher_host_unittest.cc b/content/browser/renderer_host/resource_dispatcher_host_unittest.cc index bba3d9e..65e238d 100644 --- a/content/browser/renderer_host/resource_dispatcher_host_unittest.cc +++ b/content/browser/renderer_host/resource_dispatcher_host_unittest.cc @@ -22,8 +22,8 @@ #include "content/browser/renderer_host/resource_handler.h" #include "content/browser/renderer_host/resource_message_filter.h" #include "content/common/resource_messages.h" -#include "content/common/resource_response.h" #include "content/common/view_messages.h" +#include "content/public/common/resource_response.h" #include "net/base/net_errors.h" #include "net/base/upload_data.h" #include "net/http/http_util.h" @@ -43,7 +43,7 @@ namespace { // Returns the resource response header structure for this request. void GetResponseHead(const std::vector<IPC::Message>& messages, - ResourceResponseHead* response_head) { + content::ResourceResponseHead* response_head) { ASSERT_GE(messages.size(), 2U); // The first messages should be received response. @@ -1007,7 +1007,7 @@ TEST_F(ResourceDispatcherHostTest, MimeSniffed) { accum_.GetClassifiedMessages(&msgs); ASSERT_EQ(1U, msgs.size()); - ResourceResponseHead response_head; + content::ResourceResponseHead response_head; GetResponseHead(msgs[0], &response_head); ASSERT_EQ("text/html", response_head.mime_type); } @@ -1036,7 +1036,7 @@ TEST_F(ResourceDispatcherHostTest, MimeNotSniffed) { accum_.GetClassifiedMessages(&msgs); ASSERT_EQ(1U, msgs.size()); - ResourceResponseHead response_head; + content::ResourceResponseHead response_head; GetResponseHead(msgs[0], &response_head); ASSERT_EQ("image/jpeg", response_head.mime_type); } @@ -1064,7 +1064,7 @@ TEST_F(ResourceDispatcherHostTest, MimeNotSniffed2) { accum_.GetClassifiedMessages(&msgs); ASSERT_EQ(1U, msgs.size()); - ResourceResponseHead response_head; + content::ResourceResponseHead response_head; GetResponseHead(msgs[0], &response_head); ASSERT_EQ("", response_head.mime_type); } @@ -1091,7 +1091,7 @@ TEST_F(ResourceDispatcherHostTest, MimeSniff204) { accum_.GetClassifiedMessages(&msgs); ASSERT_EQ(1U, msgs.size()); - ResourceResponseHead response_head; + content::ResourceResponseHead response_head; GetResponseHead(msgs[0], &response_head); ASSERT_EQ("text/plain", response_head.mime_type); } diff --git a/content/browser/renderer_host/resource_handler.h b/content/browser/renderer_host/resource_handler.h index 85c7f2bc..d086aef 100644 --- a/content/browser/renderer_host/resource_handler.h +++ b/content/browser/renderer_host/resource_handler.h @@ -17,14 +17,17 @@ #include "content/public/browser/browser_thread.h" +class GURL; + +namespace content { +struct ResourceResponse; +} + namespace net { class IOBuffer; class URLRequestStatus; } // namespace net -struct ResourceResponse; -class GURL; - // The resource dispatcher host uses this interface to push load events to the // renderer, allowing for differences in the types of IPC messages generated. // See the implementations of this interface defined below. @@ -41,12 +44,12 @@ class ResourceHandler // false. Set |*defer| to true to defer the redirect. The redirect may be // followed later on via ResourceDispatcherHost::FollowDeferredRedirect. virtual bool OnRequestRedirected(int request_id, const GURL& url, - ResourceResponse* response, + content::ResourceResponse* response, bool* defer) = 0; // Response headers and meta data are available. virtual bool OnResponseStarted(int request_id, - ResourceResponse* response) = 0; + content::ResourceResponse* response) = 0; // Called before the net::URLRequest for |request_id| (whose url is |url|) is // to be started. If the handler returns false, then the request is cancelled. diff --git a/content/browser/renderer_host/sync_resource_handler.cc b/content/browser/renderer_host/sync_resource_handler.cc index e4a53fd..3dfb18e 100644 --- a/content/browser/renderer_host/sync_resource_handler.cc +++ b/content/browser/renderer_host/sync_resource_handler.cc @@ -35,10 +35,11 @@ bool SyncResourceHandler::OnUploadProgress(int request_id, return true; } -bool SyncResourceHandler::OnRequestRedirected(int request_id, - const GURL& new_url, - ResourceResponse* response, - bool* defer) { +bool SyncResourceHandler::OnRequestRedirected( + int request_id, + const GURL& new_url, + content::ResourceResponse* response, + bool* defer) { net::URLRequest* request = rdh_->GetURLRequest( GlobalRequestID(filter_->child_id(), request_id)); if (rdh_->delegate()) @@ -56,8 +57,9 @@ bool SyncResourceHandler::OnRequestRedirected(int request_id, return true; } -bool SyncResourceHandler::OnResponseStarted(int request_id, - ResourceResponse* response) { +bool SyncResourceHandler::OnResponseStarted( + int request_id, + content::ResourceResponse* response) { net::URLRequest* request = rdh_->GetURLRequest( GlobalRequestID(filter_->child_id(), request_id)); if (rdh_->delegate()) @@ -66,16 +68,16 @@ bool SyncResourceHandler::OnResponseStarted(int request_id, DevToolsNetLogObserver::PopulateResponseInfo(request, response); // We don't care about copying the status here. - result_.headers = response->response_head.headers; - result_.mime_type = response->response_head.mime_type; - result_.charset = response->response_head.charset; - result_.download_file_path = response->response_head.download_file_path; - result_.request_time = response->response_head.request_time; - result_.response_time = response->response_head.response_time; - result_.connection_id = response->response_head.connection_id; - result_.connection_reused = response->response_head.connection_reused; - result_.load_timing = response->response_head.load_timing; - result_.devtools_info = response->response_head.devtools_info; + result_.headers = response->headers; + result_.mime_type = response->mime_type; + result_.charset = response->charset; + result_.download_file_path = response->download_file_path; + result_.request_time = response->request_time; + result_.response_time = response->response_time; + result_.connection_id = response->connection_id; + result_.connection_reused = response->connection_reused; + result_.load_timing = response->load_timing; + result_.devtools_info = response->devtools_info; return true; } diff --git a/content/browser/renderer_host/sync_resource_handler.h b/content/browser/renderer_host/sync_resource_handler.h index 0a1ee21..5786c6a 100644 --- a/content/browser/renderer_host/sync_resource_handler.h +++ b/content/browser/renderer_host/sync_resource_handler.h @@ -9,7 +9,7 @@ #include <string> #include "content/browser/renderer_host/resource_handler.h" -#include "content/common/resource_response.h" +#include "content/public/common/resource_response.h" class ResourceDispatcherHost; class ResourceMessageFilter; @@ -36,10 +36,10 @@ class SyncResourceHandler : public ResourceHandler { uint64 size) OVERRIDE; virtual bool OnRequestRedirected(int request_id, const GURL& new_url, - ResourceResponse* response, + content::ResourceResponse* response, bool* defer) OVERRIDE; virtual bool OnResponseStarted(int request_id, - ResourceResponse* response) OVERRIDE; + content::ResourceResponse* response) OVERRIDE; virtual bool OnWillStart(int request_id, const GURL& url, bool* defer) OVERRIDE; @@ -61,7 +61,7 @@ class SyncResourceHandler : public ResourceHandler { scoped_refptr<net::IOBuffer> read_buffer_; - SyncLoadResult result_; + content::SyncLoadResult result_; ResourceMessageFilter* filter_; IPC::Message* result_message_; ResourceDispatcherHost* rdh_; diff --git a/content/browser/renderer_host/x509_user_cert_resource_handler.cc b/content/browser/renderer_host/x509_user_cert_resource_handler.cc index bc40b2b..c068a6f 100644 --- a/content/browser/renderer_host/x509_user_cert_resource_handler.cc +++ b/content/browser/renderer_host/x509_user_cert_resource_handler.cc @@ -8,8 +8,8 @@ #include "content/browser/download/download_types.h" #include "content/browser/renderer_host/resource_dispatcher_host.h" #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" -#include "content/common/resource_response.h" #include "content/public/browser/content_browser_client.h" +#include "content/public/common/resource_response.h" #include "net/base/io_buffer.h" #include "net/base/mime_sniffer.h" #include "net/base/mime_util.h" @@ -36,17 +36,19 @@ bool X509UserCertResourceHandler::OnUploadProgress(int request_id, return true; } -bool X509UserCertResourceHandler::OnRequestRedirected(int request_id, - const GURL& url, - ResourceResponse* resp, - bool* defer) { +bool X509UserCertResourceHandler::OnRequestRedirected( + int request_id, + const GURL& url, + content::ResourceResponse* resp, + bool* defer) { url_ = url; return true; } -bool X509UserCertResourceHandler::OnResponseStarted(int request_id, - ResourceResponse* resp) { - return (resp->response_head.mime_type == "application/x-x509-user-cert"); +bool X509UserCertResourceHandler::OnResponseStarted( + int request_id, + content::ResourceResponse* resp) { + return (resp->mime_type == "application/x-x509-user-cert"); } bool X509UserCertResourceHandler::OnWillStart(int request_id, diff --git a/content/browser/renderer_host/x509_user_cert_resource_handler.h b/content/browser/renderer_host/x509_user_cert_resource_handler.h index 179ec01..81bca8c 100644 --- a/content/browser/renderer_host/x509_user_cert_resource_handler.h +++ b/content/browser/renderer_host/x509_user_cert_resource_handler.h @@ -39,12 +39,12 @@ class X509UserCertResourceHandler : public ResourceHandler { // Not needed, as this event handler ought to be the final resource. virtual bool OnRequestRedirected(int request_id, const GURL& url, - ResourceResponse* resp, + content::ResourceResponse* resp, bool* defer) OVERRIDE; // Check if this indeed an X509 cert. virtual bool OnResponseStarted(int request_id, - ResourceResponse* resp) OVERRIDE; + content::ResourceResponse* resp) OVERRIDE; // Pass-through implementation. virtual bool OnWillStart(int request_id, diff --git a/content/common/resource_dispatcher.cc b/content/common/resource_dispatcher.cc index 4afa078..4bde33b 100644 --- a/content/common/resource_dispatcher.cc +++ b/content/common/resource_dispatcher.cc @@ -15,8 +15,8 @@ #include "base/string_util.h" #include "content/common/request_extra_data.h" #include "content/common/resource_messages.h" -#include "content/common/resource_response.h" #include "content/public/common/resource_dispatcher_delegate.h" +#include "content/public/common/resource_response.h" #include "net/base/net_errors.h" #include "net/base/net_util.h" #include "net/base/upload_data.h" @@ -215,7 +215,7 @@ void IPCResourceLoaderBridge::SyncLoad(SyncLoadResponse* response) { request_id_ = MakeRequestID(); - SyncLoadResult result; + content::SyncLoadResult result; IPC::SyncMessage* msg = new ResourceHostMsg_SyncLoad(routing_id_, request_id_, request_, &result); // NOTE: This may pump events (see RenderThread::Send). @@ -332,7 +332,7 @@ void ResourceDispatcher::OnUploadProgress( } void ResourceDispatcher::OnReceivedResponse( - int request_id, const ResourceResponseHead& response_head) { + int request_id, const content::ResourceResponseHead& response_head) { PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); if (!request_info) return; diff --git a/content/common/resource_dispatcher.h b/content/common/resource_dispatcher.h index ba74b23..1b8e3a3 100644 --- a/content/common/resource_dispatcher.h +++ b/content/common/resource_dispatcher.h @@ -19,10 +19,9 @@ #include "ipc/ipc_channel.h" #include "webkit/glue/resource_loader_bridge.h" -struct ResourceResponseHead; - namespace content { class ResourceDispatcherDelegate; +struct ResourceResponseHead; } // This class serves as a communication interface between the @@ -105,7 +104,7 @@ class CONTENT_EXPORT ResourceDispatcher : public IPC::Channel::Listener { int request_id, int64 position, int64 size); - void OnReceivedResponse(int request_id, const ResourceResponseHead&); + void OnReceivedResponse(int request_id, const content::ResourceResponseHead&); void OnReceivedCachedMetadata(int request_id, const std::vector<char>& data); void OnReceivedRedirect( const IPC::Message& message, diff --git a/content/common/resource_dispatcher_unittest.cc b/content/common/resource_dispatcher_unittest.cc index 2483ea1..e5c8a08 100644 --- a/content/common/resource_dispatcher_unittest.cc +++ b/content/common/resource_dispatcher_unittest.cc @@ -12,7 +12,7 @@ #include "content/common/request_extra_data.h" #include "content/common/resource_dispatcher.h" #include "content/common/resource_messages.h" -#include "content/common/resource_response.h" +#include "content/public/common/resource_response.h" #include "net/base/upload_data.h" #include "net/http/http_response_headers.h" #include "testing/gtest/include/gtest/gtest.h" @@ -114,7 +114,7 @@ class ResourceDispatcherTest : public testing::Test, EXPECT_EQ(test_page_url, request.url.spec()); // received response message - ResourceResponseHead response; + content::ResourceResponseHead response; std::string raw_headers(test_page_headers); std::replace(raw_headers.begin(), raw_headers.end(), '\n', '\0'); response.headers = new net::HttpResponseHeaders(raw_headers); @@ -242,7 +242,7 @@ class DeferredResourceLoadingTest : public ResourceDispatcherTest, void InitMessages() { set_defer_loading(true); - ResourceResponseHead response_head; + content::ResourceResponseHead response_head; response_head.status.set_status(net::URLRequestStatus::SUCCESS); IPC::Message* response_message = diff --git a/content/common/resource_messages.h b/content/common/resource_messages.h index a6982e6..854290a 100644 --- a/content/common/resource_messages.h +++ b/content/common/resource_messages.h @@ -6,8 +6,8 @@ // Multiply-included message file, hence no include guard. #include "base/shared_memory.h" -#include "content/common/resource_response.h" #include "content/public/common/common_param_traits.h" +#include "content/public/common/resource_response.h" #include "ipc/ipc_message_macros.h" #include "net/base/upload_data.h" @@ -15,6 +15,17 @@ #undef IPC_MESSAGE_EXPORT #define IPC_MESSAGE_EXPORT CONTENT_EXPORT +IPC_STRUCT_TRAITS_BEGIN(content::ResourceResponseHead) + IPC_STRUCT_TRAITS_PARENT(webkit_glue::ResourceResponseInfo) + IPC_STRUCT_TRAITS_MEMBER(status) +IPC_STRUCT_TRAITS_END() + +IPC_STRUCT_TRAITS_BEGIN(content::SyncLoadResult) + IPC_STRUCT_TRAITS_PARENT(content::ResourceResponseHead) + IPC_STRUCT_TRAITS_MEMBER(final_url) + IPC_STRUCT_TRAITS_MEMBER(data) +IPC_STRUCT_TRAITS_END() + IPC_STRUCT_TRAITS_BEGIN(webkit_glue::ResourceResponseInfo) IPC_STRUCT_TRAITS_MEMBER(request_time) IPC_STRUCT_TRAITS_MEMBER(response_time) @@ -38,17 +49,6 @@ IPC_STRUCT_TRAITS_BEGIN(webkit_glue::ResourceResponseInfo) IPC_STRUCT_TRAITS_MEMBER(socket_address) IPC_STRUCT_TRAITS_END() -IPC_STRUCT_TRAITS_BEGIN(ResourceResponseHead) - IPC_STRUCT_TRAITS_PARENT(webkit_glue::ResourceResponseInfo) - IPC_STRUCT_TRAITS_MEMBER(status) -IPC_STRUCT_TRAITS_END() - -IPC_STRUCT_TRAITS_BEGIN(SyncLoadResult) - IPC_STRUCT_TRAITS_PARENT(ResourceResponseHead) - IPC_STRUCT_TRAITS_MEMBER(final_url) - IPC_STRUCT_TRAITS_MEMBER(data) -IPC_STRUCT_TRAITS_END() - // Parameters for a resource request. IPC_STRUCT_BEGIN(ResourceHostMsg_Request) // The request method: GET, POST, etc. @@ -118,7 +118,7 @@ IPC_STRUCT_END() // Sent when the headers are available for a resource request. IPC_MESSAGE_ROUTED2(ResourceMsg_ReceivedResponse, int /* request_id */, - ResourceResponseHead) + content::ResourceResponseHead) // Sent when cached metadata from a resource request is ready. IPC_MESSAGE_ROUTED2(ResourceMsg_ReceivedCachedMetadata, @@ -137,7 +137,7 @@ IPC_MESSAGE_ROUTED3(ResourceMsg_UploadProgress, IPC_MESSAGE_ROUTED3(ResourceMsg_ReceivedRedirect, int /* request_id */, GURL /* new_url */, - ResourceResponseHead) + content::ResourceResponseHead) // Sent when some data from a resource request is ready. The handle should // already be mapped into the process that receives this message. @@ -190,7 +190,7 @@ IPC_MESSAGE_ROUTED3(ResourceHostMsg_FollowRedirect, IPC_SYNC_MESSAGE_ROUTED2_1(ResourceHostMsg_SyncLoad, int /* request_id */, ResourceHostMsg_Request, - SyncLoadResult) + content::SyncLoadResult) // Sent when the renderer process is done processing a DataReceived // message. diff --git a/content/common/resource_response.cc b/content/common/resource_response.cc deleted file mode 100644 index a5318f4..0000000 --- a/content/common/resource_response.cc +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "content/common/resource_response.h" - -ResourceResponse::ResourceResponse() { -} - -ResourceResponse::~ResourceResponse() { -} diff --git a/content/content_browser.gypi b/content/content_browser.gypi index 7efb790..64ce8f1 100644 --- a/content/content_browser.gypi +++ b/content/content_browser.gypi @@ -44,6 +44,7 @@ 'public/browser/render_process_host.h', 'public/browser/render_process_host_factory.h', 'public/browser/resource_dispatcher_host_delegate.h', + 'public/browser/resource_response.h', 'public/browser/sensors.h', 'public/browser/sensors_listener.h', 'browser/accessibility/browser_accessibility.cc', diff --git a/content/content_common.gypi b/content/content_common.gypi index a0ca493..507d80e 100644 --- a/content/content_common.gypi +++ b/content/content_common.gypi @@ -215,8 +215,6 @@ 'common/resource_dispatcher.cc', 'common/resource_dispatcher.h', 'common/resource_messages.h', - 'common/resource_response.cc', - 'common/resource_response.h', 'common/sandbox_init_mac.cc', 'common/sandbox_init_win.cc', 'common/sandbox_mac.h', diff --git a/content/public/browser/resource_dispatcher_host_delegate.h b/content/public/browser/resource_dispatcher_host_delegate.h index ca0050d..50ed0a4 100644 --- a/content/public/browser/resource_dispatcher_host_delegate.h +++ b/content/public/browser/resource_dispatcher_host_delegate.h @@ -15,10 +15,10 @@ class GURL; class ResourceDispatcherHostLoginDelegate; class ResourceHandler; class ResourceMessageFilter; -struct ResourceResponse; namespace content { class ResourceContext; +struct ResourceResponse; } namespace net { diff --git a/content/common/resource_response.h b/content/public/common/resource_response.h index 8c949a3..652ef34 100644 --- a/content/common/resource_response.h +++ b/content/public/common/resource_response.h @@ -4,18 +4,21 @@ // See http://dev.chromium.org/developers/design-documents/multi-process-resource-loading -#ifndef CONTENT_COMMON_RESOURCE_RESPONSE_H_ -#define CONTENT_COMMON_RESOURCE_RESPONSE_H_ +#ifndef CONTENT_PUBLIC_COMMON_RESOURCE_RESPONSE_H_ +#define CONTENT_PUBLIC_COMMON_RESOURCE_RESPONSE_H_ #pragma once #include <string> +#include "base/compiler_specific.h" #include "base/memory/ref_counted.h" #include "content/common/content_export.h" #include "googleurl/src/gurl.h" #include "net/url_request/url_request_status.h" #include "webkit/glue/resource_loader_bridge.h" +namespace content { + // Parameters for a resource response header. struct ResourceResponseHead : webkit_glue::ResourceResponseInfo { // The response status. @@ -33,15 +36,15 @@ struct SyncLoadResult : ResourceResponseHead { // Simple wrapper that refcounts ResourceResponseHead. struct CONTENT_EXPORT ResourceResponse - : public base::RefCounted<ResourceResponse> { - ResourceResponse(); - - ResourceResponseHead response_head; + : public NON_EXPORTED_BASE(ResourceResponseHead), + public base::RefCounted<ResourceResponse> { private: friend class base::RefCounted<ResourceResponse>; - ~ResourceResponse(); + ~ResourceResponse() {} }; -#endif // CONTENT_COMMON_RESOURCE_RESPONSE_H_ +} // namespace content + +#endif // CONTENT_PUBLIC_COMMON_RESOURCE_RESPONSE_H_ diff --git a/content/test/render_view_fake_resources_test.cc b/content/test/render_view_fake_resources_test.cc index 0b9825d..b35d4e9 100644 --- a/content/test/render_view_fake_resources_test.cc +++ b/content/test/render_view_fake_resources_test.cc @@ -11,8 +11,8 @@ #include "base/time.h" #include "content/common/dom_storage_common.h" #include "content/common/resource_messages.h" -#include "content/common/resource_response.h" #include "content/common/view_messages.h" +#include "content/public/common/resource_response.h" #include "content/renderer/render_thread_impl.h" #include "content/renderer/render_view_impl.h" #include "content/test/mock_render_process.h" @@ -150,7 +150,7 @@ void RenderViewFakeResourcesTest::OnRequestResource( body = it->second; } - ResourceResponseHead response_head; + content::ResourceResponseHead response_head; response_head.headers = new net::HttpResponseHeaders(headers); response_head.mime_type = "text/html"; ASSERT_TRUE(channel_->Send(new ResourceMsg_ReceivedResponse( |
