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

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

Issue 2668603003: Make ResourceHandler::OnWillRead able to complete asynchronously. (Closed)
Patch Set: One bot doesn't like 256 day timers. :( Created 3 years, 11 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/resource_loader.h
diff --git a/content/browser/loader/resource_loader.h b/content/browser/loader/resource_loader.h
index e7da4b7cf67a3d18d3fe88facd4b2e300aa4f391..ce610e0a902ca19c6c01ee4651021753d9249178 100644
--- a/content/browser/loader/resource_loader.h
+++ b/content/browser/loader/resource_loader.h
@@ -99,8 +99,11 @@ class CONTENT_EXPORT ResourceLoader : public net::URLRequest::Delegate,
void CancelRequestInternal(int error, bool from_renderer);
void FollowDeferredRedirectInternal();
void CompleteResponseStarted();
- // If |handle_result_async| is true, the result of a read that completed
- // synchronously will be handled asynchronously, except on EOF or error.
+ // If |handle_result_async| is true, the result of the following read will be
+ // handled asynchronously if it completes synchronously, unless it's EOF or an
+ // error. This is to prevent a single request from blocking the thread for too
+ // long.
+ void PrepareToReadMore(bool handle_result_async);
void ReadMore(bool handle_result_async);
void ResumeReading();
// Passes a read result to the handler.
@@ -133,6 +136,7 @@ class CONTENT_EXPORT ResourceLoader : public net::URLRequest::Delegate,
DEFERRED_SYNC,
DEFERRED_START,
DEFERRED_REDIRECT,
+ DEFERRED_ON_WILL_READ,
DEFERRED_READ,
DEFERRED_RESPONSE_COMPLETE,
DEFERRED_FINISH
@@ -167,6 +171,11 @@ class CONTENT_EXPORT ResourceLoader : public net::URLRequest::Delegate,
// Stores the URL from a deferred redirect.
GURL deferred_redirect_url_;
+ // Read buffer and its size. Class members as OnWillRead can complete
+ // asynchronously.
+ scoped_refptr<net::IOBuffer> read_buffer_;
+ int read_buffer_size_;
+
base::WeakPtrFactory<ResourceLoader> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(ResourceLoader);

Powered by Google App Engine
This is Rietveld 408576698