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

Side by Side Diff: Source/bindings/core/v8/ScriptPromisePropertyBase.cpp

Issue 921813002: Fix template angle bracket syntax in bindings (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 10 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 #include "config.h" 5 #include "config.h"
6 #include "bindings/core/v8/ScriptPromisePropertyBase.h" 6 #include "bindings/core/v8/ScriptPromisePropertyBase.h"
7 7
8 #include "bindings/core/v8/ScopedPersistent.h" 8 #include "bindings/core/v8/ScopedPersistent.h"
9 #include "bindings/core/v8/ScriptState.h" 9 #include "bindings/core/v8/ScriptState.h"
10 #include "bindings/core/v8/V8Binding.h" 10 #include "bindings/core/v8/V8Binding.h"
11 #include "bindings/core/v8/V8HiddenValue.h" 11 #include "bindings/core/v8/V8HiddenValue.h"
12 #include "core/dom/ExecutionContext.h" 12 #include "core/dom/ExecutionContext.h"
13 13
14 namespace blink { 14 namespace blink {
15 15
16 ScriptPromisePropertyBase::ScriptPromisePropertyBase(ExecutionContext* execution Context, Name name) 16 ScriptPromisePropertyBase::ScriptPromisePropertyBase(ExecutionContext* execution Context, Name name)
17 : ContextLifecycleObserver(executionContext) 17 : ContextLifecycleObserver(executionContext)
18 , m_isolate(toIsolate(executionContext)) 18 , m_isolate(toIsolate(executionContext))
19 , m_name(name) 19 , m_name(name)
20 , m_state(Pending) 20 , m_state(Pending)
21 { 21 {
22 } 22 }
23 23
24 ScriptPromisePropertyBase::~ScriptPromisePropertyBase() 24 ScriptPromisePropertyBase::~ScriptPromisePropertyBase()
25 { 25 {
26 clearWrappers(); 26 clearWrappers();
27 } 27 }
28 28
29 static void clearHandle(const v8::WeakCallbackData<v8::Object, ScopedPersistent< v8::Object> >& data) 29 static void clearHandle(const v8::WeakCallbackData<v8::Object, ScopedPersistent< v8::Object>>& data)
30 { 30 {
31 data.GetParameter()->clear(); 31 data.GetParameter()->clear();
32 } 32 }
33 33
34 ScriptPromise ScriptPromisePropertyBase::promise(DOMWrapperWorld& world) 34 ScriptPromise ScriptPromisePropertyBase::promise(DOMWrapperWorld& world)
35 { 35 {
36 if (!executionContext()) 36 if (!executionContext())
37 return ScriptPromise(); 37 return ScriptPromise();
38 38
39 v8::HandleScope handleScope(m_isolate); 39 v8::HandleScope handleScope(m_isolate);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 { 73 {
74 ASSERT(executionContext()); 74 ASSERT(executionContext());
75 ASSERT(m_state == Pending); 75 ASSERT(m_state == Pending);
76 ASSERT(targetState == Resolved || targetState == Rejected); 76 ASSERT(targetState == Resolved || targetState == Rejected);
77 77
78 m_state = targetState; 78 m_state = targetState;
79 79
80 v8::HandleScope handleScope(m_isolate); 80 v8::HandleScope handleScope(m_isolate);
81 size_t i = 0; 81 size_t i = 0;
82 while (i < m_wrappers.size()) { 82 while (i < m_wrappers.size()) {
83 const OwnPtr<ScopedPersistent<v8::Object> >& persistent = m_wrappers[i]; 83 const OwnPtr<ScopedPersistent<v8::Object>>& persistent = m_wrappers[i];
84 if (persistent->isEmpty()) { 84 if (persistent->isEmpty()) {
85 // wrapper has died. 85 // wrapper has died.
86 // Since v8 GC can run during the iteration and clear the reference, 86 // Since v8 GC can run during the iteration and clear the reference,
87 // we can't move this check out of the loop. 87 // we can't move this check out of the loop.
88 m_wrappers.remove(i); 88 m_wrappers.remove(i);
89 continue; 89 continue;
90 } 90 }
91 v8::Local<v8::Object> wrapper = persistent->newLocal(m_isolate); 91 v8::Local<v8::Object> wrapper = persistent->newLocal(m_isolate);
92 ScriptState::Scope scope(ScriptState::from(wrapper->CreationContext())); 92 ScriptState::Scope scope(ScriptState::from(wrapper->CreationContext()));
93 93
(...skipping 24 matching lines...) Expand all
118 resolver->Reject(rejectedValue(m_isolate, resolver->CreationContext()->G lobal())); 118 resolver->Reject(rejectedValue(m_isolate, resolver->CreationContext()->G lobal()));
119 break; 119 break;
120 } 120 }
121 } 121 }
122 122
123 v8::Local<v8::Object> ScriptPromisePropertyBase::ensureHolderWrapper(ScriptState * scriptState) 123 v8::Local<v8::Object> ScriptPromisePropertyBase::ensureHolderWrapper(ScriptState * scriptState)
124 { 124 {
125 v8::Local<v8::Context> context = scriptState->context(); 125 v8::Local<v8::Context> context = scriptState->context();
126 size_t i = 0; 126 size_t i = 0;
127 while (i < m_wrappers.size()) { 127 while (i < m_wrappers.size()) {
128 const OwnPtr<ScopedPersistent<v8::Object> >& persistent = m_wrappers[i]; 128 const OwnPtr<ScopedPersistent<v8::Object>>& persistent = m_wrappers[i];
129 if (persistent->isEmpty()) { 129 if (persistent->isEmpty()) {
130 // wrapper has died. 130 // wrapper has died.
131 // Since v8 GC can run during the iteration and clear the reference, 131 // Since v8 GC can run during the iteration and clear the reference,
132 // we can't move this check out of the loop. 132 // we can't move this check out of the loop.
133 m_wrappers.remove(i); 133 m_wrappers.remove(i);
134 continue; 134 continue;
135 } 135 }
136 136
137 v8::Local<v8::Object> wrapper = persistent->newLocal(m_isolate); 137 v8::Local<v8::Object> wrapper = persistent->newLocal(m_isolate);
138 if (wrapper->CreationContext() == context) 138 if (wrapper->CreationContext() == context)
139 return wrapper; 139 return wrapper;
140 ++i; 140 ++i;
141 } 141 }
142 v8::Local<v8::Object> wrapper = holder(context->Global(), m_isolate); 142 v8::Local<v8::Object> wrapper = holder(context->Global(), m_isolate);
143 OwnPtr<ScopedPersistent<v8::Object> > weakPersistent = adoptPtr(new ScopedPe rsistent<v8::Object>); 143 OwnPtr<ScopedPersistent<v8::Object>> weakPersistent = adoptPtr(new ScopedPer sistent<v8::Object>);
144 weakPersistent->set(m_isolate, wrapper); 144 weakPersistent->set(m_isolate, wrapper);
145 weakPersistent->setWeak(weakPersistent.get(), &clearHandle); 145 weakPersistent->setWeak(weakPersistent.get(), &clearHandle);
146 m_wrappers.append(weakPersistent.release()); 146 m_wrappers.append(weakPersistent.release());
147 return wrapper; 147 return wrapper;
148 } 148 }
149 149
150 void ScriptPromisePropertyBase::clearWrappers() 150 void ScriptPromisePropertyBase::clearWrappers()
151 { 151 {
152 v8::HandleScope handleScope(m_isolate); 152 v8::HandleScope handleScope(m_isolate);
153 for (WeakPersistentSet::iterator i = m_wrappers.begin(); i != m_wrappers.end (); ++i) { 153 for (WeakPersistentSet::iterator i = m_wrappers.begin(); i != m_wrappers.end (); ++i) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 ASSERT_NOT_REACHED(); 189 ASSERT_NOT_REACHED();
190 return v8::Handle<v8::String>(); 190 return v8::Handle<v8::String>();
191 } 191 }
192 192
193 void ScriptPromisePropertyBase::trace(Visitor* visitor) 193 void ScriptPromisePropertyBase::trace(Visitor* visitor)
194 { 194 {
195 ContextLifecycleObserver::trace(visitor); 195 ContextLifecycleObserver::trace(visitor);
196 } 196 }
197 197
198 } // namespace blink 198 } // namespace blink
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/ScriptPromisePropertyBase.h ('k') | Source/bindings/core/v8/ScriptPromisePropertyTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698