| 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 17 matching lines...) Expand all Loading... |
| 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 WorkerThreadableLoader_h | 31 #ifndef WorkerThreadableLoader_h |
| 32 #define WorkerThreadableLoader_h | 32 #define WorkerThreadableLoader_h |
| 33 | 33 |
| 34 #include "core/loader/ThreadableLoader.h" | 34 #include "core/loader/ThreadableLoader.h" |
| 35 #include "core/loader/ThreadableLoaderClient.h" | 35 #include "core/loader/ThreadableLoaderClient.h" |
| 36 #include "core/loader/ThreadableLoaderClientWrapper.h" | 36 #include "core/loader/ThreadableLoaderClientWrapper.h" |
| 37 #include "platform/heap/Handle.h" | 37 #include "platform/heap/Handle.h" |
| 38 #include "platform/weborigin/Referrer.h" |
| 38 #include "wtf/PassOwnPtr.h" | 39 #include "wtf/PassOwnPtr.h" |
| 39 #include "wtf/PassRefPtr.h" | 40 #include "wtf/PassRefPtr.h" |
| 40 #include "wtf/RefPtr.h" | 41 #include "wtf/RefPtr.h" |
| 41 #include "wtf/Threading.h" | 42 #include "wtf/Threading.h" |
| 42 #include "wtf/text/WTFString.h" | 43 #include "wtf/text/WTFString.h" |
| 43 | 44 |
| 44 namespace blink { | 45 namespace blink { |
| 45 | 46 |
| 46 class ResourceError; | 47 class ResourceError; |
| 47 class ResourceRequest; | 48 class ResourceRequest; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 // | 81 // |
| 81 // case 2. xhr gets aborted and the worker context continues running. | 82 // case 2. xhr gets aborted and the worker context continues running. |
| 82 // The ThreadableLoaderClientWrapper has the underlying client cleare
d, so no more calls | 83 // The ThreadableLoaderClientWrapper has the underlying client cleare
d, so no more calls |
| 83 // go through it. All tasks posted from the worker object's thread t
o the worker context's | 84 // go through it. All tasks posted from the worker object's thread t
o the worker context's |
| 84 // thread do "ThreadableLoaderClientWrapper::ref" (automatically insi
de of the cross thread copy | 85 // thread do "ThreadableLoaderClientWrapper::ref" (automatically insi
de of the cross thread copy |
| 85 // done in createCrossThreadTask), so the ThreadableLoaderClientWrapp
er instance is there until all | 86 // done in createCrossThreadTask), so the ThreadableLoaderClientWrapp
er instance is there until all |
| 86 // tasks are executed. | 87 // tasks are executed. |
| 87 class MainThreadBridge final : public ThreadableLoaderClient { | 88 class MainThreadBridge final : public ThreadableLoaderClient { |
| 88 public: | 89 public: |
| 89 // All executed on the worker context's thread. | 90 // All executed on the worker context's thread. |
| 90 MainThreadBridge(PassRefPtr<ThreadableLoaderClientWrapper>, PassOwnP
tr<ThreadableLoaderClient>, PassRefPtr<WorkerLoaderProxy>, const ResourceRequest
&, const ThreadableLoaderOptions&, const ResourceLoaderOptions&, const String& o
utgoingReferrer); | 91 MainThreadBridge(PassRefPtr<ThreadableLoaderClientWrapper>, PassOwnP
tr<ThreadableLoaderClient>, PassRefPtr<WorkerLoaderProxy>, const ResourceRequest
&, const ThreadableLoaderOptions&, const ResourceLoaderOptions&, const ReferrerP
olicy, const String& outgoingReferrer); |
| 91 void overrideTimeout(unsigned long timeoutMilliseconds); | 92 void overrideTimeout(unsigned long timeoutMilliseconds); |
| 92 void cancel(); | 93 void cancel(); |
| 93 void destroy(); | 94 void destroy(); |
| 94 | 95 |
| 95 private: | 96 private: |
| 96 // Executed on the worker context's thread. | 97 // Executed on the worker context's thread. |
| 97 void clearClientWrapper(); | 98 void clearClientWrapper(); |
| 98 | 99 |
| 99 // All executed on the main thread. | 100 // All executed on the main thread. |
| 100 void mainThreadDestroy(ExecutionContext*); | 101 void mainThreadDestroy(ExecutionContext*); |
| 101 virtual ~MainThreadBridge(); | 102 virtual ~MainThreadBridge(); |
| 102 | 103 |
| 103 void mainThreadCreateLoader(PassOwnPtr<CrossThreadResourceRequestDat
a>, ThreadableLoaderOptions, ResourceLoaderOptions, const String& outgoingReferr
er, ExecutionContext*); | 104 void mainThreadCreateLoader(PassOwnPtr<CrossThreadResourceRequestDat
a>, ThreadableLoaderOptions, ResourceLoaderOptions, const ReferrerPolicy, const
String& outgoingReferrer, ExecutionContext*); |
| 104 void mainThreadOverrideTimeout(unsigned long timeoutMilliseconds, Ex
ecutionContext*); | 105 void mainThreadOverrideTimeout(unsigned long timeoutMilliseconds, Ex
ecutionContext*); |
| 105 void mainThreadCancel(ExecutionContext*); | 106 void mainThreadCancel(ExecutionContext*); |
| 106 virtual void didSendData(unsigned long long bytesSent, unsigned long
long totalBytesToBeSent) override; | 107 virtual void didSendData(unsigned long long bytesSent, unsigned long
long totalBytesToBeSent) override; |
| 107 virtual void didReceiveResponse(unsigned long identifier, const Reso
urceResponse&, PassOwnPtr<WebDataConsumerHandle>) override; | 108 virtual void didReceiveResponse(unsigned long identifier, const Reso
urceResponse&, PassOwnPtr<WebDataConsumerHandle>) override; |
| 108 virtual void didReceiveData(const char*, unsigned dataLength) overri
de; | 109 virtual void didReceiveData(const char*, unsigned dataLength) overri
de; |
| 109 virtual void didDownloadData(int dataLength) override; | 110 virtual void didDownloadData(int dataLength) override; |
| 110 virtual void didReceiveCachedMetadata(const char*, int dataLength) o
verride; | 111 virtual void didReceiveCachedMetadata(const char*, int dataLength) o
verride; |
| 111 virtual void didFinishLoading(unsigned long identifier, double finis
hTime) override; | 112 virtual void didFinishLoading(unsigned long identifier, double finis
hTime) override; |
| 112 virtual void didFail(const ResourceError&) override; | 113 virtual void didFail(const ResourceError&) override; |
| 113 virtual void didFailAccessControlCheck(const ResourceError&) overrid
e; | 114 virtual void didFailAccessControlCheck(const ResourceError&) overrid
e; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 128 WorkerThreadableLoader(WorkerGlobalScope&, PassRefPtr<ThreadableLoaderCl
ientWrapper>, PassOwnPtr<ThreadableLoaderClient>, const ResourceRequest&, const
ThreadableLoaderOptions&, const ResourceLoaderOptions&); | 129 WorkerThreadableLoader(WorkerGlobalScope&, PassRefPtr<ThreadableLoaderCl
ientWrapper>, PassOwnPtr<ThreadableLoaderClient>, const ResourceRequest&, const
ThreadableLoaderOptions&, const ResourceLoaderOptions&); |
| 129 | 130 |
| 130 RefPtrWillBePersistent<WorkerGlobalScope> m_workerGlobalScope; | 131 RefPtrWillBePersistent<WorkerGlobalScope> m_workerGlobalScope; |
| 131 RefPtr<ThreadableLoaderClientWrapper> m_workerClientWrapper; | 132 RefPtr<ThreadableLoaderClientWrapper> m_workerClientWrapper; |
| 132 MainThreadBridge& m_bridge; | 133 MainThreadBridge& m_bridge; |
| 133 }; | 134 }; |
| 134 | 135 |
| 135 } // namespace blink | 136 } // namespace blink |
| 136 | 137 |
| 137 #endif // WorkerThreadableLoader_h | 138 #endif // WorkerThreadableLoader_h |
| OLD | NEW |