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

Unified Diff: third_party/WebKit/Source/core/loader/ThreadableLoader.h

Issue 1264453002: Split the constructor of ThreadableLoader into two methods (ctor and start()) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Removed pipes around non-variables in a comment Created 4 years, 10 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: third_party/WebKit/Source/core/loader/ThreadableLoader.h
diff --git a/third_party/WebKit/Source/core/loader/ThreadableLoader.h b/third_party/WebKit/Source/core/loader/ThreadableLoader.h
index 5a883921b57fff71fc72d7dd58c866491e2b5f1f..ef4d9158d12e8b79c19e42e5e00ddfff5bd56f94 100644
--- a/third_party/WebKit/Source/core/loader/ThreadableLoader.h
+++ b/third_party/WebKit/Source/core/loader/ThreadableLoader.h
@@ -133,30 +133,46 @@ public:
// ThreadableLoaderClient methods may not destroy the ThreadableLoader
// instance in them.
static void loadResourceSynchronously(ExecutionContext&, const ResourceRequest&, ThreadableLoaderClient&, const ThreadableLoaderOptions&, const ResourceLoaderOptions&);
+
+ // This method never returns nullptr.
+ //
+ // This method must always be followed by start() call.
+ // ThreadableLoaderClient methods are never called before start() call.
+ //
+ // The async loading feature is separated into the create() method and
+ // and the start() method in order to:
+ // - reduce work done in a constructor
+ // - not to ask the users to handle failures in the constructor and other
+ // async failures separately
+ //
// Loading completes when one of the following methods are called:
// - didFinishLoading()
// - didFail()
// - didFailAccessControlCheck()
// - didFailRedirectCheck()
- // After any of these methods is called, no ThreadableLoaderClient method
- // will be called.
+ // After any of these methods is called, the loader won't call any of the
+ // ThreadableLoaderClient methods.
//
- // When ThreadableLoader is destructed, ThreadableLoaderClient methods are
- // NOT called in response to the destruction synchronously or after
- // destruction.
+ // When a ThreadableLoader is destructed, any of the
+ // ThreadableLoaderClient methods is NOT called in response to the
+ // destruction either synchronously or after destruction.
//
// When ThreadableLoader::cancel() is called,
- // ThreadableLoaderClient::didFail() is called with ResourceError with
- // isCancellation() returning true, if any of didFinishLoading() or
- // didFail.*() methods have not been called yet. (didFail() may be called
- // with a ResourceError with isCancellation() returning true also for
- // cancellation happened inside the loader.)
+ // ThreadableLoaderClient::didFail() is called with a ResourceError
+ // with isCancellation() returning true, if any of didFinishLoading()
+ // or didFail.*() methods have not been called yet. (didFail() may be
+ // called with a ResourceError with isCancellation() returning true
+ // also for cancellation happened inside the loader.)
//
// ThreadableLoaderClient methods:
// - may call cancel()
// - can destroy the ThreadableLoader instance in them (by clearing
// RefPtr<ThreadableLoader>).
- static PassRefPtr<ThreadableLoader> create(ExecutionContext&, ThreadableLoaderClient*, const ResourceRequest&, const ThreadableLoaderOptions&, const ResourceLoaderOptions&);
+ static PassRefPtr<ThreadableLoader> create(ExecutionContext&, ThreadableLoaderClient*, const ThreadableLoaderOptions&, const ResourceLoaderOptions&);
+
+ // The methods on the ThreadableLoaderClient passed on create() call
+ // may be called synchronous to start() call.
+ virtual void start(const ResourceRequest&) = 0;
// A ThreadableLoader may have a timeout specified. It is possible, in some cases, for
// the timeout to be overridden after the request is sent (for example, XMLHttpRequests

Powered by Google App Engine
This is Rietveld 408576698