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

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

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments from Kent; merge. Created 4 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
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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 #include "public/web/WebWorkerContentSettingsClientProxy.h" 64 #include "public/web/WebWorkerContentSettingsClientProxy.h"
65 #include "public/web/modules/serviceworker/WebServiceWorkerContextClient.h" 65 #include "public/web/modules/serviceworker/WebServiceWorkerContextClient.h"
66 #include "public/web/modules/serviceworker/WebServiceWorkerNetworkProvider.h" 66 #include "public/web/modules/serviceworker/WebServiceWorkerNetworkProvider.h"
67 #include "web/IndexedDBClientImpl.h" 67 #include "web/IndexedDBClientImpl.h"
68 #include "web/ServiceWorkerGlobalScopeClientImpl.h" 68 #include "web/ServiceWorkerGlobalScopeClientImpl.h"
69 #include "web/ServiceWorkerGlobalScopeProxy.h" 69 #include "web/ServiceWorkerGlobalScopeProxy.h"
70 #include "web/WebDataSourceImpl.h" 70 #include "web/WebDataSourceImpl.h"
71 #include "web/WebLocalFrameImpl.h" 71 #include "web/WebLocalFrameImpl.h"
72 #include "web/WorkerContentSettingsClient.h" 72 #include "web/WorkerContentSettingsClient.h"
73 #include "wtf/Functional.h" 73 #include "wtf/Functional.h"
74 #include "wtf/PtrUtil.h"
75 #include <memory>
74 76
75 namespace blink { 77 namespace blink {
76 78
77 WebEmbeddedWorker* WebEmbeddedWorker::create(WebServiceWorkerContextClient* clie nt, WebWorkerContentSettingsClientProxy* contentSettingsClient) 79 WebEmbeddedWorker* WebEmbeddedWorker::create(WebServiceWorkerContextClient* clie nt, WebWorkerContentSettingsClientProxy* contentSettingsClient)
78 { 80 {
79 return new WebEmbeddedWorkerImpl(adoptPtr(client), adoptPtr(contentSettingsC lient)); 81 return new WebEmbeddedWorkerImpl(wrapUnique(client), wrapUnique(contentSetti ngsClient));
80 } 82 }
81 83
82 static HashSet<WebEmbeddedWorkerImpl*>& runningWorkerInstances() 84 static HashSet<WebEmbeddedWorkerImpl*>& runningWorkerInstances()
83 { 85 {
84 DEFINE_STATIC_LOCAL(HashSet<WebEmbeddedWorkerImpl*>, set, ()); 86 DEFINE_STATIC_LOCAL(HashSet<WebEmbeddedWorkerImpl*>, set, ());
85 return set; 87 return set;
86 } 88 }
87 89
88 WebEmbeddedWorkerImpl::WebEmbeddedWorkerImpl(PassOwnPtr<WebServiceWorkerContextC lient> client, PassOwnPtr<WebWorkerContentSettingsClientProxy> contentSettingsCl ient) 90 WebEmbeddedWorkerImpl::WebEmbeddedWorkerImpl(std::unique_ptr<WebServiceWorkerCon textClient> client, std::unique_ptr<WebWorkerContentSettingsClientProxy> content SettingsClient)
89 : m_workerContextClient(std::move(client)) 91 : m_workerContextClient(std::move(client))
90 , m_contentSettingsClient(std::move(contentSettingsClient)) 92 , m_contentSettingsClient(std::move(contentSettingsClient))
91 , m_workerInspectorProxy(WorkerInspectorProxy::create()) 93 , m_workerInspectorProxy(WorkerInspectorProxy::create())
92 , m_webView(nullptr) 94 , m_webView(nullptr)
93 , m_mainFrame(nullptr) 95 , m_mainFrame(nullptr)
94 , m_loadingShadowPage(false) 96 , m_loadingShadowPage(false)
95 , m_askedToTerminate(false) 97 , m_askedToTerminate(false)
96 , m_pauseAfterDownloadState(DontPauseAfterDownload) 98 , m_pauseAfterDownloadState(DontPauseAfterDownload)
97 , m_waitingForDebuggerState(NotWaitingForDebugger) 99 , m_waitingForDebuggerState(NotWaitingForDebugger)
98 { 100 {
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 322
321 void WebEmbeddedWorkerImpl::didFinishDocumentLoad(WebLocalFrame* frame) 323 void WebEmbeddedWorkerImpl::didFinishDocumentLoad(WebLocalFrame* frame)
322 { 324 {
323 DCHECK(!m_mainScriptLoader); 325 DCHECK(!m_mainScriptLoader);
324 DCHECK(!m_networkProvider); 326 DCHECK(!m_networkProvider);
325 DCHECK(m_mainFrame); 327 DCHECK(m_mainFrame);
326 DCHECK(m_workerContextClient); 328 DCHECK(m_workerContextClient);
327 DCHECK(m_loadingShadowPage); 329 DCHECK(m_loadingShadowPage);
328 DCHECK(!m_askedToTerminate); 330 DCHECK(!m_askedToTerminate);
329 m_loadingShadowPage = false; 331 m_loadingShadowPage = false;
330 m_networkProvider = adoptPtr(m_workerContextClient->createServiceWorkerNetwo rkProvider(frame->dataSource())); 332 m_networkProvider = wrapUnique(m_workerContextClient->createServiceWorkerNet workProvider(frame->dataSource()));
331 m_mainScriptLoader = WorkerScriptLoader::create(); 333 m_mainScriptLoader = WorkerScriptLoader::create();
332 m_mainScriptLoader->setRequestContext(WebURLRequest::RequestContextServiceWo rker); 334 m_mainScriptLoader->setRequestContext(WebURLRequest::RequestContextServiceWo rker);
333 m_mainScriptLoader->loadAsynchronously( 335 m_mainScriptLoader->loadAsynchronously(
334 *m_mainFrame->frame()->document(), 336 *m_mainFrame->frame()->document(),
335 m_workerStartData.scriptURL, 337 m_workerStartData.scriptURL,
336 DenyCrossOriginRequests, 338 DenyCrossOriginRequests,
337 m_workerStartData.addressSpace, 339 m_workerStartData.addressSpace,
338 nullptr, 340 nullptr,
339 bind(&WebEmbeddedWorkerImpl::onScriptLoaderFinished, this)); 341 bind(&WebEmbeddedWorkerImpl::onScriptLoaderFinished, this));
340 // Do nothing here since onScriptLoaderFinished() might have been already 342 // Do nothing here since onScriptLoaderFinished() might have been already
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 396
395 Document* document = m_mainFrame->frame()->document(); 397 Document* document = m_mainFrame->frame()->document();
396 398
397 // FIXME: this document's origin is pristine and without any extra privilege s. (crbug.com/254993) 399 // FIXME: this document's origin is pristine and without any extra privilege s. (crbug.com/254993)
398 SecurityOrigin* starterOrigin = document->getSecurityOrigin(); 400 SecurityOrigin* starterOrigin = document->getSecurityOrigin();
399 401
400 WorkerClients* workerClients = WorkerClients::create(); 402 WorkerClients* workerClients = WorkerClients::create();
401 provideContentSettingsClientToWorker(workerClients, std::move(m_contentSetti ngsClient)); 403 provideContentSettingsClientToWorker(workerClients, std::move(m_contentSetti ngsClient));
402 provideIndexedDBClientToWorker(workerClients, IndexedDBClientImpl::create()) ; 404 provideIndexedDBClientToWorker(workerClients, IndexedDBClientImpl::create()) ;
403 provideServiceWorkerGlobalScopeClientToWorker(workerClients, ServiceWorkerGl obalScopeClientImpl::create(*m_workerContextClient)); 405 provideServiceWorkerGlobalScopeClientToWorker(workerClients, ServiceWorkerGl obalScopeClientImpl::create(*m_workerContextClient));
404 provideServiceWorkerContainerClientToWorker(workerClients, adoptPtr(m_worker ContextClient->createServiceWorkerProvider())); 406 provideServiceWorkerContainerClientToWorker(workerClients, wrapUnique(m_work erContextClient->createServiceWorkerProvider()));
405 407
406 // We need to set the CSP to both the shadow page's document and the Service WorkerGlobalScope. 408 // We need to set the CSP to both the shadow page's document and the Service WorkerGlobalScope.
407 document->initContentSecurityPolicy(m_mainScriptLoader->releaseContentSecuri tyPolicy()); 409 document->initContentSecurityPolicy(m_mainScriptLoader->releaseContentSecuri tyPolicy());
408 410
409 KURL scriptURL = m_mainScriptLoader->url(); 411 KURL scriptURL = m_mainScriptLoader->url();
410 WorkerThreadStartMode startMode = m_workerInspectorProxy->workerStartMode(do cument); 412 WorkerThreadStartMode startMode = m_workerInspectorProxy->workerStartMode(do cument);
411 413
412 OwnPtr<WorkerThreadStartupData> startupData = WorkerThreadStartupData::creat e( 414 std::unique_ptr<WorkerThreadStartupData> startupData = WorkerThreadStartupDa ta::create(
413 scriptURL, 415 scriptURL,
414 m_workerStartData.userAgent, 416 m_workerStartData.userAgent,
415 m_mainScriptLoader->script(), 417 m_mainScriptLoader->script(),
416 m_mainScriptLoader->releaseCachedMetadata(), 418 m_mainScriptLoader->releaseCachedMetadata(),
417 startMode, 419 startMode,
418 document->contentSecurityPolicy()->headers().get(), 420 document->contentSecurityPolicy()->headers().get(),
419 starterOrigin, 421 starterOrigin,
420 workerClients, 422 workerClients,
421 m_mainScriptLoader->responseAddressSpace(), 423 m_mainScriptLoader->responseAddressSpace(),
422 m_mainScriptLoader->originTrialTokens(), 424 m_mainScriptLoader->originTrialTokens(),
423 static_cast<V8CacheOptions>(m_workerStartData.v8CacheOptions)); 425 static_cast<V8CacheOptions>(m_workerStartData.v8CacheOptions));
424 426
425 m_mainScriptLoader.clear(); 427 m_mainScriptLoader.clear();
426 428
427 m_workerGlobalScopeProxy = ServiceWorkerGlobalScopeProxy::create(*this, *doc ument, *m_workerContextClient); 429 m_workerGlobalScopeProxy = ServiceWorkerGlobalScopeProxy::create(*this, *doc ument, *m_workerContextClient);
428 m_loaderProxy = WorkerLoaderProxy::create(this); 430 m_loaderProxy = WorkerLoaderProxy::create(this);
429 m_workerThread = ServiceWorkerThread::create(m_loaderProxy, *m_workerGlobalS copeProxy); 431 m_workerThread = ServiceWorkerThread::create(m_loaderProxy, *m_workerGlobalS copeProxy);
430 m_workerThread->start(std::move(startupData)); 432 m_workerThread->start(std::move(startupData));
431 m_workerInspectorProxy->workerThreadCreated(document, m_workerThread.get(), scriptURL); 433 m_workerInspectorProxy->workerThreadCreated(document, m_workerThread.get(), scriptURL);
432 } 434 }
433 435
434 } // namespace blink 436 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698