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

Unified Diff: third_party/WebKit/Source/modules/serviceworkers/InstallEvent.cpp

Issue 1406823002: Start of foreign fetch implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove blank line Created 5 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
Index: third_party/WebKit/Source/modules/serviceworkers/InstallEvent.cpp
diff --git a/third_party/WebKit/Source/modules/serviceworkers/InstallEvent.cpp b/third_party/WebKit/Source/modules/serviceworkers/InstallEvent.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8ecb5d070fcb4655389e5ba67bc0fa032d7fe72b
--- /dev/null
+++ b/third_party/WebKit/Source/modules/serviceworkers/InstallEvent.cpp
@@ -0,0 +1,84 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+#include "InstallEvent.h"
+
+#include "core/dom/ExceptionCode.h"
+#include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h"
+
+namespace blink {
+
+PassRefPtrWillBeRawPtr<InstallEvent> InstallEvent::create()
+{
+ return adoptRefWillBeNoop(new InstallEvent());
+}
+
+PassRefPtrWillBeRawPtr<InstallEvent> InstallEvent::create(const AtomicString& type, const ExtendableEventInit& eventInit)
+{
+ return adoptRefWillBeNoop(new InstallEvent(type, eventInit));
+}
+
+PassRefPtrWillBeRawPtr<InstallEvent> InstallEvent::create(const AtomicString& type, const ExtendableEventInit& eventInit, WaitUntilObserver* observer)
+{
+ return adoptRefWillBeNoop(new InstallEvent(type, eventInit, observer));
+}
+
+InstallEvent::~InstallEvent()
+{
+}
+
+void InstallEvent::registerForeignFetchScopes(ExecutionContext* executionContext, const Vector<String>& subScopes, ExceptionState& exceptionState)
+{
+ if (!isBeingDispatched()) {
+ exceptionState.throwDOMException(InvalidStateError, "The event handler is already finished.");
+ return;
+ }
+
+ ServiceWorkerGlobalScopeClient* client = ServiceWorkerGlobalScopeClient::from(executionContext);
+
+ String scopePath = static_cast<KURL>(client->scope()).path();
+ RefPtr<SecurityOrigin> origin = executionContext->securityOrigin();
+
+ Vector<KURL> subScopeURLs(subScopes.size());
+ for (size_t i = 0; i < subScopes.size(); ++i) {
+ subScopeURLs[i] = executionContext->completeURL(subScopes[i]);
+ if (!subScopeURLs[i].isValid()) {
+ exceptionState.throwTypeError("Invalid URL: " + subScopes[i]);
+ return;
+ }
+ subScopeURLs[i].removeFragmentIdentifier();
+ if (!origin->canRequest(subScopeURLs[i])) {
+ exceptionState.throwTypeError("URL is not within scope: " + subScopes[i]);
+ return;
+ }
+ String subScopePath = subScopeURLs[i].path();
+ if (!subScopePath.startsWith(scopePath)) {
+ exceptionState.throwTypeError("URL is not within scope: " + subScopes[i]);
+ return;
+ }
+ }
+ client->registerForeignFetchScopes(subScopeURLs);
+}
+
+const AtomicString& InstallEvent::interfaceName() const
+{
+ return EventNames::InstallEvent;
+}
+
+InstallEvent::InstallEvent()
+{
+}
+
+InstallEvent::InstallEvent(const AtomicString& type, const ExtendableEventInit& initializer)
+ : ExtendableEvent(type, initializer)
+{
+}
+
+InstallEvent::InstallEvent(const AtomicString& type, const ExtendableEventInit& initializer, WaitUntilObserver* observer)
+ : ExtendableEvent(type, initializer, observer)
+{
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698