Index: third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerWindowClientCallback.cpp |
diff --git a/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerWindowClientCallback.cpp b/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerWindowClientCallback.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d66006616364954cd07a7697237f3c89c9ec463e |
--- /dev/null |
+++ b/third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerWindowClientCallback.cpp |
@@ -0,0 +1,36 @@ |
+// 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 "modules/serviceworkers/ServiceWorkerWindowClientCallback.h" |
+ |
+#include "bindings/core/v8/ScriptPromiseResolver.h" |
+#include "core/dom/DOMException.h" |
+#include "modules/serviceworkers/ServiceWorkerError.h" |
+#include "modules/serviceworkers/ServiceWorkerWindowClient.h" |
+ |
+namespace blink { |
+ |
+void NavigateClientCallback::onSuccess(WebPassOwnPtr<WebServiceWorkerClientInfo> clientInfo) |
+{ |
+ if (!m_resolver->executionContext() || m_resolver->executionContext()->activeDOMObjectsAreStopped()) |
+ return; |
+ m_resolver->resolve(ServiceWorkerWindowClient::take(m_resolver.get(), clientInfo.release())); |
+} |
+ |
+void NavigateClientCallback::onError(const WebServiceWorkerError& error) |
+{ |
+ if (!m_resolver->executionContext() || m_resolver->executionContext()->activeDOMObjectsAreStopped()) |
+ return; |
+ |
+ if (error.errorType == WebServiceWorkerError::ErrorTypeNavigation) { |
+ ScriptState::Scope scope(m_resolver->scriptState()); |
+ m_resolver->reject(V8ThrowException::createTypeError(m_resolver->scriptState()->isolate(), error.message)); |
+ return; |
+ } |
+ |
+ m_resolver->reject(ServiceWorkerError::take(m_resolver.get(), error)); |
+} |
+ |
+} // namespace blink |