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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 | 52 |
53 class WorkerThreadableLoader final : public ThreadableLoader, private Thread
ableLoaderClientWrapper::ResourceTimingClient { | 53 class WorkerThreadableLoader final : public ThreadableLoader, private Thread
ableLoaderClientWrapper::ResourceTimingClient { |
54 WTF_MAKE_FAST_ALLOCATED(WorkerThreadableLoader); | 54 WTF_MAKE_FAST_ALLOCATED(WorkerThreadableLoader); |
55 public: | 55 public: |
56 static void loadResourceSynchronously(WorkerGlobalScope&, const Resource
Request&, ThreadableLoaderClient&, const ThreadableLoaderOptions&, const Resourc
eLoaderOptions&); | 56 static void loadResourceSynchronously(WorkerGlobalScope&, const Resource
Request&, ThreadableLoaderClient&, const ThreadableLoaderOptions&, const Resourc
eLoaderOptions&); |
57 static PassRefPtr<WorkerThreadableLoader> create(WorkerGlobalScope& work
erGlobalScope, PassRefPtr<ThreadableLoaderClientWrapper> clientWrapper, PassOwnP
tr<ThreadableLoaderClient> clientBridge, const ResourceRequest& request, const T
hreadableLoaderOptions& options, const ResourceLoaderOptions& resourceLoaderOpti
ons) | 57 static PassRefPtr<WorkerThreadableLoader> create(WorkerGlobalScope& work
erGlobalScope, PassRefPtr<ThreadableLoaderClientWrapper> clientWrapper, PassOwnP
tr<ThreadableLoaderClient> clientBridge, const ResourceRequest& request, const T
hreadableLoaderOptions& options, const ResourceLoaderOptions& resourceLoaderOpti
ons) |
58 { | 58 { |
59 return adoptRef(new WorkerThreadableLoader(workerGlobalScope, client
Wrapper, clientBridge, request, options, resourceLoaderOptions)); | 59 return adoptRef(new WorkerThreadableLoader(workerGlobalScope, client
Wrapper, clientBridge, request, options, resourceLoaderOptions)); |
60 } | 60 } |
61 | 61 |
62 virtual ~WorkerThreadableLoader(); | 62 ~WorkerThreadableLoader() override; |
63 | 63 |
64 virtual void overrideTimeout(unsigned long timeout) override; | 64 void overrideTimeout(unsigned long timeout) override; |
65 | 65 |
66 virtual void cancel() override; | 66 void cancel() override; |
67 | 67 |
68 private: | 68 private: |
69 // Creates a loader on the main thread and bridges communication between | 69 // Creates a loader on the main thread and bridges communication between |
70 // the main thread and the worker context's thread where WorkerThreadabl
eLoader runs. | 70 // the main thread and the worker context's thread where WorkerThreadabl
eLoader runs. |
71 // | 71 // |
72 // Regarding the bridge and lifetimes of items used in callbacks, there
are a few cases: | 72 // Regarding the bridge and lifetimes of items used in callbacks, there
are a few cases: |
73 // | 73 // |
74 // all cases. All tasks posted from the worker context's thread are ok b
ecause | 74 // all cases. All tasks posted from the worker context's thread are ok b
ecause |
75 // the last task posted always is "mainThreadDestroy", so MainThreadB
ridge is | 75 // the last task posted always is "mainThreadDestroy", so MainThreadB
ridge is |
76 // around for all tasks that use it on the main thread. | 76 // around for all tasks that use it on the main thread. |
(...skipping 15 matching lines...) Expand all Loading... |
92 void overrideTimeout(unsigned long timeoutMilliseconds); | 92 void overrideTimeout(unsigned long timeoutMilliseconds); |
93 void cancel(); | 93 void cancel(); |
94 void destroy(); | 94 void destroy(); |
95 | 95 |
96 private: | 96 private: |
97 // Executed on the worker context's thread. | 97 // Executed on the worker context's thread. |
98 void clearClientWrapper(); | 98 void clearClientWrapper(); |
99 | 99 |
100 // All executed on the main thread. | 100 // All executed on the main thread. |
101 void mainThreadDestroy(ExecutionContext*); | 101 void mainThreadDestroy(ExecutionContext*); |
102 virtual ~MainThreadBridge(); | 102 ~MainThreadBridge() override; |
103 | 103 |
104 void mainThreadCreateLoader(PassOwnPtr<CrossThreadResourceRequestDat
a>, ThreadableLoaderOptions, ResourceLoaderOptions, const ReferrerPolicy, const
String& outgoingReferrer, ExecutionContext*); | 104 void mainThreadCreateLoader(PassOwnPtr<CrossThreadResourceRequestDat
a>, ThreadableLoaderOptions, ResourceLoaderOptions, const ReferrerPolicy, const
String& outgoingReferrer, ExecutionContext*); |
105 void mainThreadOverrideTimeout(unsigned long timeoutMilliseconds, Ex
ecutionContext*); | 105 void mainThreadOverrideTimeout(unsigned long timeoutMilliseconds, Ex
ecutionContext*); |
106 void mainThreadCancel(ExecutionContext*); | 106 void mainThreadCancel(ExecutionContext*); |
107 virtual void didSendData(unsigned long long bytesSent, unsigned long
long totalBytesToBeSent) override; | 107 void didSendData(unsigned long long bytesSent, unsigned long long to
talBytesToBeSent) override; |
108 virtual void didReceiveResponse(unsigned long identifier, const Reso
urceResponse&, PassOwnPtr<WebDataConsumerHandle>) override; | 108 void didReceiveResponse(unsigned long identifier, const ResourceResp
onse&, PassOwnPtr<WebDataConsumerHandle>) override; |
109 virtual void didReceiveData(const char*, unsigned dataLength) overri
de; | 109 void didReceiveData(const char*, unsigned dataLength) override; |
110 virtual void didDownloadData(int dataLength) override; | 110 void didDownloadData(int dataLength) override; |
111 virtual void didReceiveCachedMetadata(const char*, int dataLength) o
verride; | 111 void didReceiveCachedMetadata(const char*, int dataLength) override; |
112 virtual void didFinishLoading(unsigned long identifier, double finis
hTime) override; | 112 void didFinishLoading(unsigned long identifier, double finishTime) o
verride; |
113 virtual void didFail(const ResourceError&) override; | 113 void didFail(const ResourceError&) override; |
114 virtual void didFailAccessControlCheck(const ResourceError&) overrid
e; | 114 void didFailAccessControlCheck(const ResourceError&) override; |
115 virtual void didFailRedirectCheck() override; | 115 void didFailRedirectCheck() override; |
116 virtual void didReceiveResourceTiming(const ResourceTimingInfo&) ove
rride; | 116 void didReceiveResourceTiming(const ResourceTimingInfo&) override; |
117 | 117 |
118 // Only to be used on the main thread. | 118 // Only to be used on the main thread. |
119 RefPtr<ThreadableLoader> m_mainThreadLoader; | 119 RefPtr<ThreadableLoader> m_mainThreadLoader; |
120 OwnPtr<ThreadableLoaderClient> m_clientBridge; | 120 OwnPtr<ThreadableLoaderClient> m_clientBridge; |
121 | 121 |
122 // ThreadableLoaderClientWrapper is to be used on the worker context
thread. | 122 // ThreadableLoaderClientWrapper is to be used on the worker context
thread. |
123 // The ref counting is done on either thread. | 123 // The ref counting is done on either thread. |
124 RefPtr<ThreadableLoaderClientWrapper> m_workerClientWrapper; | 124 RefPtr<ThreadableLoaderClientWrapper> m_workerClientWrapper; |
125 | 125 |
126 // Used on the worker context thread. | 126 // Used on the worker context thread. |
127 RefPtr<WorkerLoaderProxy> m_loaderProxy; | 127 RefPtr<WorkerLoaderProxy> m_loaderProxy; |
128 }; | 128 }; |
129 | 129 |
130 WorkerThreadableLoader(WorkerGlobalScope&, PassRefPtr<ThreadableLoaderCl
ientWrapper>, PassOwnPtr<ThreadableLoaderClient>, const ResourceRequest&, const
ThreadableLoaderOptions&, const ResourceLoaderOptions&); | 130 WorkerThreadableLoader(WorkerGlobalScope&, PassRefPtr<ThreadableLoaderCl
ientWrapper>, PassOwnPtr<ThreadableLoaderClient>, const ResourceRequest&, const
ThreadableLoaderOptions&, const ResourceLoaderOptions&); |
131 | 131 |
132 void didReceiveResourceTiming(const ResourceTimingInfo&) override; | 132 void didReceiveResourceTiming(const ResourceTimingInfo&) override; |
133 | 133 |
134 RefPtrWillBePersistent<WorkerGlobalScope> m_workerGlobalScope; | 134 RefPtrWillBePersistent<WorkerGlobalScope> m_workerGlobalScope; |
135 RefPtr<ThreadableLoaderClientWrapper> m_workerClientWrapper; | 135 RefPtr<ThreadableLoaderClientWrapper> m_workerClientWrapper; |
136 MainThreadBridge& m_bridge; | 136 MainThreadBridge& m_bridge; |
137 }; | 137 }; |
138 | 138 |
139 } // namespace blink | 139 } // namespace blink |
140 | 140 |
141 #endif // WorkerThreadableLoader_h | 141 #endif // WorkerThreadableLoader_h |
OLD | NEW |