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

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

Issue 474683003: Not for review - Rebase of crrev.com/62833003 Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: . Created 6 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/UIWorker.h ('k') | Source/core/workers/UIWorker.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/workers/UIWorker.cpp
diff --git a/Source/core/workers/UIWorker.cpp b/Source/core/workers/UIWorker.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c6e597e71bbc01e168824a809377fc18f28d9a27
--- /dev/null
+++ b/Source/core/workers/UIWorker.cpp
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2008, 2010 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2009 Google Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include "config.h"
+#include "core/workers/UIWorker.h"
+
+#include "bindings/core/v8/ExceptionState.h"
+#include "core/dom/Document.h"
+#include "core/events/MessageEvent.h"
+#include "core/fetch/ResourceFetcher.h"
+#include "core/frame/LocalDOMWindow.h"
+#include "core/frame/UseCounter.h"
+#include "core/inspector/InspectorInstrumentation.h"
+#include "core/workers/WorkerGlobalScopeProxy.h"
+#include "core/workers/WorkerGlobalScopeProxyProvider.h"
+#include "core/workers/WorkerScriptLoader.h"
+#include "core/workers/WorkerThread.h"
+#include "platform/TraceEvent.h"
+#include "wtf/MainThread.h"
+
+namespace blink {
+
+inline UIWorker::UIWorker(ExecutionContext* context)
+ : Worker(context)
+{
+ TRACE_EVENT0("teleport,uiworker", "UIWorker::UIWorker");
+}
+
+PassRefPtrWillBeRawPtr<UIWorker> UIWorker::create(ExecutionContext* context, const String& url, ExceptionState& exceptionState)
+{
+ ASSERT(isMainThread());
+ Document* document = toDocument(context);
+ UseCounter::count(context, UseCounter::WorkerStart);
+ if (!document->page()) {
+ exceptionState.throwDOMException(InvalidAccessError, "The context provided is invalid.");
+ return nullptr;
+ }
+ WorkerGlobalScopeProxyProvider* proxyProvider = WorkerGlobalScopeProxyProvider::from(*document->page());
+ ASSERT(proxyProvider);
+
+ RefPtrWillBeRawPtr<UIWorker> worker = adoptRefWillBeNoop(new UIWorker(context));
+
+ worker->suspendIfNeeded();
+
+ KURL scriptURL = worker->resolveURL(url, exceptionState);
+ if (scriptURL.isEmpty())
+ return nullptr;
+
+ worker->initScriptLoader(context, scriptURL);
+ worker->setContextProxy(proxyProvider->createWorkerGlobalScopeProxy(worker.get()));
+ return worker.release();
+}
+
+UIWorker::~UIWorker()
+{
+ ASSERT(isMainThread());
+}
+
+const AtomicString& UIWorker::interfaceName() const
+{
+ return EventTargetNames::UIWorker;
+}
+
+} // namespace blink
« no previous file with comments | « Source/core/workers/UIWorker.h ('k') | Source/core/workers/UIWorker.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698