Chromium Code Reviews| 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, m_wor kerGlobalScope.thread()->workerLoaderProxy(), request, options, workerGlobalScop e.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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 112 AllowCrossThreadAccess(this), request, options, outgo ingReferrer)); | 112 AllowCrossThreadAccess(this), request, options, outgo ingReferrer)); |
| 113 } | 113 } |
| 114 | 114 |
| 115 WorkerThreadableLoader::MainThreadBridge::~MainThreadBridge() | 115 WorkerThreadableLoader::MainThreadBridge::~MainThreadBridge() |
| 116 { | 116 { |
| 117 } | 117 } |
| 118 | 118 |
| 119 void WorkerThreadableLoader::MainThreadBridge::mainThreadCreateLoader(ExecutionC ontext* context, MainThreadBridge* thisPtr, PassOwnPtr<CrossThreadResourceReques tData> requestData, ThreadableLoaderOptions options, const String& outgoingRefer rer) | 119 void WorkerThreadableLoader::MainThreadBridge::mainThreadCreateLoader(ExecutionC ontext* context, MainThreadBridge* thisPtr, PassOwnPtr<CrossThreadResourceReques tData> requestData, ThreadableLoaderOptions options, const String& outgoingRefer rer) |
| 120 { | 120 { |
| 121 ASSERT(isMainThread()); | 121 ASSERT(isMainThread()); |
| 122 Document* document = toDocument(context); | 122 Document& document = toDocument(*context); |
|
Inactive
2014/03/22 15:09:54
Dereferencing context without a assertion to make
maheshkk
2014/03/24 18:17:48
WorkerThreadableLoader::MainThreadBridge implement
| |
| 123 | 123 |
| 124 OwnPtr<ResourceRequest> request(ResourceRequest::adopt(requestData)); | 124 OwnPtr<ResourceRequest> request(ResourceRequest::adopt(requestData)); |
| 125 request->setHTTPReferrer(Referrer(outgoingReferrer, ReferrerPolicyDefault)); | 125 request->setHTTPReferrer(Referrer(outgoingReferrer, ReferrerPolicyDefault)); |
| 126 options.requestInitiatorContext = WorkerContext; | 126 options.requestInitiatorContext = WorkerContext; |
| 127 thisPtr->m_mainThreadLoader = DocumentThreadableLoader::create(document, thi sPtr, *request, options); | 127 thisPtr->m_mainThreadLoader = DocumentThreadableLoader::create(document, thi sPtr, *request, options); |
| 128 if (!thisPtr->m_mainThreadLoader) { | 128 if (!thisPtr->m_mainThreadLoader) { |
| 129 // DocumentThreadableLoader::create may return 0 when the document loade r has been already changed. | 129 // DocumentThreadableLoader::create may return 0 when the document loade r has been already changed. |
| 130 thisPtr->didFail(ResourceError(errorDomainBlinkInternal, 0, request->url ().string(), "Can't create DocumentThreadableLoader")); | 130 thisPtr->didFail(ResourceError(errorDomainBlinkInternal, 0, request->url ().string(), "Can't create DocumentThreadableLoader")); |
| 131 } | 131 } |
| 132 } | 132 } |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 218 { | 218 { |
| 219 m_clientBridge->didFailAccessControlCheck(error); | 219 m_clientBridge->didFailAccessControlCheck(error); |
| 220 } | 220 } |
| 221 | 221 |
| 222 void WorkerThreadableLoader::MainThreadBridge::didFailRedirectCheck() | 222 void WorkerThreadableLoader::MainThreadBridge::didFailRedirectCheck() |
| 223 { | 223 { |
| 224 m_clientBridge->didFailRedirectCheck(); | 224 m_clientBridge->didFailRedirectCheck(); |
| 225 } | 225 } |
| 226 | 226 |
| 227 } // namespace WebCore | 227 } // namespace WebCore |
| OLD | NEW |