OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007 Apple 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "bindings/core/v8/ToV8.h" | 32 #include "bindings/core/v8/ToV8.h" |
33 #include "bindings/modules/v8/ToV8ForModules.h" | 33 #include "bindings/modules/v8/ToV8ForModules.h" |
34 #include "core/dom/ExceptionCode.h" | 34 #include "core/dom/ExceptionCode.h" |
35 | 35 |
36 namespace blink { | 36 namespace blink { |
37 | 37 |
38 unsigned SQLResultSetRowList::length() const { | 38 unsigned SQLResultSetRowList::length() const { |
39 if (result_.size() == 0) | 39 if (result_.size() == 0) |
40 return 0; | 40 return 0; |
41 | 41 |
42 ASSERT(result_.size() % columns_.size() == 0); | 42 DCHECK_EQ(result_.size() % columns_.size(), 0u); |
43 | 43 |
44 return result_.size() / columns_.size(); | 44 return result_.size() / columns_.size(); |
45 } | 45 } |
46 | 46 |
47 ScriptValue SQLResultSetRowList::item(ScriptState* script_state, | 47 ScriptValue SQLResultSetRowList::item(ScriptState* script_state, |
48 unsigned index, | 48 unsigned index, |
49 ExceptionState& exception_state) { | 49 ExceptionState& exception_state) { |
50 if (index >= length()) { | 50 if (index >= length()) { |
51 exception_state.ThrowDOMException( | 51 exception_state.ThrowDOMException( |
52 kIndexSizeError, ExceptionMessages::IndexExceedsMaximumBound<unsigned>( | 52 kIndexSizeError, ExceptionMessages::IndexExceedsMaximumBound<unsigned>( |
53 "index", index, length())); | 53 "index", index, length())); |
54 return ScriptValue(); | 54 return ScriptValue(); |
55 } | 55 } |
56 | 56 |
57 unsigned num_columns = columns_.size(); | 57 unsigned num_columns = columns_.size(); |
58 unsigned values_index = index * num_columns; | 58 unsigned values_index = index * num_columns; |
59 | 59 |
60 Vector<std::pair<String, SQLValue>> data_array; | 60 Vector<std::pair<String, SQLValue>> data_array; |
61 for (unsigned i = 0; i < num_columns; ++i) | 61 for (unsigned i = 0; i < num_columns; ++i) |
62 data_array.push_back( | 62 data_array.push_back( |
63 std::make_pair(columns_[i], result_[values_index + i])); | 63 std::make_pair(columns_[i], result_[values_index + i])); |
64 | 64 |
65 return ScriptValue::From(script_state, data_array); | 65 return ScriptValue::From(script_state, data_array); |
66 } | 66 } |
67 | 67 |
68 } // namespace blink | 68 } // namespace blink |
OLD | NEW |