WebSQL: Remove Inspector Database Agent
Cleaning up dead code that is no longer used. WebSQL was removed
in M119 in all platforms except WebView, and DevTools code for
WebSQL was removed in:
https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/5335172
Change-Id: Ifb0ff5a98fccdf662e53eaf29a519df81e44d91b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6139214
Commit-Queue: Ayu Ishii <ayui@chromium.org>
Reviewed-by: Nate Chapin <japhet@chromium.org>
Reviewed-by: Andrey Kosyakov <caseq@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1403243}
diff --git a/third_party/blink/public/devtools_protocol/browser_protocol.pdl b/third_party/blink/public/devtools_protocol/browser_protocol.pdl
index f0b3dd5..2c6782d 100644
--- a/third_party/blink/public/devtools_protocol/browser_protocol.pdl
+++ b/third_party/blink/public/devtools_protocol/browser_protocol.pdl
@@ -4217,56 +4217,6 @@
parameters
StorageId storageId
-experimental domain Database
-
- # Unique identifier of Database object.
- type DatabaseId extends string
-
- # Database object.
- type Database extends object
- properties
- # Database ID.
- DatabaseId id
- # Database domain.
- string domain
- # Database name.
- string name
- # Database version.
- string version
-
- # Database error.
- type Error extends object
- properties
- # Error message.
- string message
- # Error code.
- integer code
-
- # Disables database tracking, prevents database events from being sent to the client.
- command disable
-
- # Enables database tracking, database events will now be delivered to the client.
- command enable
-
- command executeSQL
- parameters
- DatabaseId databaseId
- string query
- returns
- optional array of string columnNames
- optional array of any values
- optional Error sqlError
-
- command getDatabaseTableNames
- parameters
- DatabaseId databaseId
- returns
- array of string tableNames
-
- event addDatabase
- parameters
- Database database
-
experimental domain DeviceOrientation
# Clears the overridden Device Orientation.
diff --git a/third_party/blink/renderer/core/core_initializer.h b/third_party/blink/renderer/core/core_initializer.h
index cb69834..d51f8ca 100644
--- a/third_party/blink/renderer/core/core_initializer.h
+++ b/third_party/blink/renderer/core/core_initializer.h
@@ -107,7 +107,6 @@
// TODO(nverne): remove this and restore to WebDevToolsAgentImpl once that
// class is a controller/ crbug:731490
virtual void InitInspectorAgentSession(DevToolsSession*,
- bool,
InspectorDOMAgent*,
InspectedFrames*,
Page*) const = 0;
diff --git a/third_party/blink/renderer/core/exported/web_dev_tools_agent_impl.cc b/third_party/blink/renderer/core/exported/web_dev_tools_agent_impl.cc
index c7b53ce..404be4b 100644
--- a/third_party/blink/renderer/core/exported/web_dev_tools_agent_impl.cc
+++ b/third_party/blink/renderer/core/exported/web_dev_tools_agent_impl.cc
@@ -96,15 +96,6 @@
namespace blink {
-namespace {
-
-bool IsMainFrame(WebLocalFrameImpl* frame) {
- // TODO(dgozman): sometimes view->mainFrameImpl() does return null, even
- // though |frame| is meant to be main frame. See http://crbug.com/526162.
- return frame->ViewImpl() && !frame->Parent();
-}
-
-} // namespace
class ClientMessageLoopAdapter : public MainThreadDebugger::ClientMessageLoop {
public:
@@ -398,7 +389,7 @@
// Call session init callbacks registered from higher layers.
CoreInitializer::GetInstance().InitInspectorAgentSession(
- session, include_view_agents_, dom_agent, inspected_frames,
+ session, dom_agent, inspected_frames,
web_local_frame_impl_->ViewImpl()->GetPage());
if (node_to_inspect_) {
@@ -414,12 +405,11 @@
// static
WebDevToolsAgentImpl* WebDevToolsAgentImpl::CreateForFrame(
WebLocalFrameImpl* frame) {
- return MakeGarbageCollected<WebDevToolsAgentImpl>(frame, IsMainFrame(frame));
+ return MakeGarbageCollected<WebDevToolsAgentImpl>(frame);
}
WebDevToolsAgentImpl::WebDevToolsAgentImpl(
- WebLocalFrameImpl* web_local_frame_impl,
- bool include_view_agents)
+ WebLocalFrameImpl* web_local_frame_impl)
: web_local_frame_impl_(web_local_frame_impl),
probe_sink_(web_local_frame_impl_->GetFrame()->GetProbeSink()),
resource_content_loader_(
@@ -428,8 +418,7 @@
inspected_frames_(MakeGarbageCollected<InspectedFrames>(
web_local_frame_impl_->GetFrame())),
resource_container_(
- MakeGarbageCollected<InspectorResourceContainer>(inspected_frames_)),
- include_view_agents_(include_view_agents) {
+ MakeGarbageCollected<InspectorResourceContainer>(inspected_frames_)) {
DCHECK(IsMainThread());
agent_ = MakeGarbageCollected<DevToolsAgent>(
this, inspected_frames_.Get(), probe_sink_.Get(),
diff --git a/third_party/blink/renderer/core/exported/web_dev_tools_agent_impl.h b/third_party/blink/renderer/core/exported/web_dev_tools_agent_impl.h
index 0b29611..73d5b643 100644
--- a/third_party/blink/renderer/core/exported/web_dev_tools_agent_impl.h
+++ b/third_party/blink/renderer/core/exported/web_dev_tools_agent_impl.h
@@ -64,7 +64,7 @@
public:
static WebDevToolsAgentImpl* CreateForFrame(WebLocalFrameImpl*);
- WebDevToolsAgentImpl(WebLocalFrameImpl*, bool include_view_agents);
+ WebDevToolsAgentImpl(WebLocalFrameImpl*);
~WebDevToolsAgentImpl() override;
virtual void Trace(Visitor*) const;
DevToolsAgent* GetDevToolsAgent() const { return agent_.Get(); }
@@ -133,7 +133,6 @@
Member<InspectedFrames> inspected_frames_;
Member<InspectorResourceContainer> resource_container_;
Member<Node> node_to_inspect_;
- bool include_view_agents_;
bool wait_for_debugger_when_shown_ = false;
bool is_paused_for_new_window_shown_ = false;
};
diff --git a/third_party/blink/renderer/core/inspector/inspector_protocol_config.json b/third_party/blink/renderer/core/inspector/inspector_protocol_config.json
index b0c6919..d214204 100644
--- a/third_party/blink/renderer/core/inspector/inspector_protocol_config.json
+++ b/third_party/blink/renderer/core/inspector/inspector_protocol_config.json
@@ -27,10 +27,6 @@
"async": ["enable", "takeComputedStyleUpdates"]
},
{
- "domain": "Database",
- "async": ["executeSQL"]
- },
- {
"domain": "DeviceOrientation"
},
{
diff --git a/third_party/blink/renderer/modules/modules_initializer.cc b/third_party/blink/renderer/modules/modules_initializer.cc
index 36b8d17..8f8f4a2e 100644
--- a/third_party/blink/renderer/modules/modules_initializer.cc
+++ b/third_party/blink/renderer/modules/modules_initializer.cc
@@ -94,7 +94,6 @@
#include "third_party/blink/renderer/modules/webaudio/audio_graph_tracer.h"
#include "third_party/blink/renderer/modules/webaudio/inspector_web_audio_agent.h"
#include "third_party/blink/renderer/modules/webdatabase/database_client.h"
-#include "third_party/blink/renderer/modules/webdatabase/inspector_database_agent.h"
#include "third_party/blink/renderer/modules/webdatabase/web_database_host.h"
#include "third_party/blink/renderer/modules/webdatabase/web_database_impl.h"
#include "third_party/blink/renderer/modules/webgl/webgl2_rendering_context.h"
@@ -298,7 +297,6 @@
void ModulesInitializer::InitInspectorAgentSession(
DevToolsSession* session,
- bool allow_view_agents,
InspectorDOMAgent* dom_agent,
InspectedFrames* inspected_frames,
Page* page) const {
@@ -311,9 +309,6 @@
session->CreateAndAppend<InspectorWebAudioAgent>(page);
session->CreateAndAppend<InspectorCacheStorageAgent>(inspected_frames);
session->CreateAndAppend<BucketFileSystemAgent>(inspected_frames);
- if (allow_view_agents) {
- session->CreateAndAppend<InspectorDatabaseAgent>(page);
- }
}
void ModulesInitializer::OnClearWindowObjectInMainWorld(
diff --git a/third_party/blink/renderer/modules/modules_initializer.h b/third_party/blink/renderer/modules/modules_initializer.h
index edced66..30f0b6bd 100644
--- a/third_party/blink/renderer/modules/modules_initializer.h
+++ b/third_party/blink/renderer/modules/modules_initializer.h
@@ -27,7 +27,6 @@
PictureInPictureController* CreatePictureInPictureController(
Document&) const override;
void InitInspectorAgentSession(DevToolsSession*,
- bool,
InspectorDOMAgent*,
InspectedFrames*,
Page*) const override;
diff --git a/third_party/blink/renderer/modules/webdatabase/BUILD.gn b/third_party/blink/renderer/modules/webdatabase/BUILD.gn
index ed04a7f..306e2e3 100644
--- a/third_party/blink/renderer/modules/webdatabase/BUILD.gn
+++ b/third_party/blink/renderer/modules/webdatabase/BUILD.gn
@@ -27,10 +27,6 @@
"database_tracker.h",
"dom_window_web_database.cc",
"dom_window_web_database.h",
- "inspector_database_agent.cc",
- "inspector_database_agent.h",
- "inspector_database_resource.cc",
- "inspector_database_resource.h",
"quota_tracker.cc",
"quota_tracker.h",
"sql_error.cc",
diff --git a/third_party/blink/renderer/modules/webdatabase/database.cc b/third_party/blink/renderer/modules/webdatabase/database.cc
index 23c7fac..e8b0521 100644
--- a/third_party/blink/renderer/modules/webdatabase/database.cc
+++ b/third_party/blink/renderer/modules/webdatabase/database.cc
@@ -419,11 +419,6 @@
return GetDatabaseContext()->GetDatabaseThread()->TransactionCoordinator();
}
-// static
-const char* Database::DatabaseInfoTableName() {
- return kInfoTableName;
-}
-
void Database::CloseDatabase() {
if (!opened_.load(std::memory_order_relaxed))
return;
@@ -870,49 +865,6 @@
WrapCrossThreadPersistent(transaction)));
}
-Vector<String> Database::PerformGetTableNames() {
- DisableAuthorizer();
-
- SQLiteStatement statement(
- SqliteDatabase(), "SELECT name FROM sqlite_master WHERE type='table';");
- if (statement.Prepare() != kSQLResultOk) {
- DLOG(ERROR) << "Unable to retrieve list of tables for database "
- << DatabaseDebugName();
- EnableAuthorizer();
- return Vector<String>();
- }
-
- Vector<String> table_names;
- int result;
- while ((result = statement.Step()) == kSQLResultRow) {
- String name = statement.GetColumnText(0);
- if (name != DatabaseInfoTableName())
- table_names.push_back(name);
- }
-
- EnableAuthorizer();
-
- if (result != kSQLResultDone) {
- DLOG(ERROR) << "Error getting tables for database " << DatabaseDebugName();
- return Vector<String>();
- }
-
- return table_names;
-}
-
-Vector<String> Database::TableNames() {
- Vector<String> result;
- base::WaitableEvent event;
- if (!GetDatabaseContext()->DatabaseThreadAvailable())
- return result;
-
- auto task = std::make_unique<DatabaseTableNamesTask>(this, &event, result);
- GetDatabaseContext()->GetDatabaseThread()->ScheduleTask(std::move(task));
- event.Wait();
-
- return result;
-}
-
const SecurityOrigin* Database::GetSecurityOrigin() const {
if (!GetExecutionContext())
return nullptr;
diff --git a/third_party/blink/renderer/modules/webdatabase/database.h b/third_party/blink/renderer/modules/webdatabase/database.h
index 93db104..fd57f27 100644
--- a/third_party/blink/renderer/modules/webdatabase/database.h
+++ b/third_party/blink/renderer/modules/webdatabase/database.h
@@ -117,7 +117,6 @@
bool HadDeletes();
void ResetAuthorizer();
- Vector<String> TableNames();
void ScheduleTransactionCallback(SQLTransaction*);
void CloseImmediately();
void CloseDatabase();
@@ -159,11 +158,9 @@
SQLTransaction::OnSuccessCallback*,
bool read_only,
const ChangeVersionData* = nullptr);
- Vector<String> PerformGetTableNames();
void ReportSqliteError(int sqlite_error_code);
void LogErrorMessage(const String&);
- static const char* DatabaseInfoTableName();
String DatabaseDebugName() const {
return context_thread_security_origin_->ToString() + "::" + name_;
}
diff --git a/third_party/blink/renderer/modules/webdatabase/database_client.cc b/third_party/blink/renderer/modules/webdatabase/database_client.cc
index 852d133b..8ba655f 100644
--- a/third_party/blink/renderer/modules/webdatabase/database_client.cc
+++ b/third_party/blink/renderer/modules/webdatabase/database_client.cc
@@ -35,14 +35,12 @@
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/modules/webdatabase/database.h"
-#include "third_party/blink/renderer/modules/webdatabase/inspector_database_agent.h"
namespace blink {
DatabaseClient::DatabaseClient(Page& page) : Supplement(page) {}
void DatabaseClient::Trace(Visitor* visitor) const {
- visitor->Trace(inspector_agent_);
Supplement<Page>::Trace(visitor);
}
@@ -64,18 +62,4 @@
WebContentSettingsClient::StorageType::kDatabase);
}
-void DatabaseClient::DidOpenDatabase(blink::Database* database,
- const String& domain,
- const String& name,
- const String& version) {
- if (inspector_agent_)
- inspector_agent_->DidOpenDatabase(database, domain, name, version);
-}
-
-void DatabaseClient::SetInspectorAgent(InspectorDatabaseAgent* agent) {
- // TODO(dgozman): we should not set agent twice, but it's happening in OOPIF
- // case.
- inspector_agent_ = agent;
-}
-
} // namespace blink
diff --git a/third_party/blink/renderer/modules/webdatabase/database_client.h b/third_party/blink/renderer/modules/webdatabase/database_client.h
index a61c9893..5d531d6c 100644
--- a/third_party/blink/renderer/modules/webdatabase/database_client.h
+++ b/third_party/blink/renderer/modules/webdatabase/database_client.h
@@ -41,7 +41,6 @@
class Database;
class ExecutionContext;
-class InspectorDatabaseAgent;
class Page;
class MODULES_EXPORT DatabaseClient : public GarbageCollected<DatabaseClient>,
@@ -58,18 +57,8 @@
bool AllowDatabase(ExecutionContext*);
- void DidOpenDatabase(Database*,
- const String& domain,
- const String& name,
- const String& version);
-
static DatabaseClient* FromPage(Page*);
static DatabaseClient* From(ExecutionContext*);
-
- void SetInspectorAgent(InspectorDatabaseAgent*);
-
- private:
- Member<InspectorDatabaseAgent> inspector_agent_;
};
} // namespace blink
diff --git a/third_party/blink/renderer/modules/webdatabase/database_context.cc b/third_party/blink/renderer/modules/webdatabase/database_context.cc
index 9452c10..f979236ff 100644
--- a/third_party/blink/renderer/modules/webdatabase/database_context.cc
+++ b/third_party/blink/renderer/modules/webdatabase/database_context.cc
@@ -244,9 +244,6 @@
}
SetHasOpenDatabases();
- ExecutionContext* context = GetExecutionContext();
- DatabaseClient::From(context)->DidOpenDatabase(
- database, context->GetSecurityOrigin()->Host(), name, expected_version);
DCHECK(database);
return database;
}
diff --git a/third_party/blink/renderer/modules/webdatabase/database_task.cc b/third_party/blink/renderer/modules/webdatabase/database_task.cc
index 1c0e7bc1..3f4fe77 100644
--- a/third_party/blink/renderer/modules/webdatabase/database_task.cc
+++ b/third_party/blink/renderer/modules/webdatabase/database_task.cc
@@ -168,26 +168,4 @@
}
#endif
-// *** DatabaseTableNamesTask ***
-// Retrieves a list of all tables in the database - for WebInspector support.
-
-Database::DatabaseTableNamesTask::DatabaseTableNamesTask(
- Database* database,
- base::WaitableEvent* complete_event,
- Vector<String>& names)
- : DatabaseTask(database, complete_event), table_names_(names) {
- DCHECK(complete_event); // A task with output parameters is supposed to be
- // synchronous.
-}
-
-void Database::DatabaseTableNamesTask::DoPerformTask() {
- (*table_names_) = GetDatabase()->PerformGetTableNames();
-}
-
-#if DCHECK_IS_ON()
-const char* Database::DatabaseTableNamesTask::DebugTaskName() const {
- return "DatabaseTableNamesTask";
-}
-#endif
-
} // namespace blink
diff --git a/third_party/blink/renderer/modules/webdatabase/database_task.h b/third_party/blink/renderer/modules/webdatabase/database_task.h
index 8cd0253..eaaa260 100644
--- a/third_party/blink/renderer/modules/webdatabase/database_task.h
+++ b/third_party/blink/renderer/modules/webdatabase/database_task.h
@@ -124,21 +124,6 @@
CrossThreadPersistent<SQLTransactionBackend> transaction_;
};
-class Database::DatabaseTableNamesTask final : public DatabaseTask {
- public:
- DatabaseTableNamesTask(Database*,
- base::WaitableEvent*,
- Vector<String>& names);
-
- private:
- void DoPerformTask() override;
-#if DCHECK_IS_ON()
- const char* DebugTaskName() const override;
-#endif
-
- const raw_ref<Vector<String>> table_names_;
-};
-
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_WEBDATABASE_DATABASE_TASK_H_
diff --git a/third_party/blink/renderer/modules/webdatabase/inspector_database_agent.cc b/third_party/blink/renderer/modules/webdatabase/inspector_database_agent.cc
deleted file mode 100644
index da90107..0000000
--- a/third_party/blink/renderer/modules/webdatabase/inspector_database_agent.cc
+++ /dev/null
@@ -1,319 +0,0 @@
-/*
- * Copyright (C) 2010 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "third_party/blink/renderer/modules/webdatabase/inspector_database_agent.h"
-
-#include "third_party/blink/renderer/core/frame/local_frame.h"
-#include "third_party/blink/renderer/core/loader/document_loader.h"
-#include "third_party/blink/renderer/core/page/page.h"
-#include "third_party/blink/renderer/modules/webdatabase/database.h"
-#include "third_party/blink/renderer/modules/webdatabase/database_client.h"
-#include "third_party/blink/renderer/modules/webdatabase/database_tracker.h"
-#include "third_party/blink/renderer/modules/webdatabase/inspector_database_resource.h"
-#include "third_party/blink/renderer/modules/webdatabase/sql_error.h"
-#include "third_party/blink/renderer/modules/webdatabase/sql_result_set.h"
-#include "third_party/blink/renderer/modules/webdatabase/sql_result_set_row_list.h"
-#include "third_party/blink/renderer/modules/webdatabase/sql_transaction.h"
-#include "third_party/blink/renderer/modules/webdatabase/sqlite/sql_value.h"
-#include "third_party/blink/renderer/platform/bindings/exception_state.h"
-#include "third_party/blink/renderer/platform/wtf/ref_counted.h"
-#include "third_party/blink/renderer/platform/wtf/vector.h"
-
-typedef blink::protocol::Database::Backend::ExecuteSQLCallback
- ExecuteSQLCallback;
-
-namespace blink {
-
-namespace {
-
-class ExecuteSQLCallbackWrapper : public RefCounted<ExecuteSQLCallbackWrapper> {
- public:
- static scoped_refptr<ExecuteSQLCallbackWrapper> Create(
- std::unique_ptr<ExecuteSQLCallback> callback) {
- return base::AdoptRef(new ExecuteSQLCallbackWrapper(std::move(callback)));
- }
- ~ExecuteSQLCallbackWrapper() = default;
- ExecuteSQLCallback* Get() { return callback_.get(); }
-
- void ReportTransactionFailed(SQLError* error) {
- auto error_object = protocol::Database::Error::create()
- .setMessage(error->message())
- .setCode(error->code())
- .build();
- callback_->sendSuccess(nullptr, nullptr, std::move(error_object));
- }
-
- private:
- explicit ExecuteSQLCallbackWrapper(
- std::unique_ptr<ExecuteSQLCallback> callback)
- : callback_(std::move(callback)) {}
- std::unique_ptr<ExecuteSQLCallback> callback_;
-};
-
-class StatementCallback final : public SQLStatement::OnSuccessCallback {
- public:
- explicit StatementCallback(
- scoped_refptr<ExecuteSQLCallbackWrapper> request_callback)
- : request_callback_(std::move(request_callback)) {}
- ~StatementCallback() override = default;
-
- bool OnSuccess(SQLTransaction*, SQLResultSet* result_set) override {
- SQLResultSetRowList* row_list = result_set->rows();
-
- const Vector<String>& columns = row_list->ColumnNames();
- auto column_names = std::make_unique<protocol::Array<String>>(
- columns.begin(), columns.end());
-
- auto values = std::make_unique<protocol::Array<protocol::Value>>();
- const Vector<SQLValue>& data = row_list->Values();
- for (wtf_size_t i = 0; i < data.size(); ++i) {
- const SQLValue& value = row_list->Values()[i];
- switch (value.GetType()) {
- case SQLValue::kStringValue:
- values->emplace_back(
- protocol::StringValue::create(value.GetString()));
- break;
- case SQLValue::kNumberValue:
- values->emplace_back(
- protocol::FundamentalValue::create(value.Number()));
- break;
- case SQLValue::kNullValue:
- values->emplace_back(protocol::Value::null());
- break;
- }
- }
- request_callback_->Get()->sendSuccess(std::move(column_names),
- std::move(values), nullptr);
- return true;
- }
-
- private:
- scoped_refptr<ExecuteSQLCallbackWrapper> request_callback_;
-};
-
-class StatementErrorCallback final : public SQLStatement::OnErrorCallback {
- public:
- explicit StatementErrorCallback(
- scoped_refptr<ExecuteSQLCallbackWrapper> request_callback)
- : request_callback_(std::move(request_callback)) {}
- ~StatementErrorCallback() override = default;
-
- bool OnError(SQLTransaction*, SQLError* error) override {
- request_callback_->ReportTransactionFailed(error);
- return true;
- }
-
- private:
- scoped_refptr<ExecuteSQLCallbackWrapper> request_callback_;
-};
-
-class TransactionCallback final : public SQLTransaction::OnProcessCallback {
- public:
- explicit TransactionCallback(
- const String& sql_statement,
- scoped_refptr<ExecuteSQLCallbackWrapper> request_callback)
- : sql_statement_(sql_statement),
- request_callback_(std::move(request_callback)) {}
- ~TransactionCallback() override = default;
-
- bool OnProcess(SQLTransaction* transaction) override {
- Vector<SQLValue> sql_values;
- transaction->ExecuteSQL(
- sql_statement_, sql_values,
- MakeGarbageCollected<StatementCallback>(request_callback_),
- MakeGarbageCollected<StatementErrorCallback>(request_callback_),
- IGNORE_EXCEPTION_FOR_TESTING);
- return true;
- }
-
- private:
- String sql_statement_;
- scoped_refptr<ExecuteSQLCallbackWrapper> request_callback_;
-};
-
-class TransactionErrorCallback final : public SQLTransaction::OnErrorCallback {
- public:
- static TransactionErrorCallback* Create(
- scoped_refptr<ExecuteSQLCallbackWrapper> request_callback) {
- return MakeGarbageCollected<TransactionErrorCallback>(
- std::move(request_callback));
- }
-
- explicit TransactionErrorCallback(
- scoped_refptr<ExecuteSQLCallbackWrapper> request_callback)
- : request_callback_(std::move(request_callback)) {}
- ~TransactionErrorCallback() override = default;
-
- bool OnError(SQLError* error) override {
- request_callback_->ReportTransactionFailed(error);
- return true;
- }
-
- private:
- scoped_refptr<ExecuteSQLCallbackWrapper> request_callback_;
-};
-
-} // namespace
-
-void InspectorDatabaseAgent::RegisterDatabaseOnCreation(
- blink::Database* database) {
- DidOpenDatabase(database, database->GetSecurityOrigin()->Host(),
- database->StringIdentifier(), database->version());
-}
-
-void InspectorDatabaseAgent::DidOpenDatabase(blink::Database* database,
- const String& domain,
- const String& name,
- const String& version) {
- if (InspectorDatabaseResource* resource =
- FindByFileName(database->FileName())) {
- resource->SetDatabase(database);
- return;
- }
-
- auto* resource = MakeGarbageCollected<InspectorDatabaseResource>(
- database, domain, name, version);
- resources_.Set(resource->Id(), resource);
- // Resources are only bound while visible.
- DCHECK(enabled_.Get());
- DCHECK(GetFrontend());
- resource->Bind(GetFrontend());
-}
-
-void InspectorDatabaseAgent::DidCommitLoadForLocalFrame(LocalFrame* frame) {
- // FIXME(dgozman): adapt this for out-of-process iframes.
- if (frame != page_->MainFrame())
- return;
-
- resources_.clear();
-}
-
-InspectorDatabaseAgent::InspectorDatabaseAgent(Page* page)
- : page_(page), enabled_(&agent_state_, /*default_value=*/false) {}
-
-InspectorDatabaseAgent::~InspectorDatabaseAgent() = default;
-
-void InspectorDatabaseAgent::InnerEnable() {
- if (DatabaseClient* client = DatabaseClient::FromPage(page_))
- client->SetInspectorAgent(this);
- DatabaseTracker::Tracker().ForEachOpenDatabaseInPage(
- page_,
- WTF::BindRepeating(&InspectorDatabaseAgent::RegisterDatabaseOnCreation,
- WrapPersistent(this)));
-}
-
-protocol::Response InspectorDatabaseAgent::enable() {
- if (enabled_.Get())
- return protocol::Response::Success();
- enabled_.Set(true);
- InnerEnable();
- return protocol::Response::Success();
-}
-
-protocol::Response InspectorDatabaseAgent::disable() {
- if (!enabled_.Get())
- return protocol::Response::Success();
- enabled_.Set(false);
- if (DatabaseClient* client = DatabaseClient::FromPage(page_))
- client->SetInspectorAgent(nullptr);
- resources_.clear();
- return protocol::Response::Success();
-}
-
-void InspectorDatabaseAgent::Restore() {
- if (enabled_.Get())
- InnerEnable();
-}
-
-protocol::Response InspectorDatabaseAgent::getDatabaseTableNames(
- const String& database_id,
- std::unique_ptr<protocol::Array<String>>* names) {
- if (!enabled_.Get())
- return protocol::Response::ServerError("Database agent is not enabled");
-
- blink::Database* database = DatabaseForId(database_id);
- if (database) {
- Vector<String> table_names = database->TableNames();
- *names = std::make_unique<protocol::Array<String>>(table_names.begin(),
- table_names.end());
- } else {
- *names = std::make_unique<protocol::Array<String>>();
- }
- return protocol::Response::Success();
-}
-
-void InspectorDatabaseAgent::executeSQL(
- const String& database_id,
- const String& query,
- std::unique_ptr<ExecuteSQLCallback> request_callback) {
- if (!enabled_.Get()) {
- request_callback->sendFailure(
- protocol::Response::ServerError("Database agent is not enabled"));
- return;
- }
-
- blink::Database* database = DatabaseForId(database_id);
- if (!database) {
- request_callback->sendFailure(
- protocol::Response::ServerError("Database not found"));
- return;
- }
-
- scoped_refptr<ExecuteSQLCallbackWrapper> wrapper =
- ExecuteSQLCallbackWrapper::Create(std::move(request_callback));
- auto* callback = MakeGarbageCollected<TransactionCallback>(query, wrapper);
- TransactionErrorCallback* error_callback =
- TransactionErrorCallback::Create(wrapper);
- SQLTransaction::OnSuccessCallback* success_callback = nullptr;
- database->PerformTransaction(callback, error_callback, success_callback);
-}
-
-InspectorDatabaseResource* InspectorDatabaseAgent::FindByFileName(
- const String& file_name) {
- for (auto& resource : resources_) {
- if (resource.value->GetDatabase()->FileName() == file_name)
- return resource.value.Get();
- }
- return nullptr;
-}
-
-blink::Database* InspectorDatabaseAgent::DatabaseForId(
- const String& database_id) {
- DatabaseResourcesHeapMap::iterator it = resources_.find(database_id);
- if (it == resources_.end())
- return nullptr;
- return it->value->GetDatabase();
-}
-
-void InspectorDatabaseAgent::Trace(Visitor* visitor) const {
- visitor->Trace(page_);
- visitor->Trace(resources_);
- InspectorBaseAgent::Trace(visitor);
-}
-
-} // namespace blink
diff --git a/third_party/blink/renderer/modules/webdatabase/inspector_database_agent.h b/third_party/blink/renderer/modules/webdatabase/inspector_database_agent.h
deleted file mode 100644
index 83dff65..0000000
--- a/third_party/blink/renderer/modules/webdatabase/inspector_database_agent.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (C) 2010 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_WEBDATABASE_INSPECTOR_DATABASE_AGENT_H_
-#define THIRD_PARTY_BLINK_RENDERER_MODULES_WEBDATABASE_INSPECTOR_DATABASE_AGENT_H_
-
-#include "third_party/blink/renderer/core/inspector/inspector_base_agent.h"
-#include "third_party/blink/renderer/core/inspector/protocol/database.h"
-#include "third_party/blink/renderer/modules/modules_export.h"
-#include "third_party/blink/renderer/platform/heap/collection_support/heap_hash_map.h"
-#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
-#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
-
-namespace blink {
-
-class Database;
-class InspectorDatabaseResource;
-class Page;
-
-class MODULES_EXPORT InspectorDatabaseAgent final
- : public InspectorBaseAgent<protocol::Database::Metainfo> {
- public:
- explicit InspectorDatabaseAgent(Page*);
-
- InspectorDatabaseAgent(const InspectorDatabaseAgent&) = delete;
- InspectorDatabaseAgent& operator=(const InspectorDatabaseAgent&) = delete;
-
- ~InspectorDatabaseAgent() override;
- void Trace(Visitor*) const override;
-
- protocol::Response disable() override;
- void Restore() override;
- void DidCommitLoadForLocalFrame(LocalFrame*) override;
-
- // Called from the front-end.
- protocol::Response enable() override;
- protocol::Response getDatabaseTableNames(
- const String& database_id,
- std::unique_ptr<protocol::Array<String>>* names) override;
- void executeSQL(const String& database_id,
- const String& query,
- std::unique_ptr<ExecuteSQLCallback>) override;
-
- void DidOpenDatabase(blink::Database*,
- const String& domain,
- const String& name,
- const String& version);
-
- private:
- void InnerEnable();
- void RegisterDatabaseOnCreation(blink::Database*);
-
- blink::Database* DatabaseForId(const String& database_id);
- InspectorDatabaseResource* FindByFileName(const String& file_name);
-
- Member<Page> page_;
- typedef HeapHashMap<String, Member<InspectorDatabaseResource>>
- DatabaseResourcesHeapMap;
- DatabaseResourcesHeapMap resources_;
- InspectorAgentState::Boolean enabled_;
-};
-
-} // namespace blink
-
-#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_WEBDATABASE_INSPECTOR_DATABASE_AGENT_H_
diff --git a/third_party/blink/renderer/modules/webdatabase/inspector_database_resource.cc b/third_party/blink/renderer/modules/webdatabase/inspector_database_resource.cc
deleted file mode 100644
index 7d1b85b..0000000
--- a/third_party/blink/renderer/modules/webdatabase/inspector_database_resource.cc
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
- * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com>
- * Copyright (C) 2009 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "third_party/blink/renderer/modules/webdatabase/inspector_database_resource.h"
-
-#include "third_party/blink/renderer/modules/webdatabase/database.h"
-
-namespace blink {
-
-static int g_next_unused_id = 1;
-
-InspectorDatabaseResource::InspectorDatabaseResource(Database* database,
- const String& domain,
- const String& name,
- const String& version)
- : database_(database),
- id_(String::Number(g_next_unused_id++)),
- domain_(domain),
- name_(name),
- version_(version) {}
-
-void InspectorDatabaseResource::Trace(Visitor* visitor) const {
- visitor->Trace(database_);
-}
-
-void InspectorDatabaseResource::Bind(protocol::Database::Frontend* frontend) {
- std::unique_ptr<protocol::Database::Database> json_object =
- protocol::Database::Database::create()
- .setId(id_)
- .setDomain(domain_)
- .setName(name_)
- .setVersion(version_)
- .build();
- frontend->addDatabase(std::move(json_object));
-}
-
-} // namespace blink
diff --git a/third_party/blink/renderer/modules/webdatabase/inspector_database_resource.h b/third_party/blink/renderer/modules/webdatabase/inspector_database_resource.h
deleted file mode 100644
index 356c9f5..0000000
--- a/third_party/blink/renderer/modules/webdatabase/inspector_database_resource.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
- * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com>
- * Copyright (C) 2009 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_WEBDATABASE_INSPECTOR_DATABASE_RESOURCE_H_
-#define THIRD_PARTY_BLINK_RENDERER_MODULES_WEBDATABASE_INSPECTOR_DATABASE_RESOURCE_H_
-
-#include "third_party/blink/renderer/core/inspector/protocol/database.h"
-#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
-#include "third_party/blink/renderer/platform/heap/member.h"
-#include "third_party/blink/renderer/platform/wtf/forward.h"
-#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
-
-namespace blink {
-class Database;
-
-class InspectorDatabaseResource final
- : public GarbageCollected<InspectorDatabaseResource> {
- public:
- InspectorDatabaseResource(Database*,
- const String& domain,
- const String& name,
- const String& version);
- void Trace(Visitor*) const;
-
- void Bind(protocol::Database::Frontend*);
- Database* GetDatabase() { return database_.Get(); }
- void SetDatabase(Database* database) { database_ = database; }
- String Id() const { return id_; }
-
- private:
- Member<Database> database_;
- String id_;
- String domain_;
- String name_;
- String version_;
-};
-
-} // namespace blink
-
-#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_WEBDATABASE_INSPECTOR_DATABASE_RESOURCE_H_