Diff
Modified: trunk/Source/WebCore/ChangeLog (126272 => 126273)
--- trunk/Source/WebCore/ChangeLog 2012-08-22 07:49:36 UTC (rev 126272)
+++ trunk/Source/WebCore/ChangeLog 2012-08-22 07:50:35 UTC (rev 126273)
@@ -1,3 +1,29 @@
+2012-08-22 Taiju Tsuiki <[email protected]>
+
+ Web Inspector: Add deleteEntry command and deletionCompleted event to FileSystemAgent
+ https://bugs.webkit.org/show_bug.cgi?id=91831
+
+ Reviewed by Vsevolod Vlasov.
+
+ InspectorAgent-side implementation of deleteEntry command.
+
+ Test will be added after JS-side implementation landed.
+
+ * inspector/Inspector.json:
+ * inspector/InspectorFileSystemAgent.cpp:
+ (WebCore):
+ (WebCore::InspectorFileSystemAgent::requestFileSystemRoot):
+ (WebCore::InspectorFileSystemAgent::requestDirectoryContent):
+ (WebCore::InspectorFileSystemAgent::requestMetadata):
+ (WebCore::InspectorFileSystemAgent::requestFileContent):
+ (WebCore::InspectorFileSystemAgent::deleteEntry):
+ (WebCore::InspectorFileSystemAgent::assertFrontend):
+ * inspector/InspectorFileSystemAgent.h:
+ (InspectorFileSystemAgent):
+ * inspector/front-end/FileSystemModel.js:
+ (WebInspector.FileSystemDispatcher.prototype.fileContentReceived):
+ (WebInspector.FileSystemDispatcher.prototype.deletionCompleted):
+
2012-08-21 Pavel Feldman <[email protected]>
Web Inspector: TabbedPane: measure tab widths in batches.
Modified: trunk/Source/WebCore/inspector/Inspector.json (126272 => 126273)
--- trunk/Source/WebCore/inspector/Inspector.json 2012-08-22 07:49:36 UTC (rev 126272)
+++ trunk/Source/WebCore/inspector/Inspector.json 2012-08-22 07:50:35 UTC (rev 126273)
@@ -1549,6 +1549,16 @@
{ "name": "requestId", "$ref": "RequestId", "description": "Request identifier. Corresponding fileContentReceived event should have same requestId with this." }
],
"description": "Returns content of the file as fileContentReceived event. Result should be sliced into [start, end)."
+ },
+ {
+ "name": "deleteEntry",
+ "parameters": [
+ { "name": "url", "type": "string", "description": "URL of the entry to delete." }
+ ],
+ "returns": [
+ { "name": "requestId", "$ref": "RequestId", "description": "Request identifier. Corresponding deletionCompleted event should have same requestId with this." }
+ ],
+ "description": "Deletes specified entry. If the entry is a directory, the agent deletes children recursively."
}
],
"events": [
@@ -1557,7 +1567,7 @@
"parameters": [
{ "name": "requestId", "type": "integer", "description": "Request Identifier that was returned by corresponding requestFileSystemRoot command." },
{ "name": "errorCode", "type": "integer", "description": "0, if no error. Otherwise, errorCode is set to FileError::ErrorCode value." },
- { "name": "root", "$ref": "FileSystem.Entry", "optional": true, "description": "Contains root of the requested FileSystem if the command completed successfully." }
+ { "name": "root", "$ref": "Entry", "optional": true, "description": "Contains root of the requested FileSystem if the command completed successfully." }
],
"description": "Completion event of requestFileSystemRoot command."
},
@@ -1566,7 +1576,7 @@
"parameters": [
{ "name": "requestId", "type": "integer", "description": "Request Identifier that was returned by corresponding requestDirectoryContent command." },
{ "name": "errorCode", "type": "integer", "description": "0, if no error. Otherwise, errorCode is set to FileError::ErrorCode value." },
- { "name": "entries", "type": "array", "items": { "$ref": "FileSystem.Entry" }, "optional": true, "description": "Contains all entries on directory if the command completed successfully." }
+ { "name": "entries", "type": "array", "items": { "$ref": "Entry" }, "optional": true, "description": "Contains all entries on directory if the command completed successfully." }
],
"description": "Completion event of requestDirectoryContent command."
},
@@ -1575,7 +1585,7 @@
"parameters": [
{ "name": "requestId", "type": "integer", "description": "Request Identifier that was returned in response to the corresponding requestMetadata command." },
{ "name": "errorCode", "type": "integer", "description": "0, if no error. Otherwise, errorCode is set to FileError::ErrorCode value." },
- { "name": "metadata", "$ref": "FileSystem.Metadata", "optional": true, "description": "Contains metadata of the entry if the command completed successfully." }
+ { "name": "metadata", "$ref": "Metadata", "optional": true, "description": "Contains metadata of the entry if the command completed successfully." }
],
"description": "Completion event of requestMetadata command."
},
@@ -1588,6 +1598,14 @@
{ "name": "charset", "type": "string", "optional": true, "description": "Charset of the content if it is served as text." }
],
"description": "Completion event of requestFileContent command."
+ },
+ {
+ "name": "deletionCompleted",
+ "parameters": [
+ { "name": "requestId", "type": "integer", "description": "Request Identifier that was returned in response to the corresponding deleteEntry command." },
+ { "name": "errorCode", "type": "integer", "description": "0, if no error. Otherwise errorCode is set to FileError::ErrorCode value." }
+ ],
+ "description": "Completion event of deleteEntry command."
}
]
},
Modified: trunk/Source/WebCore/inspector/InspectorFileSystemAgent.cpp (126272 => 126273)
--- trunk/Source/WebCore/inspector/InspectorFileSystemAgent.cpp 2012-08-22 07:49:36 UTC (rev 126272)
+++ trunk/Source/WebCore/inspector/InspectorFileSystemAgent.cpp 2012-08-22 07:50:35 UTC (rev 126273)
@@ -63,6 +63,7 @@
#include "SecurityOrigin.h"
#include "TextEncoding.h"
#include "TextResourceDecoder.h"
+#include "VoidCallback.h"
#include <wtf/text/Base64.h>
using WebCore::TypeBuilder::Array;
@@ -173,7 +174,12 @@
void start(ScriptExecutionContext*);
private:
- bool didHitError(FileError*);
+ bool didHitError(FileError* error)
+ {
+ reportResult(error->code());
+ return true;
+ }
+
bool didGetEntry(Entry*);
void reportResult(FileError::ErrorCode errorCode, PassRefPtr<TypeBuilder::FileSystem::Entry> entry = 0)
@@ -194,12 +200,6 @@
String m_type;
};
-bool FileSystemRootRequest::didHitError(FileError* error)
-{
- reportResult(error->code());
- return true;
-}
-
void FileSystemRootRequest::start(ScriptExecutionContext* scriptExecutionContext)
{
ASSERT(scriptExecutionContext);
@@ -587,6 +587,94 @@
reportResult(static_cast<FileError::ErrorCode>(0), &result, &m_charset);
}
+class DeleteEntryRequest : public VoidCallback {
+public:
+ static PassRefPtr<DeleteEntryRequest> create(PassRefPtr<FrontendProvider> frontendProvider, int requestId, const KURL& url)
+ {
+ return adoptRef(new DeleteEntryRequest(frontendProvider, requestId, url));
+ }
+
+ virtual ~DeleteEntryRequest()
+ {
+ reportResult(FileError::ABORT_ERR);
+ }
+
+ virtual bool handleEvent() OVERRIDE
+ {
+ return didDeleteEntry();
+ }
+
+ void start(ScriptExecutionContext*);
+
+private:
+ bool didHitError(FileError* error)
+ {
+ reportResult(error->code());
+ return true;
+ }
+
+ bool didGetEntry(Entry*);
+ bool didDeleteEntry();
+
+ void reportResult(FileError::ErrorCode errorCode)
+ {
+ if (!m_frontendProvider || !m_frontendProvider->frontend())
+ return;
+ m_frontendProvider->frontend()->deletionCompleted(m_requestId, static_cast<int>(errorCode));
+ m_frontendProvider = 0;
+ }
+
+ DeleteEntryRequest(PassRefPtr<FrontendProvider> frontendProvider, int requestId, const KURL& url)
+ : m_frontendProvider(frontendProvider)
+ , m_requestId(requestId)
+ , m_url(url) { }
+
+ RefPtr<FrontendProvider> m_frontendProvider;
+ int m_requestId;
+ FileSystemType m_type;
+ KURL m_url;
+};
+
+void DeleteEntryRequest::start(ScriptExecutionContext* scriptExecutionContext)
+{
+ ASSERT(scriptExecutionContext);
+
+ RefPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallback>::create(this, &DeleteEntryRequest::didHitError);
+
+ FileSystemType type;
+ String path;
+ if (!DOMFileSystemBase::crackFileSystemURL(m_url, type, path)) {
+ scriptExecutionContext->postTask(ReportErrorTask::create(errorCallback, FileError::SYNTAX_ERR));
+ return;
+ }
+
+ if (path == "/") {
+ OwnPtr<AsyncFileSystemCallbacks> fileSystemCallbacks = VoidCallbacks::create(this, errorCallback);
+ LocalFileSystem::localFileSystem().deleteFileSystem(scriptExecutionContext, type, fileSystemCallbacks.release());
+ } else {
+ RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallback>::create(this, &DeleteEntryRequest::didGetEntry);
+ OwnPtr<ResolveURICallbacks> fileSystemCallbacks = ResolveURICallbacks::create(successCallback, errorCallback, scriptExecutionContext, type, path);
+ LocalFileSystem::localFileSystem().readFileSystem(scriptExecutionContext, type, fileSystemCallbacks.release());
+ }
+}
+
+bool DeleteEntryRequest::didGetEntry(Entry* entry)
+{
+ RefPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallback>::create(this, &DeleteEntryRequest::didHitError);
+ if (entry->isDirectory()) {
+ DirectoryEntry* directoryEntry = static_cast<DirectoryEntry*>(entry);
+ directoryEntry->removeRecursively(this, errorCallback);
+ } else
+ entry->remove(this, errorCallback);
+ return true;
+}
+
+bool DeleteEntryRequest::didDeleteEntry()
+{
+ reportResult(static_cast<FileError::ErrorCode>(0));
+ return true;
+}
+
} // anonymous namespace
// static
@@ -620,11 +708,8 @@
void InspectorFileSystemAgent::requestFileSystemRoot(ErrorString* error, const String& origin, const String& type, int* requestId)
{
- if (!m_enabled || !m_frontendProvider) {
- *error = "FileSystem agent is not enabled";
+ if (!assertFrontend(error))
return;
- }
- ASSERT(m_frontendProvider->frontend());
ScriptExecutionContext* scriptExecutionContext = assertScriptExecutionContextForOrigin(error, SecurityOrigin::createFromString(origin).get());
if (!scriptExecutionContext)
@@ -636,11 +721,8 @@
void InspectorFileSystemAgent::requestDirectoryContent(ErrorString* error, const String& url, int* requestId)
{
- if (!m_enabled || !m_frontendProvider) {
- *error = "FileSystem agent is not enabled";
+ if (!assertFrontend(error))
return;
- }
- ASSERT(m_frontendProvider->frontend());
ScriptExecutionContext* scriptExecutionContext = assertScriptExecutionContextForOrigin(error, SecurityOrigin::createFromString(url).get());
if (!scriptExecutionContext)
@@ -652,11 +734,8 @@
void InspectorFileSystemAgent::requestMetadata(ErrorString* error, const String& url, int* requestId)
{
- if (!m_enabled || !m_frontendProvider) {
- *error = "FileSystem agent is not enabled";
+ if (!assertFrontend(error))
return;
- }
- ASSERT(m_frontendProvider->frontend());
ScriptExecutionContext* scriptExecutionContext = assertScriptExecutionContextForOrigin(error, SecurityOrigin::createFromString(url).get());
if (!scriptExecutionContext)
@@ -668,11 +747,8 @@
void InspectorFileSystemAgent::requestFileContent(ErrorString* error, const String& url, bool readAsText, const int* start, const int* end, const String* charset, int* requestId)
{
- if (!m_enabled || !m_frontendProvider) {
- *error = "FileSystem agent is not enabled";
+ if (!assertFrontend(error))
return;
- }
- ASSERT(m_frontendProvider->frontend());
ScriptExecutionContext* scriptExecutionContext = assertScriptExecutionContextForOrigin(error, SecurityOrigin::createFromString(url).get());
if (!scriptExecutionContext)
@@ -685,6 +761,21 @@
FileContentRequest::create(m_frontendProvider, *requestId, url, readAsText, startPosition, endPosition, charset ? *charset : "")->start(scriptExecutionContext);
}
+void InspectorFileSystemAgent::deleteEntry(ErrorString* error, const String& urlString, int* requestId)
+{
+ if (!assertFrontend(error))
+ return;
+
+ KURL url(ParsedURLString, urlString);
+
+ ScriptExecutionContext* scriptExecutionContext = assertScriptExecutionContextForOrigin(error, SecurityOrigin::create(url).get());
+ if (!scriptExecutionContext)
+ return;
+
+ *requestId = m_nextRequestId++;
+ DeleteEntryRequest::create(m_frontendProvider, *requestId, url)->start(scriptExecutionContext);
+}
+
void InspectorFileSystemAgent::setFrontend(InspectorFrontend* frontend)
{
ASSERT(frontend);
@@ -718,6 +809,16 @@
m_instrumentingAgents->setInspectorFileSystemAgent(this);
}
+bool InspectorFileSystemAgent::assertFrontend(ErrorString* error)
+{
+ if (!m_enabled || !m_frontendProvider) {
+ *error = "FileSystem agent is not enabled.";
+ return false;
+ }
+ ASSERT(m_frontendProvider->frontend());
+ return true;
+}
+
ScriptExecutionContext* InspectorFileSystemAgent::assertScriptExecutionContextForOrigin(ErrorString* error, SecurityOrigin* origin)
{
for (Frame* frame = m_pageAgent->mainFrame(); frame; frame = frame->tree()->traverseNext()) {
Modified: trunk/Source/WebCore/inspector/InspectorFileSystemAgent.h (126272 => 126273)
--- trunk/Source/WebCore/inspector/InspectorFileSystemAgent.h 2012-08-22 07:49:36 UTC (rev 126272)
+++ trunk/Source/WebCore/inspector/InspectorFileSystemAgent.h 2012-08-22 07:50:35 UTC (rev 126273)
@@ -59,6 +59,7 @@
virtual void requestDirectoryContent(ErrorString*, const String& url, int* requestId) OVERRIDE;
virtual void requestMetadata(ErrorString*, const String& url, int* requestId) OVERRIDE;
virtual void requestFileContent(ErrorString*, const String& url, bool readAsText, const int* start, const int* end, const String* charset, int* requestId) OVERRIDE;
+ virtual void deleteEntry(ErrorString*, const String& url, int* requestId) OVERRIDE;
virtual void setFrontend(InspectorFrontend*) OVERRIDE;
virtual void clearFrontend() OVERRIDE;
@@ -66,6 +67,7 @@
private:
InspectorFileSystemAgent(InstrumentingAgents*, InspectorPageAgent*, InspectorState*);
+ bool assertFrontend(ErrorString*);
ScriptExecutionContext* assertScriptExecutionContextForOrigin(ErrorString*, SecurityOrigin*);
InspectorPageAgent* m_pageAgent;
Modified: trunk/Source/WebCore/inspector/front-end/FileSystemModel.js (126272 => 126273)
--- trunk/Source/WebCore/inspector/front-end/FileSystemModel.js 2012-08-22 07:49:36 UTC (rev 126272)
+++ trunk/Source/WebCore/inspector/front-end/FileSystemModel.js 2012-08-22 07:50:35 UTC (rev 126273)
@@ -645,5 +645,14 @@
fileContentReceived: function(requestId, errorCode, content, charset)
{
this._agentWrapper._fileContentReceived(requestId, errorCode, content, charset);
+ },
+
+ /**
+ * @param {number} requestId
+ * @param {number} errorCode
+ */
+ deletionCompleted: function(requestId, errorCode)
+ {
+ console.error("Not implemented");
}
}