| OLD | NEW |
| 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 26 matching lines...) Expand all Loading... |
| 37 #include "bindings/v8/V8Binding.h" | 37 #include "bindings/v8/V8Binding.h" |
| 38 #include "core/dom/ExceptionCode.h" | 38 #include "core/dom/ExceptionCode.h" |
| 39 #include "modules/webdatabase/sqlite/SQLValue.h" | 39 #include "modules/webdatabase/sqlite/SQLValue.h" |
| 40 #include "modules/webdatabase/Database.h" | 40 #include "modules/webdatabase/Database.h" |
| 41 #include "wtf/Vector.h" | 41 #include "wtf/Vector.h" |
| 42 | 42 |
| 43 using namespace WTF; | 43 using namespace WTF; |
| 44 | 44 |
| 45 namespace WebCore { | 45 namespace WebCore { |
| 46 | 46 |
| 47 void V8SQLTransaction::executeSqlMethodCustom(const v8::FunctionCallbackInfo<v8:
:Value>& args) | 47 void V8SQLTransaction::executeSqlMethodCustom(const v8::FunctionCallbackInfo<v8:
:Value>& info) |
| 48 { | 48 { |
| 49 if (!args.Length()) { | 49 if (!info.Length()) { |
| 50 setDOMException(SyntaxError, args.GetIsolate()); | 50 setDOMException(SyntaxError, info.GetIsolate()); |
| 51 return; | 51 return; |
| 52 } | 52 } |
| 53 | 53 |
| 54 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, statement, args[0])
; | 54 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, statement, info[0])
; |
| 55 | 55 |
| 56 Vector<SQLValue> sqlValues; | 56 Vector<SQLValue> sqlValues; |
| 57 | 57 |
| 58 if (args.Length() > 1 && !isUndefinedOrNull(args[1])) { | 58 if (info.Length() > 1 && !isUndefinedOrNull(info[1])) { |
| 59 if (!args[1]->IsObject()) { | 59 if (!info[1]->IsObject()) { |
| 60 setDOMException(TypeMismatchError, args.GetIsolate()); | 60 setDOMException(TypeMismatchError, info.GetIsolate()); |
| 61 return; | 61 return; |
| 62 } | 62 } |
| 63 | 63 |
| 64 uint32_t sqlArgsLength = 0; | 64 uint32_t sqlArgsLength = 0; |
| 65 v8::Local<v8::Object> sqlArgsObject = args[1]->ToObject(); | 65 v8::Local<v8::Object> sqlArgsObject = info[1]->ToObject(); |
| 66 V8TRYCATCH_VOID(v8::Local<v8::Value>, length, sqlArgsObject->Get(v8::Str
ing::NewSymbol("length"))); | 66 V8TRYCATCH_VOID(v8::Local<v8::Value>, length, sqlArgsObject->Get(v8::Str
ing::NewSymbol("length"))); |
| 67 | 67 |
| 68 if (isUndefinedOrNull(length)) | 68 if (isUndefinedOrNull(length)) |
| 69 sqlArgsLength = sqlArgsObject->GetPropertyNames()->Length(); | 69 sqlArgsLength = sqlArgsObject->GetPropertyNames()->Length(); |
| 70 else | 70 else |
| 71 sqlArgsLength = length->Uint32Value(); | 71 sqlArgsLength = length->Uint32Value(); |
| 72 | 72 |
| 73 for (unsigned int i = 0; i < sqlArgsLength; ++i) { | 73 for (unsigned int i = 0; i < sqlArgsLength; ++i) { |
| 74 v8::Handle<v8::Integer> key = v8::Integer::New(i, args.GetIsolate())
; | 74 v8::Handle<v8::Integer> key = v8::Integer::New(i, info.GetIsolate())
; |
| 75 V8TRYCATCH_VOID(v8::Local<v8::Value>, value, sqlArgsObject->Get(key)
); | 75 V8TRYCATCH_VOID(v8::Local<v8::Value>, value, sqlArgsObject->Get(key)
); |
| 76 | 76 |
| 77 if (value.IsEmpty() || value->IsNull()) | 77 if (value.IsEmpty() || value->IsNull()) |
| 78 sqlValues.append(SQLValue()); | 78 sqlValues.append(SQLValue()); |
| 79 else if (value->IsNumber()) { | 79 else if (value->IsNumber()) { |
| 80 V8TRYCATCH_VOID(double, sqlValue, value->NumberValue()); | 80 V8TRYCATCH_VOID(double, sqlValue, value->NumberValue()); |
| 81 sqlValues.append(SQLValue(sqlValue)); | 81 sqlValues.append(SQLValue(sqlValue)); |
| 82 } else { | 82 } else { |
| 83 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, sqlValu
e, value); | 83 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, sqlValu
e, value); |
| 84 sqlValues.append(SQLValue(sqlValue)); | 84 sqlValues.append(SQLValue(sqlValue)); |
| 85 } | 85 } |
| 86 } | 86 } |
| 87 } | 87 } |
| 88 | 88 |
| 89 SQLTransaction* transaction = V8SQLTransaction::toNative(args.Holder()); | 89 SQLTransaction* transaction = V8SQLTransaction::toNative(info.Holder()); |
| 90 | 90 |
| 91 ExecutionContext* executionContext = getExecutionContext(); | 91 ExecutionContext* executionContext = getExecutionContext(); |
| 92 | 92 |
| 93 RefPtr<SQLStatementCallback> callback; | 93 RefPtr<SQLStatementCallback> callback; |
| 94 if (args.Length() > 2 && !isUndefinedOrNull(args[2])) { | 94 if (info.Length() > 2 && !isUndefinedOrNull(info[2])) { |
| 95 if (!args[2]->IsObject()) { | 95 if (!info[2]->IsObject()) { |
| 96 setDOMException(TypeMismatchError, args.GetIsolate()); | 96 setDOMException(TypeMismatchError, info.GetIsolate()); |
| 97 return; | 97 return; |
| 98 } | 98 } |
| 99 callback = V8SQLStatementCallback::create(args[2], executionContext); | 99 callback = V8SQLStatementCallback::create(info[2], executionContext); |
| 100 } | 100 } |
| 101 | 101 |
| 102 RefPtr<SQLStatementErrorCallback> errorCallback; | 102 RefPtr<SQLStatementErrorCallback> errorCallback; |
| 103 if (args.Length() > 3 && !isUndefinedOrNull(args[3])) { | 103 if (info.Length() > 3 && !isUndefinedOrNull(info[3])) { |
| 104 if (!args[3]->IsObject()) { | 104 if (!info[3]->IsObject()) { |
| 105 setDOMException(TypeMismatchError, args.GetIsolate()); | 105 setDOMException(TypeMismatchError, info.GetIsolate()); |
| 106 return; | 106 return; |
| 107 } | 107 } |
| 108 errorCallback = V8SQLStatementErrorCallback::create(args[3], executionCo
ntext); | 108 errorCallback = V8SQLStatementErrorCallback::create(info[3], executionCo
ntext); |
| 109 } | 109 } |
| 110 | 110 |
| 111 ExceptionState es(args.GetIsolate()); | 111 ExceptionState es(info.GetIsolate()); |
| 112 transaction->executeSQL(statement, sqlValues, callback, errorCallback, es); | 112 transaction->executeSQL(statement, sqlValues, callback, errorCallback, es); |
| 113 es.throwIfNeeded(); | 113 es.throwIfNeeded(); |
| 114 } | 114 } |
| 115 | 115 |
| 116 } // namespace WebCore | 116 } // namespace WebCore |
| OLD | NEW |