Index: content/browser/loader/mime_sniffing_resource_handler.h |
diff --git a/content/browser/loader/mime_sniffing_resource_handler.h b/content/browser/loader/mime_sniffing_resource_handler.h |
index 0effee5e386d72750f95184f66831778f4065d5a..ab0265d93c89fbccaf7b9aec8e6f3cf8d8de06a9 100644 |
--- a/content/browser/loader/mime_sniffing_resource_handler.h |
+++ b/content/browser/loader/mime_sniffing_resource_handler.h |
@@ -23,6 +23,7 @@ class URLRequest; |
namespace content { |
class InterceptingResourceHandler; |
class PluginService; |
+class ResourceController; |
class ResourceDispatcherHostImpl; |
struct WebPluginInfo; |
@@ -39,8 +40,7 @@ struct WebPluginInfo; |
// Accept header on the request based on its ResourceType, if one isn't already |
// present. |
class CONTENT_EXPORT MimeSniffingResourceHandler |
- : public LayeredResourceHandler, |
- public ResourceController { |
+ : public LayeredResourceHandler { |
public: |
MimeSniffingResourceHandler(std::unique_ptr<ResourceHandler> next_handler, |
ResourceDispatcherHostImpl* host, |
@@ -51,6 +51,8 @@ class CONTENT_EXPORT MimeSniffingResourceHandler |
~MimeSniffingResourceHandler() override; |
private: |
+ class Controller; |
+ |
friend class MimeSniffingResourceHandlerTest; |
enum State { |
// Starting state of the MimeSniffingResourceHandler. In this state, it is |
@@ -80,21 +82,21 @@ class CONTENT_EXPORT MimeSniffingResourceHandler |
}; |
// ResourceHandler implementation: |
- void SetController(ResourceController* controller) override; |
- bool OnWillStart(const GURL&, bool* defer) override; |
- bool OnResponseStarted(ResourceResponse* response, bool* defer) override; |
+ void OnWillStart(const GURL&, |
+ std::unique_ptr<ResourceController> controller) override; |
+ void OnResponseStarted( |
+ ResourceResponse* response, |
+ std::unique_ptr<ResourceController> controller) override; |
bool OnWillRead(scoped_refptr<net::IOBuffer>* buf, |
int* buf_size, |
int min_size) override; |
- bool OnReadCompleted(int bytes_read, bool* defer) override; |
- void OnResponseCompleted(const net::URLRequestStatus& status, |
- bool* defer) override; |
+ void OnReadCompleted(int bytes_read, |
+ std::unique_ptr<ResourceController> controller) override; |
+ void OnResponseCompleted( |
+ const net::URLRequestStatus& status, |
+ std::unique_ptr<ResourceController> controller) override; |
- // ResourceController implementation: |
- void Resume() override; |
- void Cancel() override; |
- void CancelAndIgnore() override; |
- void CancelWithError(int error_code) override; |
+ void ResumeInternal(); |
// -------------------------------------------------------------------------- |
// The following methods replay the buffered data to the downstream |
@@ -104,16 +106,15 @@ class CONTENT_EXPORT MimeSniffingResourceHandler |
// Used to advance through the states of the state machine. |
void AdvanceState(); |
- bool ProcessState(bool* defer); |
// Intercepts the request as a stream/download if needed. |
- bool MaybeIntercept(bool* defer); |
+ void MaybeIntercept(); |
// Replays OnResponseStarted on the downstream handlers. |
- bool ReplayResponseReceived(bool* defer); |
+ void ReplayResponseReceived(); |
// Replays OnReadCompleted on the downstreams handlers. |
- bool ReplayReadCompleted(bool* defer); |
+ void ReplayReadCompleted(); |
// -------------------------------------------------------------------------- |
@@ -123,18 +124,20 @@ class CONTENT_EXPORT MimeSniffingResourceHandler |
// Checks whether this request should be intercepted as a stream or a |
// download. If this is the case, sets up the new ResourceHandler that will be |
- // used for interception. Returns false if teh request should be cancelled, |
- // true otherwise. |defer| is set to true if the interception check needs to |
- // finish asynchronously. |
- bool MaybeStartInterception(bool* defer); |
+ // used for interception. |
+ // |
+ // Returns true on synchronous success, false if the operation will need to |
+ // complete asynchronously or failure. On failure, also cancels the request. |
+ bool MaybeStartInterception(); |
// Determines whether a plugin will handle the current request. Returns false |
// if there is an error and the request should be cancelled and true |
- // otherwise. |defer| is set to true if plugin data is stale and needs to be |
- // refreshed before the request can be handled (in this case the function |
- // still returns true). If the request is directed to a plugin, |
- // |handled_by_plugin| is set to true. |
- bool CheckForPluginHandler(bool* defer, bool* handled_by_plugin); |
+ // otherwise. If the request is directed to a plugin, |handled_by_plugin| is |
+ // set to true. |
+ // |
+ // Returns true on synchronous success, false if the operation will need to |
+ // complete asynchronously or failure. On failure, also cancels the request. |
+ bool CheckForPluginHandler(bool* handled_by_plugin); |
// Whether this request is allowed to be intercepted as a download or a |
// stream. |