Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 // This file is for functions that are used only by generated code. | 5 // This file is for functions that are used only by generated code. |
| 6 // CAUTION: | 6 // CAUTION: |
| 7 // All functions defined in this file should be used by generated code only. | 7 // All functions defined in this file should be used by generated code only. |
| 8 // If you want to use them from hand-written code, please find appropriate | 8 // If you want to use them from hand-written code, please find appropriate |
| 9 // location and move them to that location. | 9 // location and move them to that location. |
| 10 | 10 |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 34 // promise and returns the promise instead of throwing the exception. | 34 // promise and returns the promise instead of throwing the exception. |
| 35 // | 35 // |
| 36 // Promise-returning DOM operations are required to always return a promise | 36 // Promise-returning DOM operations are required to always return a promise |
| 37 // and to never throw an exception. | 37 // and to never throw an exception. |
| 38 // See also http://heycam.github.io/webidl/#es-operations | 38 // See also http://heycam.github.io/webidl/#es-operations |
| 39 class CORE_EXPORT ExceptionToRejectPromiseScope { | 39 class CORE_EXPORT ExceptionToRejectPromiseScope { |
| 40 STACK_ALLOCATED(); | 40 STACK_ALLOCATED(); |
| 41 | 41 |
| 42 public: | 42 public: |
| 43 ExceptionToRejectPromiseScope(const v8::FunctionCallbackInfo<v8::Value>& info, | 43 ExceptionToRejectPromiseScope(const v8::FunctionCallbackInfo<v8::Value>& info, |
| 44 ScriptState* scriptState, | |
| 45 ExceptionState& exceptionState) | 44 ExceptionState& exceptionState) |
| 46 : m_info(info), | 45 : m_info(info), |
| 47 m_scriptState(scriptState), | |
| 48 m_exceptionState(exceptionState) {} | 46 m_exceptionState(exceptionState) {} |
| 49 ~ExceptionToRejectPromiseScope() { | 47 ~ExceptionToRejectPromiseScope() { |
| 50 if (!m_exceptionState.hadException()) | 48 if (!m_exceptionState.hadException()) |
| 51 return; | 49 return; |
| 52 | 50 |
| 53 v8SetReturnValue(m_info, m_exceptionState.reject(m_scriptState).v8Value()); | 51 // As exceptions must always be created in the current realm, reject |
| 52 // promises must also be created in the current realm while regular promises | |
| 53 // are created in the relevant realm of the context object. | |
| 54 ScriptState* scriptState = ScriptState::forFunctionObject(m_info); | |
|
haraken
2016/10/18 18:46:56
Just help me understand:
- Is ExceptionToRejectPr
Yuki
2016/10/19 06:06:58
Other ScriptPromise::reject() are called after we
| |
| 55 v8SetReturnValue(m_info, m_exceptionState.reject(scriptState).v8Value()); | |
| 54 } | 56 } |
| 55 | 57 |
| 56 private: | 58 private: |
| 57 const v8::FunctionCallbackInfo<v8::Value>& m_info; | 59 const v8::FunctionCallbackInfo<v8::Value>& m_info; |
| 58 ScriptState* m_scriptState; | |
| 59 ExceptionState& m_exceptionState; | 60 ExceptionState& m_exceptionState; |
| 60 }; | 61 }; |
| 61 | 62 |
| 62 } // namespace blink | 63 } // namespace blink |
| 63 | 64 |
| 64 #endif // GeneratedCodeHelper_h | 65 #endif // GeneratedCodeHelper_h |
| OLD | NEW |