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

Side by Side Diff: Source/bindings/v8/ScriptPromiseResolverWithContext.h

Issue 236713003: [ServiceWorker, PushMessaging] Use ScriptPromiseResolverWithContext. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef ScriptPromiseResolverWithContext_h 5 #ifndef ScriptPromiseResolverWithContext_h
6 #define ScriptPromiseResolverWithContext_h 6 #define ScriptPromiseResolverWithContext_h
7 7
8 #include "bindings/v8/NewScriptState.h" 8 #include "bindings/v8/NewScriptState.h"
9 #include "bindings/v8/ScopedPersistent.h" 9 #include "bindings/v8/ScopedPersistent.h"
10 #include "bindings/v8/ScriptPromise.h" 10 #include "bindings/v8/ScriptPromise.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 { 55 {
56 if (m_state != Pending || !executionContext() || executionContext()->act iveDOMObjectsAreStopped()) 56 if (m_state != Pending || !executionContext() || executionContext()->act iveDOMObjectsAreStopped())
57 return; 57 return;
58 m_state = Rejecting; 58 m_state = Rejecting;
59 NewScriptState::Scope scope(m_scriptState.get()); 59 NewScriptState::Scope scope(m_scriptState.get());
60 m_value.set(m_scriptState->isolate(), toV8(value)); 60 m_value.set(m_scriptState->isolate(), toV8(value));
61 if (!executionContext()->activeDOMObjectsAreSuspended()) 61 if (!executionContext()->activeDOMObjectsAreSuspended())
62 resolveOrRejectImmediately(&m_timer); 62 resolveOrRejectImmediately(&m_timer);
63 } 63 }
64 64
65 NewScriptState* scriptState() { return m_scriptState.get(); }
66
65 // Note that an empty ScriptPromise will be returned after resolve or 67 // Note that an empty ScriptPromise will be returned after resolve or
66 // reject is called. 68 // reject is called.
67 ScriptPromise promise() 69 ScriptPromise promise()
68 { 70 {
69 return m_resolver ? m_resolver->promise() : ScriptPromise(); 71 return m_resolver ? m_resolver->promise() : ScriptPromise();
70 } 72 }
71 73
72 // ActiveDOMObject implementation. 74 // ActiveDOMObject implementation.
73 virtual void suspend() OVERRIDE; 75 virtual void suspend() OVERRIDE;
74 virtual void resume() OVERRIDE; 76 virtual void resume() OVERRIDE;
(...skipping 26 matching lines...) Expand all
101 } 103 }
102 v8::Handle<v8::Value> toV8(ScriptValue value) 104 v8::Handle<v8::Value> toV8(ScriptValue value)
103 { 105 {
104 return value.v8Value(); 106 return value.v8Value();
105 } 107 }
106 108
107 void resolveOrRejectImmediately(Timer<ScriptPromiseResolverWithContext>*); 109 void resolveOrRejectImmediately(Timer<ScriptPromiseResolverWithContext>*);
108 void clear(); 110 void clear();
109 111
110 ResolutionState m_state; 112 ResolutionState m_state;
111 RefPtr<NewScriptState> m_scriptState; 113 const RefPtr<NewScriptState> m_scriptState;
112 Timer<ScriptPromiseResolverWithContext> m_timer; 114 Timer<ScriptPromiseResolverWithContext> m_timer;
113 RefPtr<ScriptPromiseResolver> m_resolver; 115 RefPtr<ScriptPromiseResolver> m_resolver;
114 ScopedPersistent<v8::Value> m_value; 116 ScopedPersistent<v8::Value> m_value;
115 }; 117 };
116 118
117 } // namespace WebCore 119 } // namespace WebCore
118 120
119 #endif // #ifndef ScriptPromiseResolverWithContext_h 121 #endif // #ifndef ScriptPromiseResolverWithContext_h
OLDNEW
« no previous file with comments | « Source/bindings/v8/CallbackPromiseAdapter.h ('k') | Source/bindings/v8/ScriptPromiseResolverWithContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698