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

Unified Diff: third_party/WebKit/Source/modules/indexeddb/InspectorIndexedDBAgent.cpp

Issue 2654483004: [DevTools] Provide a way to delete Indexed DBs (Closed)
Patch Set: Moved the confirm dialog Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/modules/indexeddb/InspectorIndexedDBAgent.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/indexeddb/InspectorIndexedDBAgent.cpp
diff --git a/third_party/WebKit/Source/modules/indexeddb/InspectorIndexedDBAgent.cpp b/third_party/WebKit/Source/modules/indexeddb/InspectorIndexedDBAgent.cpp
index decb032893ac8d9fcd516cafc903ef5bcd8d77ef..39ada99abb8fc28c5910d320fb7971e8d339c666 100644
--- a/third_party/WebKit/Source/modules/indexeddb/InspectorIndexedDBAgent.cpp
+++ b/third_party/WebKit/Source/modules/indexeddb/InspectorIndexedDBAgent.cpp
@@ -77,6 +77,8 @@ typedef blink::protocol::IndexedDB::Backend::RequestDataCallback
RequestDataCallback;
typedef blink::protocol::IndexedDB::Backend::ClearObjectStoreCallback
ClearObjectStoreCallback;
+typedef blink::protocol::IndexedDB::Backend::DeleteDatabaseCallback
+ DeleteDatabaseCallback;
namespace blink {
@@ -141,6 +143,43 @@ class GetDatabaseNamesCallback final : public EventListener {
String m_securityOrigin;
};
+class DeleteCallback final : public EventListener {
+ WTF_MAKE_NONCOPYABLE(DeleteCallback);
+
+ public:
+ static DeleteCallback* create(
+ std::unique_ptr<DeleteDatabaseCallback> requestCallback,
+ const String& securityOrigin) {
+ return new DeleteCallback(std::move(requestCallback), securityOrigin);
+ }
+
+ ~DeleteCallback() override {}
+
+ bool operator==(const EventListener& other) const override {
+ return this == &other;
+ }
+
+ void handleEvent(ExecutionContext*, Event* event) override {
+ if (event->type() != EventTypeNames::success) {
+ m_requestCallback->sendFailure(
+ Response::Error("Failed to delete database."));
+ return;
+ }
+ m_requestCallback->sendSuccess();
+ }
+
+ DEFINE_INLINE_VIRTUAL_TRACE() { EventListener::trace(visitor); }
+
+ private:
+ DeleteCallback(std::unique_ptr<DeleteDatabaseCallback> requestCallback,
+ const String& securityOrigin)
+ : EventListener(EventListener::CPPEventListenerType),
+ m_requestCallback(std::move(requestCallback)),
+ m_securityOrigin(securityOrigin) {}
+ std::unique_ptr<DeleteDatabaseCallback> m_requestCallback;
+ String m_securityOrigin;
+};
+
template <typename RequestCallback>
class OpenDatabaseCallback;
template <typename RequestCallback>
@@ -951,6 +990,44 @@ void InspectorIndexedDBAgent::clearObjectStore(
databaseName);
}
+void InspectorIndexedDBAgent::deleteDatabase(
+ const String& securityOrigin,
+ const String& databaseName,
+ std::unique_ptr<DeleteDatabaseCallback> requestCallback) {
+ LocalFrame* frame =
+ m_inspectedFrames->frameWithSecurityOrigin(securityOrigin);
+ Document* document = frame ? frame->document() : nullptr;
+ if (!document) {
+ requestCallback->sendFailure(Response::Error(kNoDocumentError));
+ return;
+ }
+ IDBFactory* idbFactory = nullptr;
+ Response response = assertIDBFactory(document, idbFactory);
+ if (!response.isSuccess()) {
+ requestCallback->sendFailure(response);
+ return;
+ }
+
+ ScriptState* scriptState = ScriptState::forMainWorld(frame);
+ if (!scriptState) {
+ requestCallback->sendFailure(Response::InternalError());
+ return;
+ }
+ ScriptState::Scope scope(scriptState);
+ DummyExceptionStateForTesting exceptionState;
+ IDBRequest* idbRequest = idbFactory->closeConnectionsAndDeleteDatabase(
+ scriptState, databaseName, exceptionState);
+ if (exceptionState.hadException()) {
+ requestCallback->sendFailure(Response::Error("Could not delete database."));
+ return;
+ }
+ idbRequest->addEventListener(
+ EventTypeNames::success,
+ DeleteCallback::create(std::move(requestCallback),
+ document->getSecurityOrigin()->toRawString()),
+ false);
+}
+
DEFINE_TRACE(InspectorIndexedDBAgent) {
visitor->trace(m_inspectedFrames);
InspectorBaseAgent::trace(visitor);
« no previous file with comments | « third_party/WebKit/Source/modules/indexeddb/InspectorIndexedDBAgent.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698