| 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 | 135 |
| 136 void WorkerThreadableLoader::MainThreadBridgeBase::mainThreadStart(PassOwnPtr<Cr
ossThreadResourceRequestData> requestData) | 136 void WorkerThreadableLoader::MainThreadBridgeBase::mainThreadStart(PassOwnPtr<Cr
ossThreadResourceRequestData> requestData) |
| 137 { | 137 { |
| 138 ASSERT(isMainThread()); | 138 ASSERT(isMainThread()); |
| 139 ASSERT(m_mainThreadLoader); | 139 ASSERT(m_mainThreadLoader); |
| 140 m_mainThreadLoader->start(ResourceRequest(requestData.get())); | 140 m_mainThreadLoader->start(ResourceRequest(requestData.get())); |
| 141 } | 141 } |
| 142 | 142 |
| 143 void WorkerThreadableLoader::MainThreadBridgeBase::createLoaderInMainThread(cons
t ThreadableLoaderOptions& options, const ResourceLoaderOptions& resourceLoaderO
ptions) | 143 void WorkerThreadableLoader::MainThreadBridgeBase::createLoaderInMainThread(cons
t ThreadableLoaderOptions& options, const ResourceLoaderOptions& resourceLoaderO
ptions) |
| 144 { | 144 { |
| 145 m_loaderProxy->postTaskToLoader(createCrossThreadTask(&MainThreadBridgeBase:
:mainThreadCreateLoader, this, options, resourceLoaderOptions)); | 145 m_loaderProxy->postTaskToLoader(createCrossThreadTask(&MainThreadBridgeBase:
:mainThreadCreateLoader, AllowCrossThreadAccess(this), options, resourceLoaderOp
tions)); |
| 146 } | 146 } |
| 147 | 147 |
| 148 void WorkerThreadableLoader::MainThreadBridgeBase::startInMainThread(const Resou
rceRequest& request, const WorkerGlobalScope& workerGlobalScope) | 148 void WorkerThreadableLoader::MainThreadBridgeBase::startInMainThread(const Resou
rceRequest& request, const WorkerGlobalScope& workerGlobalScope) |
| 149 { | 149 { |
| 150 loaderProxy()->postTaskToLoader(createCrossThreadTask(&MainThreadBridgeBase:
:mainThreadStart, this, request)); | 150 loaderProxy()->postTaskToLoader(createCrossThreadTask(&MainThreadBridgeBase:
:mainThreadStart, AllowCrossThreadAccess(this), request)); |
| 151 } | 151 } |
| 152 | 152 |
| 153 void WorkerThreadableLoader::MainThreadBridgeBase::mainThreadDestroy(ExecutionCo
ntext* context) | 153 void WorkerThreadableLoader::MainThreadBridgeBase::mainThreadDestroy(ExecutionCo
ntext* context) |
| 154 { | 154 { |
| 155 ASSERT(isMainThread()); | 155 ASSERT(isMainThread()); |
| 156 ASSERT_UNUSED(context, context->isDocument()); | 156 ASSERT_UNUSED(context, context->isDocument()); |
| 157 delete this; | 157 delete this; |
| 158 } | 158 } |
| 159 | 159 |
| 160 void WorkerThreadableLoader::MainThreadBridgeBase::destroy() | 160 void WorkerThreadableLoader::MainThreadBridgeBase::destroy() |
| 161 { | 161 { |
| 162 // Ensure that no more client callbacks are done in the worker context's thr
ead. | 162 // Ensure that no more client callbacks are done in the worker context's thr
ead. |
| 163 m_workerClientWrapper->clearClient(); | 163 m_workerClientWrapper->clearClient(); |
| 164 | 164 |
| 165 // "delete this" and m_mainThreadLoader::deref() on the worker object's thre
ad. | 165 // "delete this" and m_mainThreadLoader::deref() on the worker object's thre
ad. |
| 166 m_loaderProxy->postTaskToLoader(createCrossThreadTask(&MainThreadBridgeBase:
:mainThreadDestroy, this)); | 166 m_loaderProxy->postTaskToLoader(createCrossThreadTask(&MainThreadBridgeBase:
:mainThreadDestroy, AllowCrossThreadAccess(this))); |
| 167 } | 167 } |
| 168 | 168 |
| 169 void WorkerThreadableLoader::MainThreadBridgeBase::mainThreadOverrideTimeout(uns
igned long timeoutMilliseconds, ExecutionContext* context) | 169 void WorkerThreadableLoader::MainThreadBridgeBase::mainThreadOverrideTimeout(uns
igned long timeoutMilliseconds, ExecutionContext* context) |
| 170 { | 170 { |
| 171 ASSERT(isMainThread()); | 171 ASSERT(isMainThread()); |
| 172 ASSERT_UNUSED(context, context->isDocument()); | 172 ASSERT_UNUSED(context, context->isDocument()); |
| 173 | 173 |
| 174 if (!m_mainThreadLoader) | 174 if (!m_mainThreadLoader) |
| 175 return; | 175 return; |
| 176 m_mainThreadLoader->overrideTimeout(timeoutMilliseconds); | 176 m_mainThreadLoader->overrideTimeout(timeoutMilliseconds); |
| 177 } | 177 } |
| 178 | 178 |
| 179 void WorkerThreadableLoader::MainThreadBridgeBase::overrideTimeout(unsigned long
timeoutMilliseconds) | 179 void WorkerThreadableLoader::MainThreadBridgeBase::overrideTimeout(unsigned long
timeoutMilliseconds) |
| 180 { | 180 { |
| 181 m_loaderProxy->postTaskToLoader(createCrossThreadTask(&MainThreadBridgeBase:
:mainThreadOverrideTimeout, this, timeoutMilliseconds)); | 181 m_loaderProxy->postTaskToLoader(createCrossThreadTask(&MainThreadBridgeBase:
:mainThreadOverrideTimeout, AllowCrossThreadAccess(this), timeoutMilliseconds)); |
| 182 } | 182 } |
| 183 | 183 |
| 184 void WorkerThreadableLoader::MainThreadBridgeBase::mainThreadCancel(ExecutionCon
text* context) | 184 void WorkerThreadableLoader::MainThreadBridgeBase::mainThreadCancel(ExecutionCon
text* context) |
| 185 { | 185 { |
| 186 ASSERT(isMainThread()); | 186 ASSERT(isMainThread()); |
| 187 ASSERT_UNUSED(context, context->isDocument()); | 187 ASSERT_UNUSED(context, context->isDocument()); |
| 188 | 188 |
| 189 if (!m_mainThreadLoader) | 189 if (!m_mainThreadLoader) |
| 190 return; | 190 return; |
| 191 m_mainThreadLoader->cancel(); | 191 m_mainThreadLoader->cancel(); |
| 192 m_mainThreadLoader = nullptr; | 192 m_mainThreadLoader = nullptr; |
| 193 } | 193 } |
| 194 | 194 |
| 195 void WorkerThreadableLoader::MainThreadBridgeBase::cancel() | 195 void WorkerThreadableLoader::MainThreadBridgeBase::cancel() |
| 196 { | 196 { |
| 197 m_loaderProxy->postTaskToLoader(createCrossThreadTask(&MainThreadBridgeBase:
:mainThreadCancel, this)); | 197 m_loaderProxy->postTaskToLoader(createCrossThreadTask(&MainThreadBridgeBase:
:mainThreadCancel, AllowCrossThreadAccess(this))); |
| 198 RefPtr<ThreadableLoaderClientWrapper> clientWrapper = m_workerClientWrapper; | 198 RefPtr<ThreadableLoaderClientWrapper> clientWrapper = m_workerClientWrapper; |
| 199 if (!clientWrapper->done()) { | 199 if (!clientWrapper->done()) { |
| 200 // If the client hasn't reached a termination state, then transition it
by sending a cancellation error. | 200 // If the client hasn't reached a termination state, then transition it
by sending a cancellation error. |
| 201 // Note: no more client callbacks will be done after this method -- the
m_workerClientWrapper->clearClient() call ensures that. | 201 // Note: no more client callbacks will be done after this method -- the
m_workerClientWrapper->clearClient() call ensures that. |
| 202 ResourceError error(String(), 0, String(), String()); | 202 ResourceError error(String(), 0, String(), String()); |
| 203 error.setIsCancellation(true); | 203 error.setIsCancellation(true); |
| 204 clientWrapper->didFail(error); | 204 clientWrapper->didFail(error); |
| 205 } | 205 } |
| 206 // |this| might be already destructed here because didFail() might | 206 // |this| might be already destructed here because didFail() might |
| 207 // clear a reference to ThreadableLoader, which might destruct | 207 // clear a reference to ThreadableLoader, which might destruct |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 | 361 |
| 362 MutexLocker lock(m_lock); | 362 MutexLocker lock(m_lock); |
| 363 RELEASE_ASSERT(!m_done); | 363 RELEASE_ASSERT(!m_done); |
| 364 | 364 |
| 365 m_clientTasks.append(std::move(task)); | 365 m_clientTasks.append(std::move(task)); |
| 366 m_done = true; | 366 m_done = true; |
| 367 m_loaderDoneEvent->signal(); | 367 m_loaderDoneEvent->signal(); |
| 368 } | 368 } |
| 369 | 369 |
| 370 } // namespace blink | 370 } // namespace blink |
| OLD | NEW |