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

Unified Diff: Source/core/workers/SharedWorker.cpp

Issue 40143003: Simplify SharedWorkerRepository code (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/workers/DefaultSharedWorkerRepository.h ('k') | Source/core/workers/SharedWorkerRepository.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/workers/SharedWorker.cpp
diff --git a/Source/core/workers/SharedWorker.cpp b/Source/core/workers/SharedWorker.cpp
index 781c4f6ca4eb9a7d7007305c7f68d80c220b47be..a7a72c5e2dcf55fd7164fe9286d3db81ec677487 100644
--- a/Source/core/workers/SharedWorker.cpp
+++ b/Source/core/workers/SharedWorker.cpp
@@ -38,8 +38,9 @@
#include "core/dom/MessageChannel.h"
#include "core/dom/MessagePort.h"
#include "core/inspector/InspectorInstrumentation.h"
+#include "core/page/Page.h"
#include "core/page/UseCounter.h"
-#include "core/workers/SharedWorkerRepository.h"
+#include "core/workers/SharedWorkerRepositoryClient.h"
#include "weborigin/KURL.h"
#include "weborigin/SecurityOrigin.h"
@@ -54,6 +55,8 @@ inline SharedWorker::SharedWorker(ExecutionContext* context)
PassRefPtr<SharedWorker> SharedWorker::create(ExecutionContext* context, const String& url, const String& name, ExceptionState& es)
{
ASSERT(isMainThread());
+ ASSERT_WITH_SECURITY_IMPLICATION(context->isDocument());
+
UseCounter::count(toDocument(context)->domWindow(), UseCounter::SharedWorkerStart);
RefPtr<SharedWorker> worker = adoptRef(new SharedWorker(context));
@@ -66,7 +69,6 @@ PassRefPtr<SharedWorker> SharedWorker::create(ExecutionContext* context, const S
worker->suspendIfNeeded();
// We don't currently support nested workers, so workers can only be created from documents.
- ASSERT_WITH_SECURITY_IMPLICATION(context->isDocument());
Document* document = toDocument(context);
if (!document->securityOrigin()->canAccessSharedWorkers()) {
es.throwSecurityError("Failed to create 'SharedWorker': access to shared workers is denied to origin '" + document->securityOrigin()->toString() + "'.");
@@ -77,7 +79,8 @@ PassRefPtr<SharedWorker> SharedWorker::create(ExecutionContext* context, const S
if (scriptURL.isEmpty())
return 0;
- SharedWorkerRepository::connect(worker.get(), remotePort.release(), scriptURL, name, es);
+ if (document->page() && document->page()->sharedWorkerRepositoryClient())
+ document->page()->sharedWorkerRepositoryClient()->connect(worker.get(), remotePort.release(), scriptURL, name, es);
return worker.release();
}
« no previous file with comments | « Source/core/workers/DefaultSharedWorkerRepository.h ('k') | Source/core/workers/SharedWorkerRepository.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698