Changeset 126273 in webkit
- Timestamp:
- Aug 22, 2012 12:50:35 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r126268 r126273 1 2012-08-22 Taiju Tsuiki <tzik@chromium.org> 2 3 Web Inspector: Add deleteEntry command and deletionCompleted event to FileSystemAgent 4 https://bugs.webkit.org/show_bug.cgi?id=91831 5 6 Reviewed by Vsevolod Vlasov. 7 8 InspectorAgent-side implementation of deleteEntry command. 9 10 Test will be added after JS-side implementation landed. 11 12 * inspector/Inspector.json: 13 * inspector/InspectorFileSystemAgent.cpp: 14 (WebCore): 15 (WebCore::InspectorFileSystemAgent::requestFileSystemRoot): 16 (WebCore::InspectorFileSystemAgent::requestDirectoryContent): 17 (WebCore::InspectorFileSystemAgent::requestMetadata): 18 (WebCore::InspectorFileSystemAgent::requestFileContent): 19 (WebCore::InspectorFileSystemAgent::deleteEntry): 20 (WebCore::InspectorFileSystemAgent::assertFrontend): 21 * inspector/InspectorFileSystemAgent.h: 22 (InspectorFileSystemAgent): 23 * inspector/front-end/FileSystemModel.js: 24 (WebInspector.FileSystemDispatcher.prototype.fileContentReceived): 25 (WebInspector.FileSystemDispatcher.prototype.deletionCompleted): 26 1 27 2012-08-21 Pavel Feldman <pfeldman@chromium.org> 2 28 -
trunk/Source/WebCore/inspector/Inspector.json
r126140 r126273 1550 1550 ], 1551 1551 "description": "Returns content of the file as fileContentReceived event. Result should be sliced into [start, end)." 1552 }, 1553 { 1554 "name": "deleteEntry", 1555 "parameters": [ 1556 { "name": "url", "type": "string", "description": "URL of the entry to delete." } 1557 ], 1558 "returns": [ 1559 { "name": "requestId", "$ref": "RequestId", "description": "Request identifier. Corresponding deletionCompleted event should have same requestId with this." } 1560 ], 1561 "description": "Deletes specified entry. If the entry is a directory, the agent deletes children recursively." 1552 1562 } 1553 1563 ], … … 1558 1568 { "name": "requestId", "type": "integer", "description": "Request Identifier that was returned by corresponding requestFileSystemRoot command." }, 1559 1569 { "name": "errorCode", "type": "integer", "description": "0, if no error. Otherwise, errorCode is set to FileError::ErrorCode value." }, 1560 { "name": "root", "$ref": " FileSystem.Entry", "optional": true, "description": "Contains root of the requested FileSystem if the command completed successfully." }1570 { "name": "root", "$ref": "Entry", "optional": true, "description": "Contains root of the requested FileSystem if the command completed successfully." } 1561 1571 ], 1562 1572 "description": "Completion event of requestFileSystemRoot command." … … 1567 1577 { "name": "requestId", "type": "integer", "description": "Request Identifier that was returned by corresponding requestDirectoryContent command." }, 1568 1578 { "name": "errorCode", "type": "integer", "description": "0, if no error. Otherwise, errorCode is set to FileError::ErrorCode value." }, 1569 { "name": "entries", "type": "array", "items": { "$ref": " FileSystem.Entry" }, "optional": true, "description": "Contains all entries on directory if the command completed successfully." }1579 { "name": "entries", "type": "array", "items": { "$ref": "Entry" }, "optional": true, "description": "Contains all entries on directory if the command completed successfully." } 1570 1580 ], 1571 1581 "description": "Completion event of requestDirectoryContent command." … … 1576 1586 { "name": "requestId", "type": "integer", "description": "Request Identifier that was returned in response to the corresponding requestMetadata command." }, 1577 1587 { "name": "errorCode", "type": "integer", "description": "0, if no error. Otherwise, errorCode is set to FileError::ErrorCode value." }, 1578 { "name": "metadata", "$ref": " FileSystem.Metadata", "optional": true, "description": "Contains metadata of the entry if the command completed successfully." }1588 { "name": "metadata", "$ref": "Metadata", "optional": true, "description": "Contains metadata of the entry if the command completed successfully." } 1579 1589 ], 1580 1590 "description": "Completion event of requestMetadata command." … … 1589 1599 ], 1590 1600 "description": "Completion event of requestFileContent command." 1601 }, 1602 { 1603 "name": "deletionCompleted", 1604 "parameters": [ 1605 { "name": "requestId", "type": "integer", "description": "Request Identifier that was returned in response to the corresponding deleteEntry command." }, 1606 { "name": "errorCode", "type": "integer", "description": "0, if no error. Otherwise errorCode is set to FileError::ErrorCode value." } 1607 ], 1608 "description": "Completion event of deleteEntry command." 1591 1609 } 1592 1610 ] -
trunk/Source/WebCore/inspector/InspectorFileSystemAgent.cpp
r126195 r126273 64 64 #include "TextEncoding.h" 65 65 #include "TextResourceDecoder.h" 66 #include "VoidCallback.h" 66 67 #include <wtf/text/Base64.h> 67 68 … … 174 175 175 176 private: 176 bool didHitError(FileError*); 177 bool didHitError(FileError* error) 178 { 179 reportResult(error->code()); 180 return true; 181 } 182 177 183 bool didGetEntry(Entry*); 178 184 … … 194 200 String m_type; 195 201 }; 196 197 bool FileSystemRootRequest::didHitError(FileError* error)198 {199 reportResult(error->code());200 return true;201 }202 202 203 203 void FileSystemRootRequest::start(ScriptExecutionContext* scriptExecutionContext) … … 588 588 } 589 589 590 class DeleteEntryRequest : public VoidCallback { 591 public: 592 static PassRefPtr<DeleteEntryRequest> create(PassRefPtr<FrontendProvider> frontendProvider, int requestId, const KURL& url) 593 { 594 return adoptRef(new DeleteEntryRequest(frontendProvider, requestId, url)); 595 } 596 597 virtual ~DeleteEntryRequest() 598 { 599 reportResult(FileError::ABORT_ERR); 600 } 601 602 virtual bool handleEvent() OVERRIDE 603 { 604 return didDeleteEntry(); 605 } 606 607 void start(ScriptExecutionContext*); 608 609 private: 610 bool didHitError(FileError* error) 611 { 612 reportResult(error->code()); 613 return true; 614 } 615 616 bool didGetEntry(Entry*); 617 bool didDeleteEntry(); 618 619 void reportResult(FileError::ErrorCode errorCode) 620 { 621 if (!m_frontendProvider || !m_frontendProvider->frontend()) 622 return; 623 m_frontendProvider->frontend()->deletionCompleted(m_requestId, static_cast<int>(errorCode)); 624 m_frontendProvider = 0; 625 } 626 627 DeleteEntryRequest(PassRefPtr<FrontendProvider> frontendProvider, int requestId, const KURL& url) 628 : m_frontendProvider(frontendProvider) 629 , m_requestId(requestId) 630 , m_url(url) { } 631 632 RefPtr<FrontendProvider> m_frontendProvider; 633 int m_requestId; 634 FileSystemType m_type; 635 KURL m_url; 636 }; 637 638 void DeleteEntryRequest::start(ScriptExecutionContext* scriptExecutionContext) 639 { 640 ASSERT(scriptExecutionContext); 641 642 RefPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallback>::create(this, &DeleteEntryRequest::didHitError); 643 644 FileSystemType type; 645 String path; 646 if (!DOMFileSystemBase::crackFileSystemURL(m_url, type, path)) { 647 scriptExecutionContext->postTask(ReportErrorTask::create(errorCallback, FileError::SYNTAX_ERR)); 648 return; 649 } 650 651 if (path == "/") { 652 OwnPtr<AsyncFileSystemCallbacks> fileSystemCallbacks = VoidCallbacks::create(this, errorCallback); 653 LocalFileSystem::localFileSystem().deleteFileSystem(scriptExecutionContext, type, fileSystemCallbacks.release()); 654 } else { 655 RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallback>::create(this, &DeleteEntryRequest::didGetEntry); 656 OwnPtr<ResolveURICallbacks> fileSystemCallbacks = ResolveURICallbacks::create(successCallback, errorCallback, scriptExecutionContext, type, path); 657 LocalFileSystem::localFileSystem().readFileSystem(scriptExecutionContext, type, fileSystemCallbacks.release()); 658 } 659 } 660 661 bool DeleteEntryRequest::didGetEntry(Entry* entry) 662 { 663 RefPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallback>::create(this, &DeleteEntryRequest::didHitError); 664 if (entry->isDirectory()) { 665 DirectoryEntry* directoryEntry = static_cast<DirectoryEntry*>(entry); 666 directoryEntry->removeRecursively(this, errorCallback); 667 } else 668 entry->remove(this, errorCallback); 669 return true; 670 } 671 672 bool DeleteEntryRequest::didDeleteEntry() 673 { 674 reportResult(static_cast<FileError::ErrorCode>(0)); 675 return true; 676 } 677 590 678 } // anonymous namespace 591 679 … … 621 709 void InspectorFileSystemAgent::requestFileSystemRoot(ErrorString* error, const String& origin, const String& type, int* requestId) 622 710 { 623 if (!m_enabled || !m_frontendProvider) { 624 *error = "FileSystem agent is not enabled"; 625 return; 626 } 627 ASSERT(m_frontendProvider->frontend()); 711 if (!assertFrontend(error)) 712 return; 628 713 629 714 ScriptExecutionContext* scriptExecutionContext = assertScriptExecutionContextForOrigin(error, SecurityOrigin::createFromString(origin).get()); … … 637 722 void InspectorFileSystemAgent::requestDirectoryContent(ErrorString* error, const String& url, int* requestId) 638 723 { 639 if (!m_enabled || !m_frontendProvider) { 640 *error = "FileSystem agent is not enabled"; 641 return; 642 } 643 ASSERT(m_frontendProvider->frontend()); 724 if (!assertFrontend(error)) 725 return; 644 726 645 727 ScriptExecutionContext* scriptExecutionContext = assertScriptExecutionContextForOrigin(error, SecurityOrigin::createFromString(url).get()); … … 653 735 void InspectorFileSystemAgent::requestMetadata(ErrorString* error, const String& url, int* requestId) 654 736 { 655 if (!m_enabled || !m_frontendProvider) { 656 *error = "FileSystem agent is not enabled"; 657 return; 658 } 659 ASSERT(m_frontendProvider->frontend()); 737 if (!assertFrontend(error)) 738 return; 660 739 661 740 ScriptExecutionContext* scriptExecutionContext = assertScriptExecutionContextForOrigin(error, SecurityOrigin::createFromString(url).get()); … … 669 748 void InspectorFileSystemAgent::requestFileContent(ErrorString* error, const String& url, bool readAsText, const int* start, const int* end, const String* charset, int* requestId) 670 749 { 671 if (!m_enabled || !m_frontendProvider) { 672 *error = "FileSystem agent is not enabled"; 673 return; 674 } 675 ASSERT(m_frontendProvider->frontend()); 750 if (!assertFrontend(error)) 751 return; 676 752 677 753 ScriptExecutionContext* scriptExecutionContext = assertScriptExecutionContextForOrigin(error, SecurityOrigin::createFromString(url).get()); … … 684 760 long long endPosition = end ? *end : std::numeric_limits<long long>::max(); 685 761 FileContentRequest::create(m_frontendProvider, *requestId, url, readAsText, startPosition, endPosition, charset ? *charset : "")->start(scriptExecutionContext); 762 } 763 764 void InspectorFileSystemAgent::deleteEntry(ErrorString* error, const String& urlString, int* requestId) 765 { 766 if (!assertFrontend(error)) 767 return; 768 769 KURL url(ParsedURLString, urlString); 770 771 ScriptExecutionContext* scriptExecutionContext = assertScriptExecutionContextForOrigin(error, SecurityOrigin::create(url).get()); 772 if (!scriptExecutionContext) 773 return; 774 775 *requestId = m_nextRequestId++; 776 DeleteEntryRequest::create(m_frontendProvider, *requestId, url)->start(scriptExecutionContext); 686 777 } 687 778 … … 719 810 } 720 811 812 bool InspectorFileSystemAgent::assertFrontend(ErrorString* error) 813 { 814 if (!m_enabled || !m_frontendProvider) { 815 *error = "FileSystem agent is not enabled."; 816 return false; 817 } 818 ASSERT(m_frontendProvider->frontend()); 819 return true; 820 } 821 721 822 ScriptExecutionContext* InspectorFileSystemAgent::assertScriptExecutionContextForOrigin(ErrorString* error, SecurityOrigin* origin) 722 823 { -
trunk/Source/WebCore/inspector/InspectorFileSystemAgent.h
r122313 r126273 60 60 virtual void requestMetadata(ErrorString*, const String& url, int* requestId) OVERRIDE; 61 61 virtual void requestFileContent(ErrorString*, const String& url, bool readAsText, const int* start, const int* end, const String* charset, int* requestId) OVERRIDE; 62 virtual void deleteEntry(ErrorString*, const String& url, int* requestId) OVERRIDE; 62 63 63 64 virtual void setFrontend(InspectorFrontend*) OVERRIDE; … … 67 68 private: 68 69 InspectorFileSystemAgent(InstrumentingAgents*, InspectorPageAgent*, InspectorState*); 70 bool assertFrontend(ErrorString*); 69 71 ScriptExecutionContext* assertScriptExecutionContextForOrigin(ErrorString*, SecurityOrigin*); 70 72 -
trunk/Source/WebCore/inspector/front-end/FileSystemModel.js
r122313 r126273 646 646 { 647 647 this._agentWrapper._fileContentReceived(requestId, errorCode, content, charset); 648 }, 649 650 /** 651 * @param {number} requestId 652 * @param {number} errorCode 653 */ 654 deletionCompleted: function(requestId, errorCode) 655 { 656 console.error("Not implemented"); 648 657 } 649 658 }
Note: See TracChangeset
for help on using the changeset viewer.