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

Side by Side Diff: third_party/WebKit/Source/modules/webdatabase/InspectorDatabaseAgent.cpp

Issue 1702673002: DevTools: migrate remote debugging protocol generators to jinja2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
OLDNEW
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 namespace blink { 53 namespace blink {
54 54
55 namespace DatabaseAgentState { 55 namespace DatabaseAgentState {
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 RefPtr<protocol::TypeBuilder::Database::Error> errorObject = protocol::TypeB uilder::Database::Error::create() 63 OwnPtr<protocol::Database::Error> errorObject = protocol::Database::Error::c reate()
64 .setMessage(error->message()) 64 .setMessage(error->message())
65 .setCode(error->code()); 65 .setCode(error->code()).build();
66 requestCallback->sendSuccess(nullptr, nullptr, errorObject.release()); 66 requestCallback->sendSuccess(nullptr, nullptr, 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 RefPtr<protocol::TypeBuilder::Array<String>> columnNames = protocol::Typ eBuilder::Array<String>::create(); 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 RefPtr<protocol::TypeBuilder::Array<JSONValue>> values = protocol::TypeB uilder::Array<JSONValue>::create(); 92 OwnPtr<protocol::Array<RefPtr<JSONValue>>> values = protocol::Array<RefP tr<JSONValue>>::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.type()) { 96 switch (value.type()) {
97 case SQLValue::StringValue: values->addItem(JSONString::create(value .string())); break; 97 case SQLValue::StringValue: values->addItem(JSONString::create(value .string())); break;
98 case SQLValue::NumberValue: values->addItem(JSONBasicValue::create(v alue.number())); break; 98 case SQLValue::NumberValue: values->addItem(JSONBasicValue::create(v alue.number())); break;
99 case SQLValue::NullValue: values->addItem(JSONValue::null()); break; 99 case SQLValue::NullValue: values->addItem(JSONValue::null()); break;
100 } 100 }
101 } 101 }
102 m_requestCallback->sendSuccess(columnNames.release(), values.release(), nullptr); 102 m_requestCallback->sendSuccess(columnNames.release(), values.release(), nullptr);
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 return; 263 return;
264 m_enabled = false; 264 m_enabled = false;
265 m_state->setBoolean(DatabaseAgentState::databaseAgentEnabled, m_enabled); 265 m_state->setBoolean(DatabaseAgentState::databaseAgentEnabled, m_enabled);
266 } 266 }
267 267
268 void InspectorDatabaseAgent::restore() 268 void InspectorDatabaseAgent::restore()
269 { 269 {
270 m_enabled = m_state->booleanProperty(DatabaseAgentState::databaseAgentEnable d, false); 270 m_enabled = m_state->booleanProperty(DatabaseAgentState::databaseAgentEnable d, false);
271 } 271 }
272 272
273 void InspectorDatabaseAgent::getDatabaseTableNames(ErrorString* error, const Str ing& databaseId, RefPtr<protocol::TypeBuilder::Array<String>>& names) 273 void InspectorDatabaseAgent::getDatabaseTableNames(ErrorString* error, const Str ing& databaseId, OwnPtr<protocol::Array<String>>* names)
274 { 274 {
275 if (!m_enabled) { 275 if (!m_enabled) {
276 *error = "Database agent is not enabled"; 276 *error = "Database agent is not enabled";
277 return; 277 return;
278 } 278 }
279 279
280 names = protocol::TypeBuilder::Array<String>::create(); 280 *names = protocol::Array<String>::create();
281 281
282 Database* database = databaseForId(databaseId); 282 Database* database = databaseForId(databaseId);
283 if (database) { 283 if (database) {
284 Vector<String> tableNames = database->tableNames(); 284 Vector<String> tableNames = database->tableNames();
285 unsigned length = tableNames.size(); 285 unsigned length = tableNames.size();
286 for (unsigned i = 0; i < length; ++i) 286 for (unsigned i = 0; i < length; ++i)
287 names->addItem(tableNames[i]); 287 (*names)->addItem(tableNames[i]);
288 } 288 }
289 } 289 }
290 290
291 void InspectorDatabaseAgent::executeSQL(ErrorString*, const String& databaseId, const String& query, PassRefPtr<ExecuteSQLCallback> prpRequestCallback) 291 void InspectorDatabaseAgent::executeSQL(ErrorString*, const String& databaseId, const String& query, PassRefPtr<ExecuteSQLCallback> prpRequestCallback)
292 { 292 {
293 RefPtr<ExecuteSQLCallback> requestCallback = prpRequestCallback; 293 RefPtr<ExecuteSQLCallback> requestCallback = prpRequestCallback;
294 294
295 if (!m_enabled) { 295 if (!m_enabled) {
296 requestCallback->sendFailure("Database agent is not enabled"); 296 requestCallback->sendFailure("Database agent is not enabled");
297 return; 297 return;
(...skipping 29 matching lines...) Expand all
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698