Chromium Code Reviews| 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 11 matching lines...) Expand all Loading... | |
| 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 */ | 27 */ |
| 28 | 28 |
| 29 #include "config.h" | 29 #include "config.h" |
| 30 #include "modules/webdatabase/SQLResultSetRowList.h" | 30 #include "modules/webdatabase/SQLResultSetRowList.h" |
| 31 | 31 |
| 32 #include "bindings/core/v8/ExceptionMessages.h" | |
| 33 #include "bindings/core/v8/ToV8.h" | |
| 34 #include "bindings/core/v8/V8Binding.h" | |
|
vivekg
2015/03/04 13:40:44
The V8Binding.h inclusion is not required.
I wan
| |
| 35 #include "bindings/modules/v8/ToV8.h" | |
| 36 #include "core/dom/ExceptionCode.h" | |
| 37 | |
| 32 namespace blink { | 38 namespace blink { |
| 33 | 39 |
| 34 unsigned SQLResultSetRowList::length() const | 40 unsigned SQLResultSetRowList::length() const |
| 35 { | 41 { |
| 36 if (m_result.size() == 0) | 42 if (m_result.size() == 0) |
| 37 return 0; | 43 return 0; |
| 38 | 44 |
| 39 ASSERT(m_result.size() % m_columns.size() == 0); | 45 ASSERT(m_result.size() % m_columns.size() == 0); |
| 40 | 46 |
| 41 return m_result.size() / m_columns.size(); | 47 return m_result.size() / m_columns.size(); |
| 42 } | 48 } |
| 43 | 49 |
| 50 ScriptValue SQLResultSetRowList::item(unsigned index, ExceptionState& exceptionS tate) | |
|
Yuki
2015/03/04 14:11:04
This function should return Vector<pair<String, SQ
Jens Widell
2015/03/04 14:18:26
I disagree. The code generator determines what the
Jens Widell
2015/03/04 14:23:41
That said, we should still perhaps not use toV8()
Yuki
2015/03/04 14:30:45
Agreed. Otherwise, we face to another issue how t
| |
| 51 { | |
| 52 if (index >= length()) { | |
| 53 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde xExceedsMaximumBound<unsigned>("index", index, length())); | |
| 54 return ScriptValue(); | |
| 55 } | |
| 56 unsigned numColumns = m_columns.size(); | |
| 57 unsigned valuesIndex = index * numColumns; | |
| 58 | |
| 59 Vector<std::pair<String, v8::Handle<v8::Value>>> dataArray; | |
| 60 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | |
| 61 | |
| 62 for (unsigned i = 0; i < numColumns; ++i) | |
| 63 dataArray.append(std::make_pair(m_columns[i], toV8(m_result[valuesIndex + i], isolate))); | |
| 64 | |
| 65 ScriptState* scriptState = ScriptState::current(isolate); | |
| 66 ASSERT(scriptState); | |
| 67 return ScriptValue(scriptState, toV8(dataArray, scriptState->context()->Glob al(), isolate)); | |
| 44 } | 68 } |
| 69 | |
| 70 } | |
| OLD | NEW |