Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Side by Side Diff: Source/core/loader/WorkerThreadableLoader.cpp

Issue 204983007: Make ThreadableLoader class to use references (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added asserts Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
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);
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, th isPtr, *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 }
133 133
134 void WorkerThreadableLoader::MainThreadBridge::mainThreadDestroy(ExecutionContex t* context, MainThreadBridge* thisPtr) 134 void WorkerThreadableLoader::MainThreadBridge::mainThreadDestroy(ExecutionContex t* context, MainThreadBridge* thisPtr)
135 { 135 {
136 ASSERT(isMainThread()); 136 ASSERT(isMainThread());
137 ASSERT_UNUSED(context, context->isDocument()); 137 ASSERT_UNUSED(context, context->isDocument());
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698