| 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 18 matching lines...) Expand all Loading... |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 | 32 |
| 33 #include "core/loader/WorkerThreadableLoader.h" | 33 #include "core/loader/WorkerThreadableLoader.h" |
| 34 | 34 |
| 35 #include "core/dom/CrossThreadTask.h" | 35 #include "core/dom/CrossThreadTask.h" |
| 36 #include "core/dom/Document.h" | 36 #include "core/dom/Document.h" |
| 37 #include "core/loader/DocumentThreadableLoader.h" | 37 #include "core/loader/DocumentThreadableLoader.h" |
| 38 #include "core/loader/WorkerLoaderClientBridgeSyncHelper.h" | 38 #include "core/loader/WorkerLoaderClientBridgeSyncHelper.h" |
| 39 #include "core/timing/WorkerGlobalScopePerformance.h" |
| 39 #include "core/workers/WorkerGlobalScope.h" | 40 #include "core/workers/WorkerGlobalScope.h" |
| 40 #include "core/workers/WorkerLoaderProxy.h" | 41 #include "core/workers/WorkerLoaderProxy.h" |
| 41 #include "core/workers/WorkerThread.h" | 42 #include "core/workers/WorkerThread.h" |
| 42 #include "platform/heap/SafePoint.h" | 43 #include "platform/heap/SafePoint.h" |
| 43 #include "platform/network/ResourceError.h" | 44 #include "platform/network/ResourceError.h" |
| 44 #include "platform/network/ResourceRequest.h" | 45 #include "platform/network/ResourceRequest.h" |
| 45 #include "platform/network/ResourceResponse.h" | 46 #include "platform/network/ResourceResponse.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 "public/platform/WebWaitableEvent.h" |
| 49 #include "wtf/MainThread.h" | 50 #include "wtf/MainThread.h" |
| 50 #include "wtf/OwnPtr.h" | 51 #include "wtf/OwnPtr.h" |
| 51 #include "wtf/Vector.h" | 52 #include "wtf/Vector.h" |
| 52 | 53 |
| 53 namespace blink { | 54 namespace blink { |
| 54 | 55 |
| 55 WorkerThreadableLoader::WorkerThreadableLoader(WorkerGlobalScope& workerGlobalSc
ope, PassRefPtr<ThreadableLoaderClientWrapper> clientWrapper, PassOwnPtr<Threada
bleLoaderClient> clientBridge, const ResourceRequest& request, const ThreadableL
oaderOptions& options, const ResourceLoaderOptions& resourceLoaderOptions) | 56 WorkerThreadableLoader::WorkerThreadableLoader(WorkerGlobalScope& workerGlobalSc
ope, PassRefPtr<ThreadableLoaderClientWrapper> clientWrapper, PassOwnPtr<Threada
bleLoaderClient> clientBridge, const ResourceRequest& request, const ThreadableL
oaderOptions& options, const ResourceLoaderOptions& resourceLoaderOptions) |
| 56 : m_workerGlobalScope(&workerGlobalScope) | 57 : m_workerGlobalScope(&workerGlobalScope) |
| 57 , m_workerClientWrapper(clientWrapper) | 58 , m_workerClientWrapper(clientWrapper) |
| 58 , m_bridge(*(new MainThreadBridge(m_workerClientWrapper, clientBridge, worke
rGlobalScope.thread()->workerLoaderProxy(), request, options, resourceLoaderOpti
ons, workerGlobalScope.referrerPolicy(), workerGlobalScope.url().strippedForUseA
sReferrer()))) | 59 , m_bridge(*(new MainThreadBridge(m_workerClientWrapper, clientBridge, worke
rGlobalScope.thread()->workerLoaderProxy(), request, options, resourceLoaderOpti
ons, workerGlobalScope.referrerPolicy(), workerGlobalScope.url().strippedForUseA
sReferrer()))) |
| 59 { | 60 { |
| 61 m_workerClientWrapper->setResourceTimingClient(this); |
| 60 } | 62 } |
| 61 | 63 |
| 62 WorkerThreadableLoader::~WorkerThreadableLoader() | 64 WorkerThreadableLoader::~WorkerThreadableLoader() |
| 63 { | 65 { |
| 66 m_workerClientWrapper->clearResourceTimingClient(); |
| 64 m_bridge.destroy(); | 67 m_bridge.destroy(); |
| 65 } | 68 } |
| 66 | 69 |
| 67 void WorkerThreadableLoader::loadResourceSynchronously(WorkerGlobalScope& worker
GlobalScope, const ResourceRequest& request, ThreadableLoaderClient& client, con
st ThreadableLoaderOptions& options, const ResourceLoaderOptions& resourceLoader
Options) | 70 void WorkerThreadableLoader::loadResourceSynchronously(WorkerGlobalScope& worker
GlobalScope, const ResourceRequest& request, ThreadableLoaderClient& client, con
st ThreadableLoaderOptions& options, const ResourceLoaderOptions& resourceLoader
Options) |
| 68 { | 71 { |
| 69 WebWaitableEvent* shutdownEvent = | 72 WebWaitableEvent* shutdownEvent = |
| 70 workerGlobalScope.thread()->shutdownEvent(); | 73 workerGlobalScope.thread()->shutdownEvent(); |
| 71 OwnPtr<WebWaitableEvent> loaderDone = | 74 OwnPtr<WebWaitableEvent> loaderDone = |
| 72 adoptPtr(Platform::current()->createWaitableEvent()); | 75 adoptPtr(Platform::current()->createWaitableEvent()); |
| 73 | 76 |
| 74 Vector<WebWaitableEvent*> events; | 77 Vector<WebWaitableEvent*> events; |
| 75 events.append(shutdownEvent); | 78 events.append(shutdownEvent); |
| 76 events.append(loaderDone.get()); | 79 events.append(loaderDone.get()); |
| 77 | 80 |
| 78 RefPtr<ThreadableLoaderClientWrapper> clientWrapper(ThreadableLoaderClientWr
apper::create(&client)); | 81 RefPtr<ThreadableLoaderClientWrapper> clientWrapper(ThreadableLoaderClientWr
apper::create(&client)); |
| 79 OwnPtr<WorkerLoaderClientBridgeSyncHelper> clientBridge(WorkerLoaderClientBr
idgeSyncHelper::create(client, loaderDone.release())); | 82 OwnPtr<WorkerLoaderClientBridgeSyncHelper> clientBridge(WorkerLoaderClientBr
idgeSyncHelper::create(clientWrapper.get(), loaderDone.release())); |
| 80 | 83 |
| 81 // This must be valid while loader is around. | 84 // This must be valid while loader is around. |
| 82 WorkerLoaderClientBridgeSyncHelper* clientBridgePtr = clientBridge.get(); | 85 WorkerLoaderClientBridgeSyncHelper* clientBridgePtr = clientBridge.get(); |
| 83 | 86 |
| 84 RefPtr<WorkerThreadableLoader> loader = WorkerThreadableLoader::create(worke
rGlobalScope, clientWrapper, clientBridge.release(), request, options, resourceL
oaderOptions); | 87 RefPtr<WorkerThreadableLoader> loader = WorkerThreadableLoader::create(worke
rGlobalScope, clientWrapper, clientBridge.release(), request, options, resourceL
oaderOptions); |
| 85 | 88 |
| 86 WebWaitableEvent* signalled; | 89 WebWaitableEvent* signalled; |
| 87 { | 90 { |
| 88 SafePointScope scope(ThreadState::HeapPointersOnStack); | 91 SafePointScope scope(ThreadState::HeapPointersOnStack); |
| 89 signalled = Platform::current()->waitMultipleEvents(events); | 92 signalled = Platform::current()->waitMultipleEvents(events); |
| 90 } | 93 } |
| 91 if (signalled == shutdownEvent) { | 94 if (signalled == shutdownEvent) { |
| 92 loader->cancel(); | 95 loader->cancel(); |
| 93 return; | 96 return; |
| 94 } | 97 } |
| 95 | 98 |
| 96 clientBridgePtr->run(); | 99 clientBridgePtr->run(); |
| 97 } | 100 } |
| 98 | 101 |
| 99 void WorkerThreadableLoader::overrideTimeout(unsigned long timeoutMilliseconds) | 102 void WorkerThreadableLoader::overrideTimeout(unsigned long timeoutMilliseconds) |
| 100 { | 103 { |
| 101 m_bridge.overrideTimeout(timeoutMilliseconds); | 104 m_bridge.overrideTimeout(timeoutMilliseconds); |
| 102 } | 105 } |
| 103 | 106 |
| 104 void WorkerThreadableLoader::cancel() | 107 void WorkerThreadableLoader::cancel() |
| 105 { | 108 { |
| 106 m_bridge.cancel(); | 109 m_bridge.cancel(); |
| 107 } | 110 } |
| 108 | 111 |
| 112 void WorkerThreadableLoader::didReceiveResourceTiming(const ResourceTimingInfo&
info) |
| 113 { |
| 114 WorkerGlobalScopePerformance::performance(*m_workerGlobalScope)->addResource
Timing(info); |
| 115 } |
| 116 |
| 109 WorkerThreadableLoader::MainThreadBridge::MainThreadBridge( | 117 WorkerThreadableLoader::MainThreadBridge::MainThreadBridge( |
| 110 PassRefPtr<ThreadableLoaderClientWrapper> workerClientWrapper, | 118 PassRefPtr<ThreadableLoaderClientWrapper> workerClientWrapper, |
| 111 PassOwnPtr<ThreadableLoaderClient> clientBridge, | 119 PassOwnPtr<ThreadableLoaderClient> clientBridge, |
| 112 PassRefPtr<WorkerLoaderProxy> loaderProxy, | 120 PassRefPtr<WorkerLoaderProxy> loaderProxy, |
| 113 const ResourceRequest& request, | 121 const ResourceRequest& request, |
| 114 const ThreadableLoaderOptions& options, | 122 const ThreadableLoaderOptions& options, |
| 115 const ResourceLoaderOptions& resourceLoaderOptions, | 123 const ResourceLoaderOptions& resourceLoaderOptions, |
| 116 const ReferrerPolicy referrerPolicy, | 124 const ReferrerPolicy referrerPolicy, |
| 117 const String& outgoingReferrer) | 125 const String& outgoingReferrer) |
| 118 : m_clientBridge(clientBridge) | 126 : m_clientBridge(clientBridge) |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 void WorkerThreadableLoader::MainThreadBridge::didFailAccessControlCheck(const R
esourceError& error) | 255 void WorkerThreadableLoader::MainThreadBridge::didFailAccessControlCheck(const R
esourceError& error) |
| 248 { | 256 { |
| 249 m_clientBridge->didFailAccessControlCheck(error); | 257 m_clientBridge->didFailAccessControlCheck(error); |
| 250 } | 258 } |
| 251 | 259 |
| 252 void WorkerThreadableLoader::MainThreadBridge::didFailRedirectCheck() | 260 void WorkerThreadableLoader::MainThreadBridge::didFailRedirectCheck() |
| 253 { | 261 { |
| 254 m_clientBridge->didFailRedirectCheck(); | 262 m_clientBridge->didFailRedirectCheck(); |
| 255 } | 263 } |
| 256 | 264 |
| 265 void WorkerThreadableLoader::MainThreadBridge::didReceiveResourceTiming(const Re
sourceTimingInfo& info) |
| 266 { |
| 267 m_clientBridge->didReceiveResourceTiming(info); |
| 268 } |
| 269 |
| 257 } // namespace blink | 270 } // namespace blink |
| OLD | NEW |