Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 14 matching lines...) Expand all Loading... | |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef ExceptionState_h | 31 #ifndef ExceptionState_h |
| 32 #define ExceptionState_h | 32 #define ExceptionState_h |
| 33 | 33 |
| 34 #include "bindings/v8/ScopedPersistent.h" | 34 #include "bindings/v8/ScopedPersistent.h" |
| 35 #include "bindings/v8/ScriptPromise.h" | |
| 35 #include "bindings/v8/V8ThrowException.h" | 36 #include "bindings/v8/V8ThrowException.h" |
| 36 #include "wtf/Noncopyable.h" | 37 #include "wtf/Noncopyable.h" |
| 37 #include "wtf/text/WTFString.h" | 38 #include "wtf/text/WTFString.h" |
| 38 #include <v8.h> | 39 #include <v8.h> |
| 39 | 40 |
| 40 namespace WebCore { | 41 namespace WebCore { |
| 41 | 42 |
| 42 typedef int ExceptionCode; | 43 typedef int ExceptionCode; |
| 43 | 44 |
| 44 class ExceptionState { | 45 class ExceptionState { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 85 const String& message() const { return m_message; } | 86 const String& message() const { return m_message; } |
| 86 | 87 |
| 87 bool throwIfNeeded() | 88 bool throwIfNeeded() |
| 88 { | 89 { |
| 89 if (!hadException()) | 90 if (!hadException()) |
| 90 return false; | 91 return false; |
| 91 throwException(); | 92 throwException(); |
| 92 return true; | 93 return true; |
| 93 } | 94 } |
| 94 | 95 |
| 96 ScriptPromise reject() | |
|
rmacnak
2014/04/16 18:40:42
DBC: Should this be asserted to be unreachable for
| |
| 97 { | |
| 98 if (hadException()) | |
| 99 return ScriptPromise::reject(m_exception.newLocal(m_isolate), m_isol ate); | |
| 100 return ScriptPromise::reject(V8ThrowException::createError(v8GeneralErro r, "Unknown Error", m_isolate), m_isolate); | |
| 101 } | |
| 102 | |
| 95 Context context() const { return m_context; } | 103 Context context() const { return m_context; } |
| 96 const char* propertyName() const { return m_propertyName; } | 104 const char* propertyName() const { return m_propertyName; } |
| 97 const char* interfaceName() const { return m_interfaceName; } | 105 const char* interfaceName() const { return m_interfaceName; } |
| 98 | 106 |
| 99 void rethrowV8Exception(v8::Handle<v8::Value> value) | 107 void rethrowV8Exception(v8::Handle<v8::Value> value) |
| 100 { | 108 { |
| 101 setException(value); | 109 setException(value); |
| 102 } | 110 } |
| 103 | 111 |
| 104 protected: | 112 protected: |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 133 public: | 141 public: |
| 134 TrackExceptionState(): ExceptionState(ExceptionState::UnknownContext, 0, 0, v8::Handle<v8::Object>(), v8::Isolate::GetCurrent()) { } | 142 TrackExceptionState(): ExceptionState(ExceptionState::UnknownContext, 0, 0, v8::Handle<v8::Object>(), v8::Isolate::GetCurrent()) { } |
| 135 virtual void throwDOMException(const ExceptionCode&, const String& message) OVERRIDE; | 143 virtual void throwDOMException(const ExceptionCode&, const String& message) OVERRIDE; |
| 136 virtual void throwTypeError(const String& message = String()) OVERRIDE; | 144 virtual void throwTypeError(const String& message = String()) OVERRIDE; |
| 137 virtual void throwSecurityError(const String& sanitizedMessage, const String & unsanitizedMessage = String()) OVERRIDE; | 145 virtual void throwSecurityError(const String& sanitizedMessage, const String & unsanitizedMessage = String()) OVERRIDE; |
| 138 }; | 146 }; |
| 139 | 147 |
| 140 } // namespace WebCore | 148 } // namespace WebCore |
| 141 | 149 |
| 142 #endif // ExceptionState_h | 150 #endif // ExceptionState_h |
| OLD | NEW |