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

Unified Diff: content/browser/loader/mime_sniffing_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
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 21200938cb7bb5e76a8fb4c2832d8696d3c05cf9..017cd891d4d032e9600457cdbe5023c593f12ad3 100644
--- a/content/browser/loader/mime_sniffing_resource_handler.h
+++ b/content/browser/loader/mime_sniffing_resource_handler.h
@@ -66,11 +66,6 @@ class CONTENT_EXPORT MimeSniffingResourceHandler
// about request interception.
STATE_BUFFERING,
- // In these states, the MimeSniffingResourceHandler is calling OnWillRead on
- // the downstream ResourceHandler and then waiting for the response.
- STATE_CALLING_ON_WILL_READ,
- STATE_WAITING_FOR_BUFFER,
-
// In this state, the MimeSniffingResourceHandler has identified the mime
// type and made a decision on whether the request should be intercepted or
// not. It is nows attempting to replay the response to downstream
@@ -78,9 +73,17 @@ class CONTENT_EXPORT MimeSniffingResourceHandler
STATE_INTERCEPTION_CHECK_DONE,
// In this state, the MimeSniffingResourceHandler is replaying the buffered
- // OnResponseStarted event to the downstream ResourceHandlers.
+ // OnResponseStarted event to the downstream ResourceHandlers. This state
+ // will transition to the next state if there is more data to replay, or
+ // to STATE_STREAMING when replay is done.
STATE_REPLAYING_RESPONSE_RECEIVED,
+ // In this state, the MimeSniffingResourceHandler is replaying the buffered
+ // OnResponseStarted event to the downstream ResourceHandlers, and is
+ // waiting for a buffer from those handlers. This state always
+ // transitions to the previous one.
+ STATE_REPLAYING_WAIT_FOR_WILL_READ,
+
// In this state, the MimeSniffingResourceHandler is just a blind
// pass-through
// ResourceHandler.
@@ -116,15 +119,12 @@ class CONTENT_EXPORT MimeSniffingResourceHandler
// Intercepts the request as a stream/download if needed.
void MaybeIntercept();
- // Calls OnWillRead on the downstream handlers.
- void CallOnWillRead();
-
- // Copies received buffer to parent.
- void BufferReceived();
-
// Replays OnResponseStarted on the downstream handlers.
void ReplayResponseReceived();
+ // Gets a buffer for read completion.
+ void ReplayGetBuffer();
+
// Replays OnReadCompleted on the downstreams handlers.
void ReplayReadCompleted();
@@ -178,11 +178,11 @@ class CONTENT_EXPORT MimeSniffingResourceHandler
scoped_refptr<net::IOBuffer> read_buffer_;
int read_buffer_size_;
int bytes_read_;
+ int bytes_replayed_;
- // Pointers to parent-owned read buffer and its size. Only used for first
- // OnWillRead call.
- scoped_refptr<net::IOBuffer>* parent_read_buffer_;
- int* parent_read_buffer_size_;
+ // Downstream buffer information for replay.
+ scoped_refptr<net::IOBuffer> out_buffer_;
+ int out_buffer_size_;
// The InterceptingResourceHandler that will perform ResourceHandler swap if
// needed.

Powered by Google App Engine
This is Rietveld 408576698