| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef ThreadableLoader_h | 31 #ifndef ThreadableLoader_h |
| 32 #define ThreadableLoader_h | 32 #define ThreadableLoader_h |
| 33 | 33 |
| 34 #include "core/CoreExport.h" | 34 #include "core/CoreExport.h" |
| 35 #include "core/fetch/ResourceLoaderOptions.h" | 35 #include "core/fetch/ResourceLoaderOptions.h" |
| 36 #include "platform/CrossThreadCopier.h" | 36 #include "platform/CrossThreadCopier.h" |
| 37 #include "platform/heap/Handle.h" | |
| 38 #include "wtf/Allocator.h" | 37 #include "wtf/Allocator.h" |
| 39 #include "wtf/Noncopyable.h" | 38 #include "wtf/Noncopyable.h" |
| 40 #include <memory> | 39 #include <memory> |
| 41 | 40 |
| 42 namespace blink { | 41 namespace blink { |
| 43 | 42 |
| 44 class ResourceRequest; | 43 class ResourceRequest; |
| 45 class ExecutionContext; | 44 class ExecutionContext; |
| 46 class ThreadableLoaderClient; | 45 class ThreadableLoaderClient; |
| 47 | 46 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 // just able to run on threads other than the main thread). | 119 // just able to run on threads other than the main thread). |
| 121 // | 120 // |
| 122 // Arguments common to both loadResourceSynchronously() and create(): | 121 // Arguments common to both loadResourceSynchronously() and create(): |
| 123 // | 122 // |
| 124 // - ThreadableLoaderOptions argument configures this ThreadableLoader's | 123 // - ThreadableLoaderOptions argument configures this ThreadableLoader's |
| 125 // behavior. | 124 // behavior. |
| 126 // | 125 // |
| 127 // - ResourceLoaderOptions argument will be passed to the FetchRequest | 126 // - ResourceLoaderOptions argument will be passed to the FetchRequest |
| 128 // that this ThreadableLoader creates. It can be altered e.g. when | 127 // that this ThreadableLoader creates. It can be altered e.g. when |
| 129 // redirect happens. | 128 // redirect happens. |
| 130 class CORE_EXPORT ThreadableLoader : public GarbageCollectedFinalized<Threadable
Loader> { | 129 class CORE_EXPORT ThreadableLoader { |
| 131 WTF_MAKE_NONCOPYABLE(ThreadableLoader); | 130 WTF_MAKE_NONCOPYABLE(ThreadableLoader); |
| 132 public: | 131 public: |
| 133 // ThreadableLoaderClient methods may not destroy the ThreadableLoader | 132 // ThreadableLoaderClient methods may not destroy the ThreadableLoader |
| 134 // instance in them. | 133 // instance in them. |
| 135 static void loadResourceSynchronously(ExecutionContext&, const ResourceReque
st&, ThreadableLoaderClient&, const ThreadableLoaderOptions&, const ResourceLoad
erOptions&); | 134 static void loadResourceSynchronously(ExecutionContext&, const ResourceReque
st&, ThreadableLoaderClient&, const ThreadableLoaderOptions&, const ResourceLoad
erOptions&); |
| 136 | 135 |
| 137 // This method never returns nullptr. | 136 // This method never returns nullptr. |
| 138 // | 137 // |
| 139 // This method must always be followed by start() call. | 138 // This method must always be followed by start() call. |
| 140 // ThreadableLoaderClient methods are never called before start() call. | 139 // ThreadableLoaderClient methods are never called before start() call. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 161 // ThreadableLoaderClient::didFail() is called with a ResourceError | 160 // ThreadableLoaderClient::didFail() is called with a ResourceError |
| 162 // with isCancellation() returning true, if any of didFinishLoading() | 161 // with isCancellation() returning true, if any of didFinishLoading() |
| 163 // or didFail.*() methods have not been called yet. (didFail() may be | 162 // or didFail.*() methods have not been called yet. (didFail() may be |
| 164 // called with a ResourceError with isCancellation() returning true | 163 // called with a ResourceError with isCancellation() returning true |
| 165 // also for cancellation happened inside the loader.) | 164 // also for cancellation happened inside the loader.) |
| 166 // | 165 // |
| 167 // ThreadableLoaderClient methods: | 166 // ThreadableLoaderClient methods: |
| 168 // - may call cancel() | 167 // - may call cancel() |
| 169 // - can destroy the ThreadableLoader instance in them (by clearing | 168 // - can destroy the ThreadableLoader instance in them (by clearing |
| 170 // std::unique_ptr<ThreadableLoader>). | 169 // std::unique_ptr<ThreadableLoader>). |
| 171 static ThreadableLoader* create(ExecutionContext&, ThreadableLoaderClient*,
const ThreadableLoaderOptions&, const ResourceLoaderOptions&); | 170 static std::unique_ptr<ThreadableLoader> create(ExecutionContext&, Threadabl
eLoaderClient*, const ThreadableLoaderOptions&, const ResourceLoaderOptions&); |
| 172 | 171 |
| 173 // The methods on the ThreadableLoaderClient passed on create() call | 172 // The methods on the ThreadableLoaderClient passed on create() call |
| 174 // may be called synchronous to start() call. | 173 // may be called synchronous to start() call. |
| 175 virtual void start(const ResourceRequest&) = 0; | 174 virtual void start(const ResourceRequest&) = 0; |
| 176 | 175 |
| 177 // A ThreadableLoader may have a timeout specified. It is possible, in some
cases, for | 176 // A ThreadableLoader may have a timeout specified. It is possible, in some
cases, for |
| 178 // the timeout to be overridden after the request is sent (for example, XMLH
ttpRequests | 177 // the timeout to be overridden after the request is sent (for example, XMLH
ttpRequests |
| 179 // may override their timeout setting after sending). | 178 // may override their timeout setting after sending). |
| 180 // | 179 // |
| 181 // Set a new timeout relative to the time the request started, in millisecon
ds. | 180 // Set a new timeout relative to the time the request started, in millisecon
ds. |
| 182 virtual void overrideTimeout(unsigned long timeoutMilliseconds) = 0; | 181 virtual void overrideTimeout(unsigned long timeoutMilliseconds) = 0; |
| 183 | 182 |
| 184 virtual void cancel() = 0; | 183 virtual void cancel() = 0; |
| 185 | 184 |
| 186 virtual ~ThreadableLoader() { } | 185 virtual ~ThreadableLoader() { } |
| 187 | 186 |
| 188 DEFINE_INLINE_VIRTUAL_TRACE() {} | |
| 189 | |
| 190 protected: | 187 protected: |
| 191 ThreadableLoader() { } | 188 ThreadableLoader() { } |
| 192 }; | 189 }; |
| 193 | 190 |
| 194 } // namespace blink | 191 } // namespace blink |
| 195 | 192 |
| 196 #endif // ThreadableLoader_h | 193 #endif // ThreadableLoader_h |
| OLD | NEW |