Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(642)

Unified Diff: content/browser/loader/intercepting_resource_handler.h

Issue 2743723003: Add buffering to MimeSniffingResourceHandler.
Patch Set: Remove unused 'first_call' variable. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/loader/intercepting_resource_handler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/loader/intercepting_resource_handler.h
diff --git a/content/browser/loader/intercepting_resource_handler.h b/content/browser/loader/intercepting_resource_handler.h
index cbfbba4f99cf55a3b77020416ae06499baa6bb1c..d30776660f356a66b7978ed63907845daecd9ca7 100644
--- a/content/browser/loader/intercepting_resource_handler.h
+++ b/content/browser/loader/intercepting_resource_handler.h
@@ -56,9 +56,11 @@ class CONTENT_EXPORT InterceptingResourceHandler
// Replaces the next handler with |new_handler|, sending
// |payload_for_old_handler| to the old handler. Must be called after
- // OnWillStart and OnRequestRedirected and before OnResponseStarted. One
- // OnWillRead call is permitted beforehand. |new_handler|'s OnWillStart and
- // OnRequestRedirected methods will not be called.
+ // OnWillStart and OnRequestRedirected and before OnResponseStarted.
+ // OnWillRead may not be called be called before this call. |new_handler|'s
+ // OnRequestRedirected method will not be called. |new_handler|'s
+ // OnWillStart() method will be called following the call to
+ // InterceptingResourceHandler::OnResponseStarted.
void UseNewHandler(std::unique_ptr<ResourceHandler> new_handler,
const std::string& payload_for_old_handler);
@@ -82,12 +84,6 @@ class CONTENT_EXPORT InterceptingResourceHandler
// handlers.
SWAPPING_HANDLERS,
- // States where the InterceptingResourceHandler passes the initial
- // OnWillRead call to the old handler, and then waits for the resulting
- // buffer read buffer.
- SENDING_ON_WILL_READ_TO_OLD_HANDLER,
- WAITING_FOR_OLD_HANDLERS_BUFFER,
-
// The InterceptingResourceHandler is sending the payload given via
// UseNewHandler to the old handler. The first state starts retrieving a
// buffer from the old handler, the second state copies as much of the data
@@ -98,26 +94,9 @@ class CONTENT_EXPORT InterceptingResourceHandler
// The InterceptingResourcHandler is calling the new handler's
// OnResponseStarted method and waiting for its completion via Resume().
// After completion, the InterceptingResourceHandler will transition to
- // SENDING_ON_RESPONSE_STARTED_TO_NEW_HANDLER on success.
+ // PASS_THROUGH on success.
SENDING_ON_WILL_START_TO_NEW_HANDLER,
- // The InterceptingResourcHandler is calling the new handler's
- // OnResponseStarted method and waiting for its completion via Resume().
- // After completion, the InterceptingResourceHandler will transition to
- // WAITING_FOR_ON_READ_COMPLETED on success.
- SENDING_ON_RESPONSE_STARTED_TO_NEW_HANDLER,
-
- // The InterceptingResourcHandler is waiting for OnReadCompleted to be
- // called.
- WAITING_FOR_ON_READ_COMPLETED,
-
- // The two phases of uploading previously received data stored in
- // |first_read_buffer_double_| to the new handler, which is now stored in
- // |next_handler_|. The first state gets a buffer to write to, and the next
- // copies all the data it can to that buffer.
- SENDING_BUFFER_TO_NEW_HANDLER,
- SENDING_BUFFER_TO_NEW_HANDLER_WAITING_FOR_BUFFER,
-
// The InterceptingResourceHandler has replaced its next ResourceHandler if
// needed, and has ensured the buffered read data was properly transmitted
// to the new ResourceHandler. The InterceptingResourceHandler now acts as
@@ -135,7 +114,6 @@ class CONTENT_EXPORT InterceptingResourceHandler
void SendOnResponseStartedToOldHandler();
void SendPayloadToOldHandler();
void ReceivedBufferFromOldHandler();
- void SendFirstReadBufferToNewHandler();
void SendOnResponseStartedToNewHandler();
void ReceivedBufferFromNewHandler();
@@ -145,27 +123,9 @@ class CONTENT_EXPORT InterceptingResourceHandler
std::string payload_for_old_handler_;
size_t payload_bytes_written_ = 0;
- // Result of the first read, that may have to be passed to an alternate
- // ResourceHandler instead of the original ResourceHandler.
- scoped_refptr<net::IOBuffer> first_read_buffer_;
- // Instead of |first_read_buffer_|, this handler creates a new IOBuffer with
- // the same size and return it to the client.
- scoped_refptr<net::IOBuffer> first_read_buffer_double_;
- int first_read_buffer_size_ = 0;
- int first_read_buffer_bytes_read_ = 0;
- int first_read_buffer_bytes_written_ = 0;
-
- // Information about the new handler's buffer while copying data from
- // |first_read_buffer_double_| to the new handler's buffer.
- // Note that when these are used, the old handler has been destroyed, and
- // |next_handler_| is now the new one.
- scoped_refptr<net::IOBuffer> new_handler_read_buffer_;
- int new_handler_read_buffer_size_ = 0;
-
- // Pointers to parent-owned read buffer and its size. Only used for first
- // OnWillRead call.
- scoped_refptr<net::IOBuffer>* parent_read_buffer_ = nullptr;
- int* parent_read_buffer_size_ = nullptr;
+ // Buffer pointers used for passing a payload to the old handler.
+ scoped_refptr<net::IOBuffer> read_buffer_;
+ int read_buffer_size_ = 0;
scoped_refptr<ResourceResponse> response_;
« no previous file with comments | « no previous file | content/browser/loader/intercepting_resource_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698