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

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

Issue 177323003: Migrate V8SQLResultSetRowListCustom to ExceptionState. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 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 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
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 "config.h" 31 #include "config.h"
32 #include "V8SQLResultSetRowList.h" 32 #include "V8SQLResultSetRowList.h"
33 33
34 #include "bindings/v8/ExceptionMessages.h"
35 #include "bindings/v8/ExceptionState.h"
34 #include "bindings/v8/V8Binding.h" 36 #include "bindings/v8/V8Binding.h"
37 #include "core/dom/ExceptionCode.h"
35 #include "modules/webdatabase/SQLResultSetRowList.h" 38 #include "modules/webdatabase/SQLResultSetRowList.h"
36 39
37 namespace WebCore { 40 namespace WebCore {
38 41
39 void V8SQLResultSetRowList::itemMethodCustom(const v8::FunctionCallbackInfo<v8:: Value>& info) 42 void V8SQLResultSetRowList::itemMethodCustom(const v8::FunctionCallbackInfo<v8:: Value>& info)
40 { 43 {
44 ExceptionState exceptionState(ExceptionState::ExecutionContext, "item", "SQL ResultSetRowList", info.Holder(), info.GetIsolate());
41 if (!info.Length()) { 45 if (!info.Length()) {
42 throwError(v8SyntaxError, "Item index is required.", info.GetIsolate()); 46 exceptionState.throwDOMException(SyntaxError, ExceptionMessages::notEnou ghArguments(1, 0));
47 exceptionState.throwIfNeeded();
43 return; 48 return;
44 } 49 }
45 50
46 if (!info[0]->IsNumber()) { 51 if (!info[0]->IsNumber()) {
47 throwTypeError("Item index must be a number.", info.GetIsolate()); 52 exceptionState.throwTypeError("The index provided is not a number.");
53 exceptionState.throwIfNeeded();
48 return; 54 return;
49 } 55 }
50 56
51 SQLResultSetRowList* rowList = V8SQLResultSetRowList::toNative(info.Holder() ); 57 SQLResultSetRowList* rowList = V8SQLResultSetRowList::toNative(info.Holder() );
52 58
53 unsigned long index = info[0]->IntegerValue(); 59 unsigned long index = info[0]->IntegerValue();
54 if (index >= rowList->length()) { 60 if (index >= rowList->length()) {
55 throwError(v8RangeError, "Item index is out of range.", info.GetIsolate( )); 61 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde xExceedsMaximumBound<unsigned>("index", index, rowList->length()));
62 exceptionState.throwIfNeeded();
56 return; 63 return;
57 } 64 }
58 65
59 v8::Local<v8::Object> item = v8::Object::New(info.GetIsolate()); 66 v8::Local<v8::Object> item = v8::Object::New(info.GetIsolate());
60 unsigned numColumns = rowList->columnNames().size(); 67 unsigned numColumns = rowList->columnNames().size();
61 unsigned valuesIndex = index * numColumns; 68 unsigned valuesIndex = index * numColumns;
62 69
63 for (unsigned i = 0; i < numColumns; ++i) { 70 for (unsigned i = 0; i < numColumns; ++i) {
64 const SQLValue& sqlValue = rowList->values()[valuesIndex + i]; 71 const SQLValue& sqlValue = rowList->values()[valuesIndex + i];
65 v8::Handle<v8::Value> value; 72 v8::Handle<v8::Value> value;
(...skipping 11 matching lines...) Expand all
77 ASSERT_NOT_REACHED(); 84 ASSERT_NOT_REACHED();
78 } 85 }
79 86
80 item->Set(v8String(info.GetIsolate(), rowList->columnNames()[i]), value, static_cast<v8::PropertyAttribute>(v8::DontDelete | v8::ReadOnly)); 87 item->Set(v8String(info.GetIsolate(), rowList->columnNames()[i]), value, static_cast<v8::PropertyAttribute>(v8::DontDelete | v8::ReadOnly));
81 } 88 }
82 89
83 v8SetReturnValue(info, item); 90 v8SetReturnValue(info, item);
84 } 91 }
85 92
86 } // namespace WebCore 93 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698