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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 #include "platform/network/ResourceResponse.h" | 44 #include "platform/network/ResourceResponse.h" |
45 #include "platform/weborigin/Referrer.h" | 45 #include "platform/weborigin/Referrer.h" |
46 #include "public/platform/Platform.h" | 46 #include "public/platform/Platform.h" |
47 #include "public/platform/WebWaitableEvent.h" | 47 #include "public/platform/WebWaitableEvent.h" |
48 #include "wtf/MainThread.h" | 48 #include "wtf/MainThread.h" |
49 #include "wtf/OwnPtr.h" | 49 #include "wtf/OwnPtr.h" |
50 #include "wtf/Vector.h" | 50 #include "wtf/Vector.h" |
51 | 51 |
52 namespace WebCore { | 52 namespace WebCore { |
53 | 53 |
54 WorkerThreadableLoader::WorkerThreadableLoader(WorkerGlobalScope* workerGlobalSc
ope, PassRefPtr<ThreadableLoaderClientWrapper> clientWrapper, PassOwnPtr<Threada
bleLoaderClient> clientBridge, const ResourceRequest& request, const ThreadableL
oaderOptions& options) | 54 WorkerThreadableLoader::WorkerThreadableLoader(WorkerGlobalScope& workerGlobalSc
ope, PassRefPtr<ThreadableLoaderClientWrapper> clientWrapper, PassOwnPtr<Threada
bleLoaderClient> clientBridge, const ResourceRequest& request, const ThreadableL
oaderOptions& options) |
55 : m_workerGlobalScope(workerGlobalScope) | 55 : m_workerGlobalScope(&workerGlobalScope) |
56 , m_workerClientWrapper(clientWrapper) | 56 , m_workerClientWrapper(clientWrapper) |
57 , m_bridge(*(new MainThreadBridge(m_workerClientWrapper, clientBridge, m_wor
kerGlobalScope->thread()->workerLoaderProxy(), request, options, workerGlobalSco
pe->url().strippedForUseAsReferrer()))) | 57 , m_bridge(*(new MainThreadBridge(m_workerClientWrapper, clientBridge, worke
rGlobalScope.thread()->workerLoaderProxy(), request, options, workerGlobalScope.
url().strippedForUseAsReferrer()))) |
58 { | 58 { |
59 } | 59 } |
60 | 60 |
61 WorkerThreadableLoader::~WorkerThreadableLoader() | 61 WorkerThreadableLoader::~WorkerThreadableLoader() |
62 { | 62 { |
63 m_bridge.destroy(); | 63 m_bridge.destroy(); |
64 } | 64 } |
65 | 65 |
66 void WorkerThreadableLoader::loadResourceSynchronously(WorkerGlobalScope* worker
GlobalScope, const ResourceRequest& request, ThreadableLoaderClient& client, con
st ThreadableLoaderOptions& options) | 66 void WorkerThreadableLoader::loadResourceSynchronously(WorkerGlobalScope& worker
GlobalScope, const ResourceRequest& request, ThreadableLoaderClient& client, con
st ThreadableLoaderOptions& options) |
67 { | 67 { |
68 blink::WebWaitableEvent* shutdownEvent = | 68 blink::WebWaitableEvent* shutdownEvent = |
69 workerGlobalScope->thread()->shutdownEvent(); | 69 workerGlobalScope.thread()->shutdownEvent(); |
70 OwnPtr<blink::WebWaitableEvent> loaderDone = | 70 OwnPtr<blink::WebWaitableEvent> loaderDone = |
71 adoptPtr(blink::Platform::current()->createWaitableEvent()); | 71 adoptPtr(blink::Platform::current()->createWaitableEvent()); |
72 | 72 |
73 Vector<blink::WebWaitableEvent*> events; | 73 Vector<blink::WebWaitableEvent*> events; |
74 events.append(shutdownEvent); | 74 events.append(shutdownEvent); |
75 events.append(loaderDone.get()); | 75 events.append(loaderDone.get()); |
76 | 76 |
77 RefPtr<ThreadableLoaderClientWrapper> clientWrapper(ThreadableLoaderClientWr
apper::create(&client)); | 77 RefPtr<ThreadableLoaderClientWrapper> clientWrapper(ThreadableLoaderClientWr
apper::create(&client)); |
78 OwnPtr<WorkerLoaderClientBridgeSyncHelper> clientBridge(WorkerLoaderClientBr
idgeSyncHelper::create(client, loaderDone.release())); | 78 OwnPtr<WorkerLoaderClientBridgeSyncHelper> clientBridge(WorkerLoaderClientBr
idgeSyncHelper::create(client, loaderDone.release())); |
79 | 79 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 } | 120 } |
121 | 121 |
122 void WorkerThreadableLoader::MainThreadBridge::mainThreadCreateLoader(ExecutionC
ontext* context, MainThreadBridge* thisPtr, PassOwnPtr<CrossThreadResourceReques
tData> requestData, ThreadableLoaderOptions options, const String& outgoingRefer
rer) | 122 void WorkerThreadableLoader::MainThreadBridge::mainThreadCreateLoader(ExecutionC
ontext* context, MainThreadBridge* thisPtr, PassOwnPtr<CrossThreadResourceReques
tData> requestData, ThreadableLoaderOptions options, const String& outgoingRefer
rer) |
123 { | 123 { |
124 ASSERT(isMainThread()); | 124 ASSERT(isMainThread()); |
125 Document* document = toDocument(context); | 125 Document* document = toDocument(context); |
126 | 126 |
127 OwnPtr<ResourceRequest> request(ResourceRequest::adopt(requestData)); | 127 OwnPtr<ResourceRequest> request(ResourceRequest::adopt(requestData)); |
128 request->setHTTPReferrer(Referrer(outgoingReferrer, ReferrerPolicyDefault)); | 128 request->setHTTPReferrer(Referrer(outgoingReferrer, ReferrerPolicyDefault)); |
129 options.requestInitiatorContext = WorkerContext; | 129 options.requestInitiatorContext = WorkerContext; |
130 thisPtr->m_mainThreadLoader = DocumentThreadableLoader::create(document, thi
sPtr, *request, options); | 130 thisPtr->m_mainThreadLoader = DocumentThreadableLoader::create(*document, th
isPtr, *request, options); |
131 if (!thisPtr->m_mainThreadLoader) { | 131 if (!thisPtr->m_mainThreadLoader) { |
132 // DocumentThreadableLoader::create may return 0 when the document loade
r has been already changed. | 132 // DocumentThreadableLoader::create may return 0 when the document loade
r has been already changed. |
133 thisPtr->didFail(ResourceError(errorDomainBlinkInternal, 0, request->url
().string(), "Can't create DocumentThreadableLoader")); | 133 thisPtr->didFail(ResourceError(errorDomainBlinkInternal, 0, request->url
().string(), "Can't create DocumentThreadableLoader")); |
134 } | 134 } |
135 } | 135 } |
136 | 136 |
137 void WorkerThreadableLoader::MainThreadBridge::mainThreadDestroy(ExecutionContex
t* context, MainThreadBridge* thisPtr) | 137 void WorkerThreadableLoader::MainThreadBridge::mainThreadDestroy(ExecutionContex
t* context, MainThreadBridge* thisPtr) |
138 { | 138 { |
139 ASSERT(isMainThread()); | 139 ASSERT(isMainThread()); |
140 ASSERT_UNUSED(context, context->isDocument()); | 140 ASSERT_UNUSED(context, context->isDocument()); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 { | 221 { |
222 m_clientBridge->didFailAccessControlCheck(error); | 222 m_clientBridge->didFailAccessControlCheck(error); |
223 } | 223 } |
224 | 224 |
225 void WorkerThreadableLoader::MainThreadBridge::didFailRedirectCheck() | 225 void WorkerThreadableLoader::MainThreadBridge::didFailRedirectCheck() |
226 { | 226 { |
227 m_clientBridge->didFailRedirectCheck(); | 227 m_clientBridge->didFailRedirectCheck(); |
228 } | 228 } |
229 | 229 |
230 } // namespace WebCore | 230 } // namespace WebCore |
OLD | NEW |