| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009, 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2009, 2010 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 } | 102 } |
| 103 | 103 |
| 104 void WorkerThreadableLoader::cancel() | 104 void WorkerThreadableLoader::cancel() |
| 105 { | 105 { |
| 106 m_bridge.cancel(); | 106 m_bridge.cancel(); |
| 107 } | 107 } |
| 108 | 108 |
| 109 WorkerThreadableLoader::MainThreadBridge::MainThreadBridge( | 109 WorkerThreadableLoader::MainThreadBridge::MainThreadBridge( |
| 110 PassRefPtr<ThreadableLoaderClientWrapper> workerClientWrapper, | 110 PassRefPtr<ThreadableLoaderClientWrapper> workerClientWrapper, |
| 111 PassOwnPtr<ThreadableLoaderClient> clientBridge, | 111 PassOwnPtr<ThreadableLoaderClient> clientBridge, |
| 112 WorkerLoaderProxy& loaderProxy, | 112 PassRefPtr<WorkerLoaderProxy> loaderProxy, |
| 113 const ResourceRequest& request, | 113 const ResourceRequest& request, |
| 114 const ThreadableLoaderOptions& options, | 114 const ThreadableLoaderOptions& options, |
| 115 const ResourceLoaderOptions& resourceLoaderOptions, | 115 const ResourceLoaderOptions& resourceLoaderOptions, |
| 116 const String& outgoingReferrer) | 116 const String& outgoingReferrer) |
| 117 : m_clientBridge(clientBridge) | 117 : m_clientBridge(clientBridge) |
| 118 , m_workerClientWrapper(workerClientWrapper) | 118 , m_workerClientWrapper(workerClientWrapper) |
| 119 , m_loaderProxy(loaderProxy) | 119 , m_loaderProxy(loaderProxy) |
| 120 { | 120 { |
| 121 ASSERT(m_workerClientWrapper.get()); | 121 ASSERT(m_workerClientWrapper.get()); |
| 122 ASSERT(m_clientBridge.get()); | 122 ASSERT(m_clientBridge.get()); |
| 123 m_loaderProxy.postTaskToLoader( | 123 m_loaderProxy->postTaskToLoader( |
| 124 createCrossThreadTask(&MainThreadBridge::mainThreadCreateLoader, AllowCr
ossThreadAccess(this), request, options, resourceLoaderOptions, outgoingReferrer
)); | 124 createCrossThreadTask(&MainThreadBridge::mainThreadCreateLoader, AllowCr
ossThreadAccess(this), request, options, resourceLoaderOptions, outgoingReferrer
)); |
| 125 } | 125 } |
| 126 | 126 |
| 127 WorkerThreadableLoader::MainThreadBridge::~MainThreadBridge() | 127 WorkerThreadableLoader::MainThreadBridge::~MainThreadBridge() |
| 128 { | 128 { |
| 129 } | 129 } |
| 130 | 130 |
| 131 void WorkerThreadableLoader::MainThreadBridge::mainThreadCreateLoader(ExecutionC
ontext* context, MainThreadBridge* thisPtr, PassOwnPtr<CrossThreadResourceReques
tData> requestData, ThreadableLoaderOptions options, ResourceLoaderOptions resou
rceLoaderOptions, const String& outgoingReferrer) | 131 void WorkerThreadableLoader::MainThreadBridge::mainThreadCreateLoader(ExecutionC
ontext* context, MainThreadBridge* thisPtr, PassOwnPtr<CrossThreadResourceReques
tData> requestData, ThreadableLoaderOptions options, ResourceLoaderOptions resou
rceLoaderOptions, const String& outgoingReferrer) |
| 132 { | 132 { |
| 133 ASSERT(isMainThread()); | 133 ASSERT(isMainThread()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 149 ASSERT_UNUSED(context, context->isDocument()); | 149 ASSERT_UNUSED(context, context->isDocument()); |
| 150 delete thisPtr; | 150 delete thisPtr; |
| 151 } | 151 } |
| 152 | 152 |
| 153 void WorkerThreadableLoader::MainThreadBridge::destroy() | 153 void WorkerThreadableLoader::MainThreadBridge::destroy() |
| 154 { | 154 { |
| 155 // Ensure that no more client callbacks are done in the worker context's thr
ead. | 155 // Ensure that no more client callbacks are done in the worker context's thr
ead. |
| 156 clearClientWrapper(); | 156 clearClientWrapper(); |
| 157 | 157 |
| 158 // "delete this" and m_mainThreadLoader::deref() on the worker object's thre
ad. | 158 // "delete this" and m_mainThreadLoader::deref() on the worker object's thre
ad. |
| 159 m_loaderProxy.postTaskToLoader( | 159 m_loaderProxy->postTaskToLoader( |
| 160 createCrossThreadTask(&MainThreadBridge::mainThreadDestroy, AllowCrossTh
readAccess(this))); | 160 createCrossThreadTask(&MainThreadBridge::mainThreadDestroy, AllowCrossTh
readAccess(this))); |
| 161 } | 161 } |
| 162 | 162 |
| 163 void WorkerThreadableLoader::MainThreadBridge::mainThreadOverrideTimeout(Executi
onContext* context, MainThreadBridge* thisPtr, unsigned long timeoutMilliseconds
) | 163 void WorkerThreadableLoader::MainThreadBridge::mainThreadOverrideTimeout(Executi
onContext* context, MainThreadBridge* thisPtr, unsigned long timeoutMilliseconds
) |
| 164 { | 164 { |
| 165 ASSERT(isMainThread()); | 165 ASSERT(isMainThread()); |
| 166 ASSERT_UNUSED(context, context->isDocument()); | 166 ASSERT_UNUSED(context, context->isDocument()); |
| 167 | 167 |
| 168 if (!thisPtr->m_mainThreadLoader) | 168 if (!thisPtr->m_mainThreadLoader) |
| 169 return; | 169 return; |
| 170 thisPtr->m_mainThreadLoader->overrideTimeout(timeoutMilliseconds); | 170 thisPtr->m_mainThreadLoader->overrideTimeout(timeoutMilliseconds); |
| 171 } | 171 } |
| 172 | 172 |
| 173 void WorkerThreadableLoader::MainThreadBridge::overrideTimeout(unsigned long tim
eoutMilliseconds) | 173 void WorkerThreadableLoader::MainThreadBridge::overrideTimeout(unsigned long tim
eoutMilliseconds) |
| 174 { | 174 { |
| 175 m_loaderProxy.postTaskToLoader( | 175 m_loaderProxy->postTaskToLoader( |
| 176 createCrossThreadTask(&MainThreadBridge::mainThreadOverrideTimeout, Allo
wCrossThreadAccess(this), | 176 createCrossThreadTask(&MainThreadBridge::mainThreadOverrideTimeout, Allo
wCrossThreadAccess(this), |
| 177 timeoutMilliseconds)); | 177 timeoutMilliseconds)); |
| 178 } | 178 } |
| 179 | 179 |
| 180 void WorkerThreadableLoader::MainThreadBridge::mainThreadCancel(ExecutionContext
* context, MainThreadBridge* thisPtr) | 180 void WorkerThreadableLoader::MainThreadBridge::mainThreadCancel(ExecutionContext
* context, MainThreadBridge* thisPtr) |
| 181 { | 181 { |
| 182 ASSERT(isMainThread()); | 182 ASSERT(isMainThread()); |
| 183 ASSERT_UNUSED(context, context->isDocument()); | 183 ASSERT_UNUSED(context, context->isDocument()); |
| 184 | 184 |
| 185 if (!thisPtr->m_mainThreadLoader) | 185 if (!thisPtr->m_mainThreadLoader) |
| 186 return; | 186 return; |
| 187 thisPtr->m_mainThreadLoader->cancel(); | 187 thisPtr->m_mainThreadLoader->cancel(); |
| 188 thisPtr->m_mainThreadLoader = nullptr; | 188 thisPtr->m_mainThreadLoader = nullptr; |
| 189 } | 189 } |
| 190 | 190 |
| 191 void WorkerThreadableLoader::MainThreadBridge::cancel() | 191 void WorkerThreadableLoader::MainThreadBridge::cancel() |
| 192 { | 192 { |
| 193 m_loaderProxy.postTaskToLoader( | 193 m_loaderProxy->postTaskToLoader( |
| 194 createCrossThreadTask(&MainThreadBridge::mainThreadCancel, AllowCrossThr
eadAccess(this))); | 194 createCrossThreadTask(&MainThreadBridge::mainThreadCancel, AllowCrossThr
eadAccess(this))); |
| 195 ThreadableLoaderClientWrapper* clientWrapper = m_workerClientWrapper.get(); | 195 ThreadableLoaderClientWrapper* clientWrapper = m_workerClientWrapper.get(); |
| 196 if (!clientWrapper->done()) { | 196 if (!clientWrapper->done()) { |
| 197 // If the client hasn't reached a termination state, then transition it
by sending a cancellation error. | 197 // If the client hasn't reached a termination state, then transition it
by sending a cancellation error. |
| 198 // Note: no more client callbacks will be done after this method -- the
clearClientWrapper() call ensures that. | 198 // Note: no more client callbacks will be done after this method -- the
clearClientWrapper() call ensures that. |
| 199 ResourceError error(String(), 0, String(), String()); | 199 ResourceError error(String(), 0, String(), String()); |
| 200 error.setIsCancellation(true); | 200 error.setIsCancellation(true); |
| 201 clientWrapper->didFail(error); | 201 clientWrapper->didFail(error); |
| 202 } | 202 } |
| 203 clearClientWrapper(); | 203 clearClientWrapper(); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 { | 247 { |
| 248 m_clientBridge->didFailAccessControlCheck(error); | 248 m_clientBridge->didFailAccessControlCheck(error); |
| 249 } | 249 } |
| 250 | 250 |
| 251 void WorkerThreadableLoader::MainThreadBridge::didFailRedirectCheck() | 251 void WorkerThreadableLoader::MainThreadBridge::didFailRedirectCheck() |
| 252 { | 252 { |
| 253 m_clientBridge->didFailRedirectCheck(); | 253 m_clientBridge->didFailRedirectCheck(); |
| 254 } | 254 } |
| 255 | 255 |
| 256 } // namespace blink | 256 } // namespace blink |
| OLD | NEW |