| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 | 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 static const char databaseAgentEnabled[] = "databaseAgentEnabled"; | 56 static const char databaseAgentEnabled[] = "databaseAgentEnabled"; |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 namespace { | 59 namespace { |
| 60 | 60 |
| 61 void reportTransactionFailed(ExecuteSQLCallback* requestCallback, SQLError* erro
r) | 61 void reportTransactionFailed(ExecuteSQLCallback* requestCallback, SQLError* erro
r) |
| 62 { | 62 { |
| 63 OwnPtr<protocol::Database::Error> errorObject = protocol::Database::Error::c
reate() | 63 OwnPtr<protocol::Database::Error> errorObject = protocol::Database::Error::c
reate() |
| 64 .setMessage(error->message()) | 64 .setMessage(error->message()) |
| 65 .setCode(error->code()).build(); | 65 .setCode(error->code()).build(); |
| 66 requestCallback->sendSuccess(Maybe<protocol::Array<String>>(), Maybe<protoco
l::Array<RefPtr<protocol::Value>>>(), errorObject.release()); | 66 requestCallback->sendSuccess(Maybe<protocol::Array<String>>(), Maybe<protoco
l::Array<protocol::Value>>(), errorObject.release()); |
| 67 } | 67 } |
| 68 | 68 |
| 69 class StatementCallback final : public SQLStatementCallback { | 69 class StatementCallback final : public SQLStatementCallback { |
| 70 public: | 70 public: |
| 71 static StatementCallback* create(PassRefPtr<ExecuteSQLCallback> requestCallb
ack) | 71 static StatementCallback* create(PassRefPtr<ExecuteSQLCallback> requestCallb
ack) |
| 72 { | 72 { |
| 73 return new StatementCallback(requestCallback); | 73 return new StatementCallback(requestCallback); |
| 74 } | 74 } |
| 75 | 75 |
| 76 ~StatementCallback() override { } | 76 ~StatementCallback() override { } |
| 77 | 77 |
| 78 DEFINE_INLINE_VIRTUAL_TRACE() | 78 DEFINE_INLINE_VIRTUAL_TRACE() |
| 79 { | 79 { |
| 80 SQLStatementCallback::trace(visitor); | 80 SQLStatementCallback::trace(visitor); |
| 81 } | 81 } |
| 82 | 82 |
| 83 bool handleEvent(SQLTransaction*, SQLResultSet* resultSet) override | 83 bool handleEvent(SQLTransaction*, SQLResultSet* resultSet) override |
| 84 { | 84 { |
| 85 SQLResultSetRowList* rowList = resultSet->rows(); | 85 SQLResultSetRowList* rowList = resultSet->rows(); |
| 86 | 86 |
| 87 OwnPtr<protocol::Array<String>> columnNames = protocol::Array<String>::c
reate(); | 87 OwnPtr<protocol::Array<String>> columnNames = protocol::Array<String>::c
reate(); |
| 88 const Vector<String>& columns = rowList->columnNames(); | 88 const Vector<String>& columns = rowList->columnNames(); |
| 89 for (size_t i = 0; i < columns.size(); ++i) | 89 for (size_t i = 0; i < columns.size(); ++i) |
| 90 columnNames->addItem(columns[i]); | 90 columnNames->addItem(columns[i]); |
| 91 | 91 |
| 92 OwnPtr<protocol::Array<RefPtr<protocol::Value>>> values = protocol::Arra
y<RefPtr<protocol::Value>>::create(); | 92 OwnPtr<protocol::Array<protocol::Value>> values = protocol::Array<protoc
ol::Value>::create(); |
| 93 const Vector<SQLValue>& data = rowList->values(); | 93 const Vector<SQLValue>& data = rowList->values(); |
| 94 for (size_t i = 0; i < data.size(); ++i) { | 94 for (size_t i = 0; i < data.size(); ++i) { |
| 95 const SQLValue& value = rowList->values()[i]; | 95 const SQLValue& value = rowList->values()[i]; |
| 96 switch (value.getType()) { | 96 switch (value.getType()) { |
| 97 case SQLValue::StringValue: values->addItem(protocol::StringValue::c
reate(value.string())); break; | 97 case SQLValue::StringValue: values->addItem(protocol::StringValue::c
reate(value.string())); break; |
| 98 case SQLValue::NumberValue: values->addItem(protocol::FundamentalVal
ue::create(value.number())); break; | 98 case SQLValue::NumberValue: values->addItem(protocol::FundamentalVal
ue::create(value.number())); break; |
| 99 case SQLValue::NullValue: values->addItem(protocol::Value::null());
break; | 99 case SQLValue::NullValue: values->addItem(protocol::Value::null());
break; |
| 100 } | 100 } |
| 101 } | 101 } |
| 102 m_requestCallback->sendSuccess(columnNames.release(), values.release(),
Maybe<protocol::Database::Error>()); | 102 m_requestCallback->sendSuccess(columnNames.release(), values.release(),
Maybe<protocol::Database::Error>()); |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 } | 327 } |
| 328 | 328 |
| 329 DEFINE_TRACE(InspectorDatabaseAgent) | 329 DEFINE_TRACE(InspectorDatabaseAgent) |
| 330 { | 330 { |
| 331 visitor->trace(m_page); | 331 visitor->trace(m_page); |
| 332 visitor->trace(m_resources); | 332 visitor->trace(m_resources); |
| 333 InspectorBaseAgent::trace(visitor); | 333 InspectorBaseAgent::trace(visitor); |
| 334 } | 334 } |
| 335 | 335 |
| 336 } // namespace blink | 336 } // namespace blink |
| OLD | NEW |