| 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 20 matching lines...) Expand all Loading... |
| 31 #include "core/loader/WorkerThreadableLoader.h" | 31 #include "core/loader/WorkerThreadableLoader.h" |
| 32 | 32 |
| 33 #include "core/dom/CrossThreadTask.h" | 33 #include "core/dom/CrossThreadTask.h" |
| 34 #include "core/dom/Document.h" | 34 #include "core/dom/Document.h" |
| 35 #include "core/loader/DocumentThreadableLoader.h" | 35 #include "core/loader/DocumentThreadableLoader.h" |
| 36 #include "core/timing/WorkerGlobalScopePerformance.h" | 36 #include "core/timing/WorkerGlobalScopePerformance.h" |
| 37 #include "core/workers/WorkerGlobalScope.h" | 37 #include "core/workers/WorkerGlobalScope.h" |
| 38 #include "core/workers/WorkerLoaderProxy.h" | 38 #include "core/workers/WorkerLoaderProxy.h" |
| 39 #include "core/workers/WorkerThread.h" | 39 #include "core/workers/WorkerThread.h" |
| 40 #include "platform/ThreadSafeFunctional.h" | 40 #include "platform/ThreadSafeFunctional.h" |
| 41 #include "platform/WaitableEvent.h" |
| 41 #include "platform/heap/SafePoint.h" | 42 #include "platform/heap/SafePoint.h" |
| 42 #include "platform/network/ResourceError.h" | 43 #include "platform/network/ResourceError.h" |
| 43 #include "platform/network/ResourceRequest.h" | 44 #include "platform/network/ResourceRequest.h" |
| 44 #include "platform/network/ResourceResponse.h" | 45 #include "platform/network/ResourceResponse.h" |
| 45 #include "platform/network/ResourceTimingInfo.h" | 46 #include "platform/network/ResourceTimingInfo.h" |
| 46 #include "platform/weborigin/SecurityPolicy.h" | 47 #include "platform/weborigin/SecurityPolicy.h" |
| 47 #include "public/platform/Platform.h" | 48 #include "public/platform/Platform.h" |
| 48 #include "public/platform/WebWaitableEvent.h" | |
| 49 #include "wtf/MainThread.h" | 49 #include "wtf/MainThread.h" |
| 50 #include "wtf/OwnPtr.h" | 50 #include "wtf/OwnPtr.h" |
| 51 #include "wtf/Vector.h" | 51 #include "wtf/Vector.h" |
| 52 | 52 |
| 53 namespace blink { | 53 namespace blink { |
| 54 | 54 |
| 55 static PassOwnPtr<Vector<char>> createVectorFromMemoryRegion(const char* data, u
nsigned dataLength) | 55 static PassOwnPtr<Vector<char>> createVectorFromMemoryRegion(const char* data, u
nsigned dataLength) |
| 56 { | 56 { |
| 57 OwnPtr<Vector<char>> buffer = adoptPtr(new Vector<char>(dataLength)); | 57 OwnPtr<Vector<char>> buffer = adoptPtr(new Vector<char>(dataLength)); |
| 58 memcpy(buffer->data(), data, dataLength); | 58 memcpy(buffer->data(), data, dataLength); |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 WorkerGlobalScope& workerGlobalScope, | 277 WorkerGlobalScope& workerGlobalScope, |
| 278 PassRefPtr<ThreadableLoaderClientWrapper> workerClientWrapper, | 278 PassRefPtr<ThreadableLoaderClientWrapper> workerClientWrapper, |
| 279 const ResourceRequest& request, | 279 const ResourceRequest& request, |
| 280 const ThreadableLoaderOptions& options, | 280 const ThreadableLoaderOptions& options, |
| 281 const ResourceLoaderOptions& resourceLoaderOptions, | 281 const ResourceLoaderOptions& resourceLoaderOptions, |
| 282 const ReferrerPolicy referrerPolicy, | 282 const ReferrerPolicy referrerPolicy, |
| 283 const String& outgoingReferrer) | 283 const String& outgoingReferrer) |
| 284 : MainThreadBridgeBase(workerClientWrapper, workerGlobalScope.thread()->work
erLoaderProxy()) | 284 : MainThreadBridgeBase(workerClientWrapper, workerGlobalScope.thread()->work
erLoaderProxy()) |
| 285 , m_done(false) | 285 , m_done(false) |
| 286 { | 286 { |
| 287 WebWaitableEvent* shutdownEvent = workerGlobalScope.thread()->shutdownEvent(
); | 287 WaitableEvent* shutdownEvent = workerGlobalScope.thread()->shutdownEvent(); |
| 288 m_loaderDoneEvent = adoptPtr(Platform::current()->createWaitableEvent()); | 288 m_loaderDoneEvent = adoptPtr(new WaitableEvent()); |
| 289 | 289 |
| 290 createLoader(request, options, resourceLoaderOptions, referrerPolicy, outgoi
ngReferrer); | 290 createLoader(request, options, resourceLoaderOptions, referrerPolicy, outgoi
ngReferrer); |
| 291 | 291 |
| 292 WebWaitableEvent* signalled; | 292 size_t signaledIndex; |
| 293 { | 293 { |
| 294 Vector<WebWaitableEvent*> events; | 294 Vector<WaitableEvent*> events; |
| 295 // Order is important; indicies are used later. |
| 295 events.append(shutdownEvent); | 296 events.append(shutdownEvent); |
| 296 events.append(m_loaderDoneEvent.get()); | 297 events.append(m_loaderDoneEvent.get()); |
| 297 | 298 |
| 298 SafePointScope scope(BlinkGC::HeapPointersOnStack); | 299 SafePointScope scope(BlinkGC::HeapPointersOnStack); |
| 299 signalled = Platform::current()->waitMultipleEvents(events); | 300 signaledIndex = WaitableEvent::waitMultiple(events); |
| 300 } | 301 } |
| 301 if (signalled == shutdownEvent) { | 302 // |signaledIndex| is 0; which is shutdownEvent. |
| 303 if (signaledIndex == 0) { |
| 302 cancel(); | 304 cancel(); |
| 303 return; | 305 return; |
| 304 } | 306 } |
| 305 | 307 |
| 306 // The following code must be run only after |m_loaderDoneEvent| is | 308 // The following code must be run only after |m_loaderDoneEvent| is |
| 307 // signalled. | 309 // signalled. |
| 308 | 310 |
| 309 Vector<OwnPtr<ExecutionContextTask>> tasks; | 311 Vector<OwnPtr<ExecutionContextTask>> tasks; |
| 310 { | 312 { |
| 311 MutexLocker lock(m_lock); | 313 MutexLocker lock(m_lock); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 340 | 342 |
| 341 MutexLocker lock(m_lock); | 343 MutexLocker lock(m_lock); |
| 342 RELEASE_ASSERT(!m_done); | 344 RELEASE_ASSERT(!m_done); |
| 343 | 345 |
| 344 m_clientTasks.append(task); | 346 m_clientTasks.append(task); |
| 345 m_done = true; | 347 m_done = true; |
| 346 m_loaderDoneEvent->signal(); | 348 m_loaderDoneEvent->signal(); |
| 347 } | 349 } |
| 348 | 350 |
| 349 } // namespace blink | 351 } // namespace blink |
| OLD | NEW |