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

Side by Side Diff: Source/web/WebEmbeddedWorkerImpl.cpp

Issue 1187813010: Check whether the shadow page has been loaded in WebEmbeddedWorkerImpl::terminateWorkerContext(). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « Source/web/WebEmbeddedWorkerImpl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 DEFINE_STATIC_LOCAL(HashSet<WebEmbeddedWorkerImpl*>, set, ()); 136 DEFINE_STATIC_LOCAL(HashSet<WebEmbeddedWorkerImpl*>, set, ());
137 return set; 137 return set;
138 } 138 }
139 139
140 WebEmbeddedWorkerImpl::WebEmbeddedWorkerImpl(PassOwnPtr<WebServiceWorkerContextC lient> client, PassOwnPtr<WebWorkerContentSettingsClientProxy> ContentSettingsCl ient) 140 WebEmbeddedWorkerImpl::WebEmbeddedWorkerImpl(PassOwnPtr<WebServiceWorkerContextC lient> client, PassOwnPtr<WebWorkerContentSettingsClientProxy> ContentSettingsCl ient)
141 : m_workerContextClient(client) 141 : m_workerContextClient(client)
142 , m_contentSettingsClient(ContentSettingsClient) 142 , m_contentSettingsClient(ContentSettingsClient)
143 , m_workerInspectorProxy(WorkerInspectorProxy::create()) 143 , m_workerInspectorProxy(WorkerInspectorProxy::create())
144 , m_webView(0) 144 , m_webView(0)
145 , m_mainFrame(0) 145 , m_mainFrame(0)
146 , m_loadingShadowPage(false)
146 , m_askedToTerminate(false) 147 , m_askedToTerminate(false)
147 , m_pauseAfterDownloadState(DontPauseAfterDownload) 148 , m_pauseAfterDownloadState(DontPauseAfterDownload)
148 , m_waitingForDebuggerState(NotWaitingForDebugger) 149 , m_waitingForDebuggerState(NotWaitingForDebugger)
149 { 150 {
150 runningWorkerInstances().add(this); 151 runningWorkerInstances().add(this);
151 } 152 }
152 153
153 WebEmbeddedWorkerImpl::~WebEmbeddedWorkerImpl() 154 WebEmbeddedWorkerImpl::~WebEmbeddedWorkerImpl()
154 { 155 {
155 // Prevent onScriptLoaderFinished from deleting 'this'. 156 // Prevent onScriptLoaderFinished from deleting 'this'.
156 m_askedToTerminate = true; 157 m_askedToTerminate = true;
falken 2015/06/16 06:48:15 Maybe we also need a workerContextFailedtoStart he
horo 2015/06/16 07:21:52 No. This destructor is called from workerContextFa
157 158
158 if (m_workerThread) 159 if (m_workerThread)
159 m_workerThread->terminateAndWait(); 160 m_workerThread->terminateAndWait();
160 161
161 ASSERT(runningWorkerInstances().contains(this)); 162 ASSERT(runningWorkerInstances().contains(this));
162 runningWorkerInstances().remove(this); 163 runningWorkerInstances().remove(this);
163 ASSERT(m_webView); 164 ASSERT(m_webView);
164 165
165 // Detach the client before closing the view to avoid getting called back. 166 // Detach the client before closing the view to avoid getting called back.
166 m_mainFrame->setClient(0); 167 m_mainFrame->setClient(0);
(...skipping 22 matching lines...) Expand all
189 if (data.pauseAfterDownloadMode == WebEmbeddedWorkerStartData::PauseAfterDow nload) 190 if (data.pauseAfterDownloadMode == WebEmbeddedWorkerStartData::PauseAfterDow nload)
190 m_pauseAfterDownloadState = DoPauseAfterDownload; 191 m_pauseAfterDownloadState = DoPauseAfterDownload;
191 prepareShadowPageForLoader(); 192 prepareShadowPageForLoader();
192 } 193 }
193 194
194 void WebEmbeddedWorkerImpl::terminateWorkerContext() 195 void WebEmbeddedWorkerImpl::terminateWorkerContext()
195 { 196 {
196 if (m_askedToTerminate) 197 if (m_askedToTerminate)
197 return; 198 return;
198 m_askedToTerminate = true; 199 m_askedToTerminate = true;
200 if (m_loadingShadowPage) {
201 // This may delete 'this'.
202 m_workerContextClient->workerContextFailedToStart();
203 return;
204 }
199 if (m_mainScriptLoader) { 205 if (m_mainScriptLoader) {
200 m_mainScriptLoader->cancel(); 206 m_mainScriptLoader->cancel();
201 m_mainScriptLoader.clear(); 207 m_mainScriptLoader.clear();
202 // This may delete 'this'. 208 // This may delete 'this'.
203 m_workerContextClient->workerContextFailedToStart(); 209 m_workerContextClient->workerContextFailedToStart();
204 return; 210 return;
205 } 211 }
206 if (m_pauseAfterDownloadState == IsPausedAfterDownload) { 212 if (m_pauseAfterDownloadState == IsPausedAfterDownload) {
207 // This may delete 'this'. 213 // This may delete 'this'.
208 m_workerContextClient->workerContextFailedToStart(); 214 m_workerContextClient->workerContextFailedToStart();
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 loadShadowPage(); 325 loadShadowPage();
320 } 326 }
321 327
322 void WebEmbeddedWorkerImpl::loadShadowPage() 328 void WebEmbeddedWorkerImpl::loadShadowPage()
323 { 329 {
324 // Construct substitute data source for the 'shadow page'. We only need it 330 // Construct substitute data source for the 'shadow page'. We only need it
325 // to have same origin as the worker so the loading checks work correctly. 331 // to have same origin as the worker so the loading checks work correctly.
326 CString content(""); 332 CString content("");
327 int length = static_cast<int>(content.length()); 333 int length = static_cast<int>(content.length());
328 RefPtr<SharedBuffer> buffer(SharedBuffer::create(content.data(), length)); 334 RefPtr<SharedBuffer> buffer(SharedBuffer::create(content.data(), length));
335 m_loadingShadowPage = true;
329 m_mainFrame->frame()->loader().load(FrameLoadRequest(0, ResourceRequest(m_wo rkerStartData.scriptURL), SubstituteData(buffer, "text/html", "UTF-8", KURL()))) ; 336 m_mainFrame->frame()->loader().load(FrameLoadRequest(0, ResourceRequest(m_wo rkerStartData.scriptURL), SubstituteData(buffer, "text/html", "UTF-8", KURL()))) ;
330 } 337 }
331 338
332 void WebEmbeddedWorkerImpl::willSendRequest( 339 void WebEmbeddedWorkerImpl::willSendRequest(
333 WebLocalFrame* frame, unsigned, WebURLRequest& request, 340 WebLocalFrame* frame, unsigned, WebURLRequest& request,
334 const WebURLResponse& redirectResponse) 341 const WebURLResponse& redirectResponse)
335 { 342 {
336 if (m_networkProvider) 343 if (m_networkProvider)
337 m_networkProvider->willSendRequest(frame->dataSource(), request); 344 m_networkProvider->willSendRequest(frame->dataSource(), request);
338 } 345 }
339 346
340 void WebEmbeddedWorkerImpl::didFinishDocumentLoad(WebLocalFrame* frame) 347 void WebEmbeddedWorkerImpl::didFinishDocumentLoad(WebLocalFrame* frame)
341 { 348 {
342 ASSERT(!m_mainScriptLoader); 349 ASSERT(!m_mainScriptLoader);
343 ASSERT(!m_networkProvider); 350 ASSERT(!m_networkProvider);
344 ASSERT(m_mainFrame); 351 ASSERT(m_mainFrame);
345 ASSERT(m_workerContextClient); 352 ASSERT(m_workerContextClient);
falken 2015/06/16 06:48:15 Should we deal with m_askedToTerminate here? As I
horo 2015/06/16 07:21:52 Added ASSERT(). This method will not be called aft
353 m_loadingShadowPage = false;
346 m_networkProvider = adoptPtr(m_workerContextClient->createServiceWorkerNetwo rkProvider(frame->dataSource())); 354 m_networkProvider = adoptPtr(m_workerContextClient->createServiceWorkerNetwo rkProvider(frame->dataSource()));
347 m_mainScriptLoader = Loader::create(); 355 m_mainScriptLoader = Loader::create();
348 m_mainScriptLoader->load( 356 m_mainScriptLoader->load(
349 m_mainFrame->frame()->document(), 357 m_mainFrame->frame()->document(),
350 m_workerStartData.scriptURL, 358 m_workerStartData.scriptURL,
351 bind(&WebEmbeddedWorkerImpl::onScriptLoaderFinished, this)); 359 bind(&WebEmbeddedWorkerImpl::onScriptLoaderFinished, this));
352 } 360 }
353 361
354 void WebEmbeddedWorkerImpl::sendProtocolMessage(int callId, const WebString& mes sage, const WebString& state) 362 void WebEmbeddedWorkerImpl::sendProtocolMessage(int callId, const WebString& mes sage, const WebString& state)
355 { 363 {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 m_mainScriptLoader.clear(); 437 m_mainScriptLoader.clear();
430 438
431 m_workerGlobalScopeProxy = ServiceWorkerGlobalScopeProxy::create(*this, *doc ument, *m_workerContextClient); 439 m_workerGlobalScopeProxy = ServiceWorkerGlobalScopeProxy::create(*this, *doc ument, *m_workerContextClient);
432 m_loaderProxy = WorkerLoaderProxy::create(this); 440 m_loaderProxy = WorkerLoaderProxy::create(this);
433 m_workerThread = ServiceWorkerThread::create(m_loaderProxy, *m_workerGlobalS copeProxy); 441 m_workerThread = ServiceWorkerThread::create(m_loaderProxy, *m_workerGlobalS copeProxy);
434 m_workerThread->start(startupData.release()); 442 m_workerThread->start(startupData.release());
435 m_workerInspectorProxy->workerThreadCreated(document, m_workerThread.get(), scriptURL); 443 m_workerInspectorProxy->workerThreadCreated(document, m_workerThread.get(), scriptURL);
436 } 444 }
437 445
438 } // namespace blink 446 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/WebEmbeddedWorkerImpl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698