diff options
Diffstat (limited to 'chromium/content/browser/loader/cross_site_resource_handler.h')
-rw-r--r-- | chromium/content/browser/loader/cross_site_resource_handler.h | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/chromium/content/browser/loader/cross_site_resource_handler.h b/chromium/content/browser/loader/cross_site_resource_handler.h index 29e3f5acdbc..257af02c01b 100644 --- a/chromium/content/browser/loader/cross_site_resource_handler.h +++ b/chromium/content/browser/loader/cross_site_resource_handler.h @@ -6,7 +6,9 @@ #define CONTENT_BROWSER_LOADER_CROSS_SITE_RESOURCE_HANDLER_H_ #include "base/memory/ref_counted.h" +#include "base/memory/weak_ptr.h" #include "content/browser/loader/layered_resource_handler.h" +#include "content/common/content_export.h" #include "net/url_request/url_request_status.h" namespace net { @@ -27,18 +29,14 @@ class CrossSiteResourceHandler : public LayeredResourceHandler { virtual ~CrossSiteResourceHandler(); // ResourceHandler implementation: - virtual bool OnRequestRedirected(int request_id, - const GURL& new_url, + virtual bool OnRequestRedirected(const GURL& new_url, ResourceResponse* response, bool* defer) OVERRIDE; - virtual bool OnResponseStarted(int request_id, - ResourceResponse* response, + virtual bool OnResponseStarted(ResourceResponse* response, bool* defer) OVERRIDE; - virtual bool OnReadCompleted(int request_id, - int bytes_read, + virtual bool OnReadCompleted(int bytes_read, bool* defer) OVERRIDE; - virtual void OnResponseCompleted(int request_id, - const net::URLRequestStatus& status, + virtual void OnResponseCompleted(const net::URLRequestStatus& status, const std::string& security_info, bool* defer) OVERRIDE; @@ -46,15 +44,30 @@ class CrossSiteResourceHandler : public LayeredResourceHandler { // WebContentsImpl to swap in the new renderer and destroy the old one. void ResumeResponse(); + // When set to true, requests are leaked when they can't be passed to a + // RenderViewHost, for unit tests. + CONTENT_EXPORT static void SetLeakRequestsForTesting( + bool leak_requests_for_testing); + private: // Prepare to render the cross-site response in a new RenderViewHost, by // telling the old RenderViewHost to run its onunload handler. - void StartCrossSiteTransition(int request_id, - ResourceResponse* response, + void StartCrossSiteTransition(ResourceResponse* response, bool should_transfer); + // Defer the navigation to the UI thread to check whether transfer is required + // or not. Currently only used in --site-per-process. + bool DeferForNavigationPolicyCheck(ResourceRequestInfoImpl* info, + ResourceResponse* response, + bool* defer); + + void ResumeOrTransfer(bool is_transfer); void ResumeIfDeferred(); + // Called when about to defer a request. Sets |did_defer_| and logs the + // defferral + void OnDidDefer(); + bool has_started_response_; bool in_cross_site_transition_; bool completed_during_transition_; @@ -63,6 +76,12 @@ class CrossSiteResourceHandler : public LayeredResourceHandler { std::string completed_security_info_; scoped_refptr<ResourceResponse> response_; + // TODO(nasko): WeakPtr is needed in --site-per-process, since all navigations + // are deferred to the UI thread and come back to IO thread via + // PostTaskAndReplyWithResult. If a transfer is needed, it goes back to the UI + // thread. This can be removed once the code is changed to only do one hop. + base::WeakPtrFactory<CrossSiteResourceHandler> weak_ptr_factory_; + DISALLOW_COPY_AND_ASSIGN(CrossSiteResourceHandler); }; |