Index: third_party/WebKit/Source/bindings/modules/v8/V8ServiceWorkerMessageEventInternal.h |
diff --git a/third_party/WebKit/Source/bindings/modules/v8/custom/V8ServiceWorkerMessageEventCustom.cpp b/third_party/WebKit/Source/bindings/modules/v8/V8ServiceWorkerMessageEventInternal.h |
similarity index 70% |
copy from third_party/WebKit/Source/bindings/modules/v8/custom/V8ServiceWorkerMessageEventCustom.cpp |
copy to third_party/WebKit/Source/bindings/modules/v8/V8ServiceWorkerMessageEventInternal.h |
index 6caffeb536c1e5e59b09fdea5838c980f39ada4d..eed117a19d4ec2ebb0f9b26c10a37bcbdb5f1fe8 100644 |
--- a/third_party/WebKit/Source/bindings/modules/v8/custom/V8ServiceWorkerMessageEventCustom.cpp |
+++ b/third_party/WebKit/Source/bindings/modules/v8/V8ServiceWorkerMessageEventInternal.h |
@@ -1,19 +1,29 @@ |
-// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Copyright 2016 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 "bindings/modules/v8/V8ServiceWorkerMessageEvent.h" |
+#ifndef V8ServiceWorkerMessageEventInternal_h |
+#define V8ServiceWorkerMessageEventInternal_h |
#include "bindings/core/v8/SerializedScriptValue.h" |
#include "bindings/core/v8/SerializedScriptValueFactory.h" |
#include "bindings/core/v8/V8HiddenValue.h" |
-#include "bindings/modules/v8/V8ServiceWorkerMessageEventInit.h" |
namespace blink { |
-void V8ServiceWorkerMessageEvent::constructorCustom(const v8::FunctionCallbackInfo<v8::Value>& info) |
+class V8ServiceWorkerMessageEventInternal { |
+public: |
+ template <typename EventType, typename DictType> |
+ static void constructorCustom(const v8::FunctionCallbackInfo<v8::Value>&); |
+ |
+ template <typename EventType> |
+ static void dataAttributeGetterCustom(const v8::FunctionCallbackInfo<v8::Value>&); |
+}; |
+ |
+template <typename EventType, typename DictType> |
+void V8ServiceWorkerMessageEventInternal::constructorCustom(const v8::FunctionCallbackInfo<v8::Value>& info) |
{ |
- ExceptionState exceptionState(ExceptionState::ConstructionContext, "ServiceWorkerMessageEvent", info.Holder(), info.GetIsolate()); |
+ ExceptionState exceptionState(ExceptionState::ConstructionContext, V8TypeOf<EventType>::Type::wrapperTypeInfo.interfaceName, info.Holder(), info.GetIsolate()); |
if (UNLIKELY(info.Length() < 1)) { |
setMinimumArityTypeError(exceptionState, 1, info.Length()); |
exceptionState.throwIfNeeded(); |
@@ -24,21 +34,21 @@ void V8ServiceWorkerMessageEvent::constructorCustom(const v8::FunctionCallbackIn |
if (!type.prepare()) |
return; |
- ServiceWorkerMessageEventInit eventInitDict; |
+ DictType eventInitDict; |
if (!isUndefinedOrNull(info[1])) { |
if (!info[1]->IsObject()) { |
exceptionState.throwTypeError("parameter 2 ('eventInitDict') is not an object."); |
exceptionState.throwIfNeeded(); |
return; |
} |
- V8ServiceWorkerMessageEventInit::toImpl(info.GetIsolate(), info[1], eventInitDict, exceptionState); |
+ V8TypeOf<DictType>::Type::toImpl(info.GetIsolate(), info[1], eventInitDict, exceptionState); |
if (exceptionState.throwIfNeeded()) |
return; |
} |
- RefPtrWillBeRawPtr<ServiceWorkerMessageEvent> impl = ServiceWorkerMessageEvent::create(type, eventInitDict); |
+ RefPtrWillBeRawPtr<EventType> impl = EventType::create(type, eventInitDict); |
v8::Local<v8::Object> wrapper = info.Holder(); |
- wrapper = impl->associateWithWrapper(info.GetIsolate(), &V8ServiceWorkerMessageEvent::wrapperTypeInfo, wrapper); |
+ wrapper = impl->associateWithWrapper(info.GetIsolate(), &V8TypeOf<EventType>::Type::wrapperTypeInfo, wrapper); |
// TODO(bashi): Workaround for http://crbug.com/529941. We need to store |
// |data| as a hidden value to avoid cycle references. |
@@ -51,9 +61,10 @@ void V8ServiceWorkerMessageEvent::constructorCustom(const v8::FunctionCallbackIn |
v8SetReturnValue(info, wrapper); |
} |
-void V8ServiceWorkerMessageEvent::dataAttributeGetterCustom(const v8::FunctionCallbackInfo<v8::Value>& info) |
+template <typename EventType> |
+void V8ServiceWorkerMessageEventInternal::dataAttributeGetterCustom(const v8::FunctionCallbackInfo<v8::Value>& info) |
{ |
- ServiceWorkerMessageEvent* event = V8ServiceWorkerMessageEvent::toImpl(info.Holder()); |
+ EventType* event = V8TypeOf<EventType>::Type::toImpl(info.Holder()); |
v8::Isolate* isolate = info.GetIsolate(); |
ScriptState* scriptState = ScriptState::current(isolate); |
v8::Local<v8::Value> result = V8HiddenValue::getHiddenValue(scriptState, info.Holder(), V8HiddenValue::data(isolate)); |
@@ -83,3 +94,5 @@ void V8ServiceWorkerMessageEvent::dataAttributeGetterCustom(const v8::FunctionCa |
} |
} // namespace blink |
+ |
+#endif // V8ServiceWorkerMessageEventInternal_h |