Commit c150a472 authored by dominicc@chromium.org's avatar dominicc@chromium.org

Pass script state to Web API object->script wrappable converter.

This is required to create script wrappable objects which depend on
their execution context, such as EventTargets and ActiveDOMObjects.

BUG=349919
TBR=mvanouwerkerk@chromium.org

Review URL: https://codereview.chromium.org/236133002

git-svn-id: svn://svn.chromium.org/blink/trunk@171413 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent e4d436b4
......@@ -47,7 +47,8 @@ namespace WebCore {
//
// class MyClass ... {
// typedef blink::WebMyClass WebType;
// static PassRefPtr<MyClass> from(blink::WebMyClass* webInstance) {
// static PassRefPtr<MyClass> from(NewScriptState*,
// blink::WebMyClass* webInstance) {
// // convert/create as appropriate, but often it's just:
// return MyClass::create(adoptPtr(webInstance));
// }
......@@ -73,12 +74,12 @@ public:
virtual void onSuccess(typename S::WebType* result) OVERRIDE
{
NewScriptState::Scope scope(m_scriptState.get());
m_resolver->resolve(S::from(result));
m_resolver->resolve(S::from(m_scriptState.get(), result));
}
virtual void onError(typename T::WebType* error) OVERRIDE
{
NewScriptState::Scope scope(m_scriptState.get());
m_resolver->reject(T::from(error));
m_resolver->reject(T::from(m_scriptState.get(), error));
}
private:
RefPtr<ScriptPromiseResolver> m_resolver;
......
......@@ -12,12 +12,14 @@
namespace WebCore {
class NewScriptState;
class PushError {
WTF_MAKE_NONCOPYABLE(PushError);
public:
// For CallbackPromiseAdapter.
typedef blink::WebPushError WebType;
static PassRefPtrWillBeRawPtr<DOMError> from(WebType* webErrorRaw)
static PassRefPtrWillBeRawPtr<DOMError> from(NewScriptState*, WebType* webErrorRaw)
{
OwnPtr<WebType> webError = adoptPtr(webErrorRaw);
RefPtrWillBeRawPtr<DOMError> error = DOMError::create(errorString(webError->errorType), webError->message);
......
......@@ -13,11 +13,13 @@
namespace WebCore {
class NewScriptState;
class PushRegistration FINAL : public RefCountedWillBeGarbageCollectedFinalized<PushRegistration>, public ScriptWrappable {
public:
// For CallbackPromiseAdapter.
typedef blink::WebPushRegistration WebType;
static PassRefPtrWillBeRawPtr<PushRegistration> from(WebType* registrationRaw)
static PassRefPtrWillBeRawPtr<PushRegistration> from(NewScriptState*, WebType* registrationRaw)
{
OwnPtr<WebType> registration = adoptPtr(registrationRaw);
return adoptRefWillBeNoop(new PushRegistration(registration->endpoint, registration->registrationId));
......
......@@ -45,6 +45,8 @@ class WebServiceWorker;
namespace WebCore {
class NewScriptState;
class ServiceWorker
: public RefCounted<ServiceWorker>
, public blink::WebServiceWorkerProxy {
......@@ -56,7 +58,7 @@ public:
// For CallbackPromiseAdapter
typedef blink::WebServiceWorker WebType;
static PassRefPtr<ServiceWorker> from(WebType* worker)
static PassRefPtr<ServiceWorker> from(NewScriptState*, WebType* worker)
{
return create(adoptPtr(worker));
}
......
......@@ -38,11 +38,13 @@
namespace WebCore {
class NewScriptState;
class ServiceWorkerError {
public:
// For CallbackPromiseAdapter
typedef blink::WebServiceWorkerError WebType;
static PassRefPtrWillBeRawPtr<DOMError> from(WebType* webErrorRaw)
static PassRefPtrWillBeRawPtr<DOMError> from(NewScriptState*, WebType* webErrorRaw)
{
OwnPtr<WebType> webError = adoptPtr(webErrorRaw);
RefPtrWillBeRawPtr<DOMError> error = DOMError::create(errorString(webError->errorType), webError->message);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment