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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/ExceptionState.cpp

Issue 2834463002: Move CreateDOMException out of V8ThrowException (Closed)
Patch Set: Add comments Created 3 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 /* 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
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 #include "bindings/core/v8/ExceptionState.h" 31 #include "bindings/core/v8/ExceptionState.h"
32 32
33 #include "bindings/core/v8/ExceptionMessages.h" 33 #include "bindings/core/v8/ExceptionMessages.h"
34 #include "bindings/core/v8/ScriptPromiseResolver.h" 34 #include "bindings/core/v8/ScriptPromiseResolver.h"
35 #include "bindings/core/v8/V8ThrowException.h" 35 #include "bindings/core/v8/V8ThrowDOMException.h"
36 #include "core/dom/ExceptionCode.h"
37 36
38 namespace blink { 37 namespace blink {
39 38
40 void ExceptionState::ThrowDOMException(ExceptionCode ec, const char* message) { 39 void ExceptionState::ThrowDOMException(ExceptionCode ec, const char* message) {
41 ThrowDOMException(ec, String(message)); 40 ThrowDOMException(ec, String(message));
42 } 41 }
43 42
44 void ExceptionState::ThrowRangeError(const char* message) { 43 void ExceptionState::ThrowRangeError(const char* message) {
45 ThrowRangeError(String(message)); 44 ThrowRangeError(String(message));
46 } 45 }
(...skipping 10 matching lines...) Expand all
57 void ExceptionState::ThrowDOMException(ExceptionCode ec, 56 void ExceptionState::ThrowDOMException(ExceptionCode ec,
58 const String& message) { 57 const String& message) {
59 // SecurityError is thrown via ::throwSecurityError, and _careful_ 58 // SecurityError is thrown via ::throwSecurityError, and _careful_
60 // consideration must be given to the data exposed to JavaScript via the 59 // consideration must be given to the data exposed to JavaScript via the
61 // 'sanitizedMessage'. 60 // 'sanitizedMessage'.
62 DCHECK(ec != kSecurityError); 61 DCHECK(ec != kSecurityError);
63 62
64 const String& processed_message = AddExceptionContext(message); 63 const String& processed_message = AddExceptionContext(message);
65 SetException( 64 SetException(
66 ec, processed_message, 65 ec, processed_message,
67 V8ThrowException::CreateDOMException(isolate_, ec, processed_message)); 66 V8ThrowDOMException::CreateDOMException(isolate_, ec, processed_message));
68 } 67 }
69 68
70 void ExceptionState::ThrowRangeError(const String& message) { 69 void ExceptionState::ThrowRangeError(const String& message) {
71 SetException(kV8RangeError, message, 70 SetException(kV8RangeError, message,
72 V8ThrowException::CreateRangeError( 71 V8ThrowException::CreateRangeError(
73 isolate_, AddExceptionContext(message))); 72 isolate_, AddExceptionContext(message)));
74 } 73 }
75 74
76 void ExceptionState::ThrowSecurityError(const String& sanitized_message, 75 void ExceptionState::ThrowSecurityError(const String& sanitized_message,
77 const String& unsanitized_message) { 76 const String& unsanitized_message) {
78 const String& final_sanitized = AddExceptionContext(sanitized_message); 77 const String& final_sanitized = AddExceptionContext(sanitized_message);
79 const String& final_unsanitized = AddExceptionContext(unsanitized_message); 78 const String& final_unsanitized = AddExceptionContext(unsanitized_message);
80 SetException( 79 SetException(
81 kSecurityError, final_sanitized, 80 kSecurityError, final_sanitized,
82 V8ThrowException::CreateDOMException(isolate_, kSecurityError, 81 V8ThrowDOMException::CreateDOMException(
83 final_sanitized, final_unsanitized)); 82 isolate_, kSecurityError, final_sanitized, final_unsanitized));
84 } 83 }
85 84
86 void ExceptionState::ThrowTypeError(const String& message) { 85 void ExceptionState::ThrowTypeError(const String& message) {
87 SetException(kV8TypeError, message, 86 SetException(kV8TypeError, message,
88 V8ThrowException::CreateTypeError(isolate_, 87 V8ThrowException::CreateTypeError(isolate_,
89 AddExceptionContext(message))); 88 AddExceptionContext(message)));
90 } 89 }
91 90
92 void ExceptionState::RethrowV8Exception(v8::Local<v8::Value> value) { 91 void ExceptionState::RethrowV8Exception(v8::Local<v8::Value> value) {
93 SetException(kRethrownException, String(), value); 92 SetException(kRethrownException, String(), value);
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 219
221 void DummyExceptionStateForTesting::ThrowTypeError(const String& message) { 220 void DummyExceptionStateForTesting::ThrowTypeError(const String& message) {
222 SetException(kV8TypeError, message, v8::Local<v8::Value>()); 221 SetException(kV8TypeError, message, v8::Local<v8::Value>());
223 } 222 }
224 223
225 void DummyExceptionStateForTesting::RethrowV8Exception(v8::Local<v8::Value>) { 224 void DummyExceptionStateForTesting::RethrowV8Exception(v8::Local<v8::Value>) {
226 SetException(kRethrownException, String(), v8::Local<v8::Value>()); 225 SetException(kRethrownException, String(), v8::Local<v8::Value>());
227 } 226 }
228 227
229 } // namespace blink 228 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698