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

Side by Side Diff: Source/bindings/v8/custom/V8PromiseCustom.cpp

Issue 293963003: Remove ScriptObject (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 // |promise| must be a Promise instance. 203 // |promise| must be a Promise instance.
204 void setStateForPromise(v8::Handle<v8::Object> promise, V8PromiseCustom::Promise State state, v8::Handle<v8::Value> value, v8::Isolate* isolate) 204 void setStateForPromise(v8::Handle<v8::Object> promise, V8PromiseCustom::Promise State state, v8::Handle<v8::Value> value, v8::Isolate* isolate)
205 { 205 {
206 ASSERT(!value.IsEmpty()); 206 ASSERT(!value.IsEmpty());
207 ASSERT(state == V8PromiseCustom::Pending || state == V8PromiseCustom::Fulfil led || state == V8PromiseCustom::Rejected || state == V8PromiseCustom::Following ); 207 ASSERT(state == V8PromiseCustom::Pending || state == V8PromiseCustom::Fulfil led || state == V8PromiseCustom::Rejected || state == V8PromiseCustom::Following );
208 v8::Local<v8::Object> internal = V8PromiseCustom::getInternal(promise); 208 v8::Local<v8::Object> internal = V8PromiseCustom::getInternal(promise);
209 internal->SetInternalField(V8PromiseCustom::InternalStateIndex, v8::Integer: :New(isolate, state)); 209 internal->SetInternalField(V8PromiseCustom::InternalStateIndex, v8::Integer: :New(isolate, state));
210 internal->SetInternalField(V8PromiseCustom::InternalResultIndex, value); 210 internal->SetInternalField(V8PromiseCustom::InternalResultIndex, value);
211 ExecutionContext* context = currentExecutionContext(isolate); 211 ExecutionContext* context = currentExecutionContext(isolate);
212 if (InspectorInstrumentation::isPromiseTrackerEnabled(context)) 212 if (InspectorInstrumentation::isPromiseTrackerEnabled(context))
213 InspectorInstrumentation::didUpdatePromiseState(context, ScriptObject(Sc riptState::current(isolate), promise), state, ScriptValue(ScriptState::current(i solate), value)); 213 InspectorInstrumentation::didUpdatePromiseState(context, ScriptValue(Scr iptState::current(isolate), promise), state, ScriptValue(ScriptState::current(is olate), value));
214 } 214 }
215 215
216 class TaskPerformScopeForInstrumentation { 216 class TaskPerformScopeForInstrumentation {
217 public: 217 public:
218 TaskPerformScopeForInstrumentation(ExecutionContext* context, ExecutionConte xtTask* task) 218 TaskPerformScopeForInstrumentation(ExecutionContext* context, ExecutionConte xtTask* task)
219 : m_cookie(InspectorInstrumentation::willPerformPromiseTask(context, tas k)) 219 : m_cookie(InspectorInstrumentation::willPerformPromiseTask(context, tas k))
220 { 220 {
221 } 221 }
222 222
223 ~TaskPerformScopeForInstrumentation() 223 ~TaskPerformScopeForInstrumentation()
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 v8::Local<v8::Object> internal = V8PromiseCustom::getInternal(promise); 498 v8::Local<v8::Object> internal = V8PromiseCustom::getInternal(promise);
499 V8PromiseCustom::PromiseState state = V8PromiseCustom::getState(internal); 499 V8PromiseCustom::PromiseState state = V8PromiseCustom::getState(internal);
500 if (state == V8PromiseCustom::Fulfilled || state == V8PromiseCustom::Rejecte d) { 500 if (state == V8PromiseCustom::Fulfilled || state == V8PromiseCustom::Rejecte d) {
501 updateDerived(derivedPromise, onFulfilled, onRejected, promise, isolate) ; 501 updateDerived(derivedPromise, onFulfilled, onRejected, promise, isolate) ;
502 } else { 502 } else {
503 addToDerived(internal, derivedPromise, onFulfilled, onRejected, isolate) ; 503 addToDerived(internal, derivedPromise, onFulfilled, onRejected, isolate) ;
504 } 504 }
505 ExecutionContext* context = currentExecutionContext(isolate); 505 ExecutionContext* context = currentExecutionContext(isolate);
506 if (InspectorInstrumentation::isPromiseTrackerEnabled(context)) { 506 if (InspectorInstrumentation::isPromiseTrackerEnabled(context)) {
507 ScriptState* scriptState = ScriptState::current(isolate); 507 ScriptState* scriptState = ScriptState::current(isolate);
508 InspectorInstrumentation::didUpdatePromiseParent(context, ScriptObject(s criptState, derivedPromise), ScriptObject(scriptState, promise)); 508 InspectorInstrumentation::didUpdatePromiseParent(context, ScriptValue(sc riptState, derivedPromise), ScriptValue(scriptState, promise));
509 } 509 }
510 } 510 }
511 511
512 } // namespace 512 } // namespace
513 513
514 void V8Promise::constructorCustom(const v8::FunctionCallbackInfo<v8::Value>& inf o) 514 void V8Promise::constructorCustom(const v8::FunctionCallbackInfo<v8::Value>& inf o)
515 { 515 {
516 v8SetReturnValue(info, v8::Local<v8::Value>()); 516 v8SetReturnValue(info, v8::Local<v8::Value>());
517 v8::Isolate* isolate = info.GetIsolate(); 517 v8::Isolate* isolate = info.GetIsolate();
518 ExecutionContext* executionContext = callingExecutionContext(isolate); 518 ExecutionContext* executionContext = callingExecutionContext(isolate);
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 v8::Local<v8::Object> internal = internalTemplate->NewInstance(); 673 v8::Local<v8::Object> internal = internalTemplate->NewInstance();
674 if (internal.IsEmpty()) 674 if (internal.IsEmpty())
675 return v8::Local<v8::Object>(); 675 return v8::Local<v8::Object>();
676 v8::Local<v8::Object> promise = V8DOMWrapper::createWrapper(creationContext, &V8Promise::wrapperTypeInfo, 0, isolate); 676 v8::Local<v8::Object> promise = V8DOMWrapper::createWrapper(creationContext, &V8Promise::wrapperTypeInfo, 0, isolate);
677 677
678 clearDerived(internal, isolate); 678 clearDerived(internal, isolate);
679 promise->SetInternalField(v8DOMWrapperObjectIndex, internal); 679 promise->SetInternalField(v8DOMWrapperObjectIndex, internal);
680 680
681 ExecutionContext* context = currentExecutionContext(isolate); 681 ExecutionContext* context = currentExecutionContext(isolate);
682 if (InspectorInstrumentation::isPromiseTrackerEnabled(context)) 682 if (InspectorInstrumentation::isPromiseTrackerEnabled(context))
683 InspectorInstrumentation::didCreatePromise(context, ScriptObject(ScriptS tate::current(isolate), promise)); 683 InspectorInstrumentation::didCreatePromise(context, ScriptValue(ScriptSt ate::current(isolate), promise));
684 684
685 setStateForPromise(promise, Pending, v8::Undefined(isolate), isolate); 685 setStateForPromise(promise, Pending, v8::Undefined(isolate), isolate);
686 return promise; 686 return promise;
687 } 687 }
688 688
689 v8::Local<v8::Object> V8PromiseCustom::getInternal(v8::Handle<v8::Object> promis e) 689 v8::Local<v8::Object> V8PromiseCustom::getInternal(v8::Handle<v8::Object> promis e)
690 { 690 {
691 v8::Local<v8::Value> value = promise->GetInternalField(v8DOMWrapperObjectInd ex); 691 v8::Local<v8::Value> value = promise->GetInternalField(v8DOMWrapperObjectInd ex);
692 return value.As<v8::Object>(); 692 return value.As<v8::Object>();
693 } 693 }
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 853
854 void V8PromiseCustom::callHandler(v8::Handle<v8::Object> promise, v8::Handle<v8: :Function> handler, v8::Handle<v8::Value> argument, PromiseState originatorState , v8::Isolate* isolate) 854 void V8PromiseCustom::callHandler(v8::Handle<v8::Object> promise, v8::Handle<v8: :Function> handler, v8::Handle<v8::Value> argument, PromiseState originatorState , v8::Isolate* isolate)
855 { 855 {
856 ASSERT(originatorState == Fulfilled || originatorState == Rejected); 856 ASSERT(originatorState == Fulfilled || originatorState == Rejected);
857 ExecutionContext* executionContext = currentExecutionContext(isolate); 857 ExecutionContext* executionContext = currentExecutionContext(isolate);
858 ASSERT(executionContext && executionContext->isContextThread()); 858 ASSERT(executionContext && executionContext->isContextThread());
859 executionContext->postTask(adoptPtr(new CallHandlerTask(promise, handler, ar gument, originatorState, isolate, executionContext))); 859 executionContext->postTask(adoptPtr(new CallHandlerTask(promise, handler, ar gument, originatorState, isolate, executionContext)));
860 } 860 }
861 861
862 } // namespace WebCore 862 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698