| 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 18 matching lines...) Expand all  Loading... | 
|   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 "wtf/Allocator.h" |   37 #include "wtf/Allocator.h" | 
|   38 #include "wtf/Noncopyable.h" |   38 #include "wtf/Noncopyable.h" | 
|   39 #include "wtf/PassRefPtr.h" |   39 #include "wtf/PassOwnPtr.h" | 
|   40 #include "wtf/RefCounted.h" |  | 
|   41 #include "wtf/RefPtr.h" |  | 
|   42  |   40  | 
|   43 namespace blink { |   41 namespace blink { | 
|   44  |   42  | 
|   45 class ResourceRequest; |   43 class ResourceRequest; | 
|   46 class ExecutionContext; |   44 class ExecutionContext; | 
|   47 class ThreadableLoaderClient; |   45 class ThreadableLoaderClient; | 
|   48  |   46  | 
|   49 enum CrossOriginRequestPolicy { |   47 enum CrossOriginRequestPolicy { | 
|   50     DenyCrossOriginRequests, |   48     DenyCrossOriginRequests, | 
|   51     UseAccessControl, |   49     UseAccessControl, | 
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  121 // just able to run on threads other than the main thread). |  119 // just able to run on threads other than the main thread). | 
|  122 // |  120 // | 
|  123 // Arguments common to both loadResourceSynchronously() and create(): |  121 // Arguments common to both loadResourceSynchronously() and create(): | 
|  124 // |  122 // | 
|  125 // - ThreadableLoaderOptions argument configures this ThreadableLoader's |  123 // - ThreadableLoaderOptions argument configures this ThreadableLoader's | 
|  126 //   behavior. |  124 //   behavior. | 
|  127 // |  125 // | 
|  128 // - ResourceLoaderOptions argument will be passed to the FetchRequest |  126 // - ResourceLoaderOptions argument will be passed to the FetchRequest | 
|  129 //   that this ThreadableLoader creates. It can be altered e.g. when |  127 //   that this ThreadableLoader creates. It can be altered e.g. when | 
|  130 //   redirect happens. |  128 //   redirect happens. | 
|  131 class CORE_EXPORT ThreadableLoader : public RefCounted<ThreadableLoader> { |  129 class CORE_EXPORT ThreadableLoader { | 
|  132     WTF_MAKE_NONCOPYABLE(ThreadableLoader); |  130     WTF_MAKE_NONCOPYABLE(ThreadableLoader); | 
|  133 public: |  131 public: | 
|  134     // ThreadableLoaderClient methods may not destroy the ThreadableLoader |  132     // ThreadableLoaderClient methods may not destroy the ThreadableLoader | 
|  135     // instance in them. |  133     // instance in them. | 
|  136     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&); | 
|  137  |  135  | 
|  138     // This method never returns nullptr. |  136     // This method never returns nullptr. | 
|  139     // |  137     // | 
|  140     // This method must always be followed by start() call. |  138     // This method must always be followed by start() call. | 
|  141     // ThreadableLoaderClient methods are never called before start() call. |  139     // ThreadableLoaderClient methods are never called before start() call. | 
| (...skipping 19 matching lines...) Expand all  Loading... | 
|  161     // When ThreadableLoader::cancel() is called, |  159     // When ThreadableLoader::cancel() is called, | 
|  162     // ThreadableLoaderClient::didFail() is called with a ResourceError |  160     // ThreadableLoaderClient::didFail() is called with a ResourceError | 
|  163     // with isCancellation() returning true, if any of didFinishLoading() |  161     // with isCancellation() returning true, if any of didFinishLoading() | 
|  164     // or didFail.*() methods have not been called yet. (didFail() may be |  162     // or didFail.*() methods have not been called yet. (didFail() may be | 
|  165     // called with a ResourceError with isCancellation() returning true |  163     // called with a ResourceError with isCancellation() returning true | 
|  166     // also for cancellation happened inside the loader.) |  164     // also for cancellation happened inside the loader.) | 
|  167     // |  165     // | 
|  168     // ThreadableLoaderClient methods: |  166     // ThreadableLoaderClient methods: | 
|  169     // - may call cancel() |  167     // - may call cancel() | 
|  170     // - can destroy the ThreadableLoader instance in them (by clearing |  168     // - can destroy the ThreadableLoader instance in them (by clearing | 
|  171     //   RefPtr<ThreadableLoader>). |  169     //   OwnPtr<ThreadableLoader>). | 
|  172     static PassRefPtr<ThreadableLoader> create(ExecutionContext&, ThreadableLoad
     erClient*, const ThreadableLoaderOptions&, const ResourceLoaderOptions&); |  170     static PassOwnPtr<ThreadableLoader> create(ExecutionContext&, ThreadableLoad
     erClient*, const ThreadableLoaderOptions&, const ResourceLoaderOptions&); | 
|  173  |  171  | 
|  174     // The methods on the ThreadableLoaderClient passed on create() call |  172     // The methods on the ThreadableLoaderClient passed on create() call | 
|  175     // may be called synchronous to start() call. |  173     // may be called synchronous to start() call. | 
|  176     virtual void start(const ResourceRequest&) = 0; |  174     virtual void start(const ResourceRequest&) = 0; | 
|  177  |  175  | 
|  178     // 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 | 
|  179     // 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 | 
|  180     // may override their timeout setting after sending). |  178     // may override their timeout setting after sending). | 
|  181     // |  179     // | 
|  182     // 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. | 
|  183     virtual void overrideTimeout(unsigned long timeoutMilliseconds) = 0; |  181     virtual void overrideTimeout(unsigned long timeoutMilliseconds) = 0; | 
|  184  |  182  | 
|  185     virtual void cancel() = 0; |  183     virtual void cancel() = 0; | 
|  186  |  184  | 
|  187     virtual ~ThreadableLoader() { } |  185     virtual ~ThreadableLoader() { } | 
|  188  |  186  | 
|  189 protected: |  187 protected: | 
|  190     ThreadableLoader() { } |  188     ThreadableLoader() { } | 
|  191 }; |  189 }; | 
|  192  |  190  | 
|  193 } // namespace blink |  191 } // namespace blink | 
|  194  |  192  | 
|  195 #endif // ThreadableLoader_h |  193 #endif // ThreadableLoader_h | 
| OLD | NEW |