Changeset 122313 in webkit
- Timestamp:
- Jul 11, 2012 2:04:27 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 6 added
- 6 deleted
- 6 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r122312 r122313 1 2012-07-11 Taiju Tsuiki <tzik@chromium.org> 2 3 Web Inspector: Clean up FileSystem related code 4 https://bugs.webkit.org/show_bug.cgi?id=90592 5 6 Reviewed by Vsevolod Vlasov. 7 8 Clean up FileSystem related code in Inspector as follows: 9 - Clean up layout tests and add test case for error case, 10 - Fix error handling on request, 11 - s/GetFileSystemRootTask/FileSystemRootRequest/g 12 - s/ReadDirectoryTask/DirectoryContentRequest/g 13 - s/ReadFileTask/FileContentRequest/g 14 15 * http/tests/inspector/filesystem/filesystem-test.js: 16 (initialize_FileSystemTest.InspectorTest.dumpFileSystemRootRequestResult): 17 (initialize_FileSystemTest.InspectorTest.dumpDirectoryContentRequestResult): 18 (initialize_FileSystemTest.InspectorTest.dumpMetadataRequestResult): 19 (initialize_FileSystemTest.InspectorTest.dumpFileContentRequestResult): 20 (initialize_FileSystemTest): 21 * http/tests/inspector/filesystem/request-directory-content-expected.txt: Renamed from LayoutTests/http/tests/inspector/filesystem/read-directory-expected.txt. 22 * http/tests/inspector/filesystem/request-directory-content.html: Renamed from LayoutTests/http/tests/inspector/filesystem/read-directory.html. Changed test steps to unnamed function array. Add failcase test. 23 * http/tests/inspector/filesystem/request-file-content-expected.txt: Renamed from LayoutTests/http/tests/inspector/filesystem/read-file-expected.txt. 24 * http/tests/inspector/filesystem/request-file-content.html: Renamed from LayoutTests/http/tests/inspector/filesystem/read-file.html. Changed test steps to unnamed function array. Add failcase test. 25 * http/tests/inspector/filesystem/request-filesystem-root-expected.txt: Renamed from LayoutTests/http/tests/inspector/filesystem/get-filesystem-expected.txt. 26 * http/tests/inspector/filesystem/request-filesystem-root.html: Renamed from LayoutTests/http/tests/inspector/filesystem/get-filesystem-root.html. Changed test steps to unnamed function array. Add failcase test. 27 * http/tests/inspector/filesystem/request-metadata-expected.txt: Renamed from LayoutTests/http/tests/inspector/filesystem/get-metadata-expected.txt. 28 * http/tests/inspector/filesystem/request-metadata.html: Renamed from LayoutTests/http/tests/inspector/filesystem/get-metadata.html. Changed test steps to unnamed function array. Add failcase test. 29 1 30 2012-07-09 Eugene Klyuchnikov <eustas.bug@gmail.com> 2 31 -
trunk/LayoutTests/http/tests/inspector/filesystem/filesystem-test.js
r121542 r122313 71 71 }; 72 72 73 InspectorTest.dumpReadDirectoryResult = function(errorCode, entries) 73 InspectorTest.dumpFileSystemRootRequestResult = function(errorCode, backendRootEntry) 74 { 75 InspectorTest.addResult("errorCode: " + errorCode); 76 if (backendRootEntry) 77 InspectorTest.addResult("backendRootEntry.url: " + backendRootEntry.url); 78 else 79 InspectorTest.addResult("backendRootEntry: (null)"); 80 InspectorTest.addResult(""); 81 }; 82 83 InspectorTest.dumpDirectoryContentRequestResult = function(errorCode, entries) 74 84 { 75 85 InspectorTest.addResult("errorCode: " + errorCode); … … 77 87 if (!entries) { 78 88 InspectorTest.addResult("entries: (null)"); 89 InspectorTest.addResult(""); 79 90 return; 80 91 } … … 86 97 InspectorTest.addResult(" " + j + ": " + entries[i][j]); 87 98 } 99 InspectorTest.addResult(""); 88 100 }; 89 101 … … 98 110 InspectorTest.addResult("metadata: (null)"); 99 111 } 112 InspectorTest.addResult(""); 113 }; 114 115 InspectorTest.dumpFileContentRequestResult = function(errorCode, content, charset) 116 { 117 InspectorTest.addResult("errorCode: " + errorCode); 118 119 if (content) 120 InspectorTest.addResult("content: \"" + content + "\""); 121 else 122 InspectorTest.addResult("content: (null)"); 123 124 InspectorTest.addResult("charset: " + charset); 125 InspectorTest.addResult(""); 100 126 }; 101 127 } -
trunk/LayoutTests/http/tests/inspector/filesystem/request-directory-content-expected.txt
-
Property
svn:eol-style
set to
LF
r122312 r122313 1 Tests re adDirectory.1 Tests requestDirectoryContent command. 2 2 3 3 errorCode: 0 … … 14 14 name: fuga 15 15 isDirectory: true 16 16 17 errorCode: 1 17 18 entries: (null) 18 19 20 errorCode: 2 21 entries: (null) 22 23 All tests have done. 24 -
Property
svn:eol-style
set to
-
trunk/LayoutTests/http/tests/inspector/filesystem/request-metadata-expected.txt
r122312 r122313 1 Tests getMetadata.1 Tests requestMetadata command. 2 2 3 3 errorCode: 0 … … 5 5 modificationTime: (exists) 6 6 size: 4 7 7 8 errorCode: 0 8 9 metadata: … … 10 11 size: 0 11 12 13 errorCode: 1 14 metadata: (null) 15 16 All tests have done. 17 -
trunk/Source/WebCore/ChangeLog
r122312 r122313 1 2012-07-11 Taiju Tsuiki <tzik@chromium.org> 2 3 Web Inspector: Clean up FileSystem related code 4 https://bugs.webkit.org/show_bug.cgi?id=90592 5 6 Reviewed by Vsevolod Vlasov. 7 8 Clean up FileSystem related code in Inspector as follows: 9 - Clean up layout tests and add test case for error case, 10 - Fix error handling on request, 11 - s/GetFileSystemRootTask/FileSystemRootRequest/g 12 - s/ReadDirectoryTask/DirectoryContentRequest/g 13 - s/ReadFileTask/FileContentRequest/g 14 15 Tests: http/tests/inspector/filesystem/request-directory-content.html 16 http/tests/inspector/filesystem/request-file-content.html 17 http/tests/inspector/filesystem/request-filesystem-root.html 18 http/tests/inspector/filesystem/request-metadata.html 19 20 * inspector/InspectorFileSystemAgent.cpp: 21 (WebCore): 22 (WebCore::InspectorFileSystemAgent::requestFileSystemRoot): Add early error handling. 23 (WebCore::InspectorFileSystemAgent::requestDirectoryContent): Add early error handling. 24 (WebCore::InspectorFileSystemAgent::requestMetadata): Add early error handling. 25 (WebCore::InspectorFileSystemAgent::requestFileContent): Add early error handling. 26 * inspector/InspectorFileSystemAgent.h: Remove unused forward declaration and unused header. 27 (WebCore): 28 (InspectorFileSystemAgent): 29 * inspector/front-end/FileSystemModel.js: 30 (WebInspector.FileSystemRequestManager.prototype.requestFileSystemRoot.requestAccepted): 31 (WebInspector.FileSystemRequestManager.prototype.requestFileSystemRoot): Add early error handling. 32 (WebInspector.FileSystemRequestManager.prototype.requestDirectoryContent.requestAccepted): 33 (WebInspector.FileSystemRequestManager.prototype.requestDirectoryContent): Add early error handling. 34 (WebInspector.FileSystemRequestManager.prototype.requestMetadata.requestAccepted): 35 (WebInspector.FileSystemRequestManager.prototype.requestMetadata): Add early error handling. 36 (WebInspector.FileSystemRequestManager.prototype.requestFileContent.requestAccepted): 37 (WebInspector.FileSystemRequestManager.prototype.requestFileContent): Add early error handling. 38 1 39 2012-07-09 Eugene Klyuchnikov <eustas.bug@gmail.com> 2 40 -
trunk/Source/WebCore/inspector/InspectorFileSystemAgent.cpp
r122101 r122313 42 42 #include "Document.h" 43 43 #include "EntriesCallback.h" 44 #include "Entry.h"45 44 #include "EntryArray.h" 46 45 #include "EntryCallback.h" … … 142 141 }; 143 142 144 class GetFileSystemRootTask : public RefCounted<GetFileSystemRootTask> {145 WTF_MAKE_NONCOPYABLE( GetFileSystemRootTask);143 class FileSystemRootRequest : public RefCounted<FileSystemRootRequest> { 144 WTF_MAKE_NONCOPYABLE(FileSystemRootRequest); 146 145 public: 147 static PassRefPtr< GetFileSystemRootTask> create(PassRefPtr<FrontendProvider> frontendProvider, int requestId, const String&type)148 { 149 return adoptRef(new GetFileSystemRootTask(frontendProvider, requestId, type));146 static PassRefPtr<FileSystemRootRequest> create(PassRefPtr<FrontendProvider> frontendProvider, int requestId, FileSystemType type) 147 { 148 return adoptRef(new FileSystemRootRequest(frontendProvider, requestId, type)); 150 149 } 151 150 … … 164 163 } 165 164 166 GetFileSystemRootTask(PassRefPtr<FrontendProvider> frontendProvider, int requestId, const String&type)165 FileSystemRootRequest(PassRefPtr<FrontendProvider> frontendProvider, int requestId, FileSystemType type) 167 166 : m_frontendProvider(frontendProvider) 168 167 , m_requestId(requestId) … … 171 170 RefPtr<FrontendProvider> m_frontendProvider; 172 171 int m_requestId; 173 Stringm_type;172 FileSystemType m_type; 174 173 }; 175 174 176 bool GetFileSystemRootTask::didHitError(FileError* error)175 bool FileSystemRootRequest::didHitError(FileError* error) 177 176 { 178 177 reportResult(error->code(), 0); … … 180 179 } 181 180 182 void GetFileSystemRootTask::start(ScriptExecutionContext* scriptExecutionContext) 183 { 184 FileSystemType type; 185 if (m_type == DOMFileSystemBase::persistentPathPrefix) 186 type = FileSystemTypePersistent; 187 else if (m_type == DOMFileSystemBase::temporaryPathPrefix) 188 type = FileSystemTypeTemporary; 189 else { 190 reportResult(FileError::SYNTAX_ERR, 0); 191 return; 192 } 193 194 RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallback>::create(this, &GetFileSystemRootTask::didGetEntry); 195 RefPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallback>::create(this, &GetFileSystemRootTask::didHitError); 196 OwnPtr<ResolveURICallbacks> fileSystemCallbacks = ResolveURICallbacks::create(successCallback, errorCallback, scriptExecutionContext, type, "/"); 197 198 LocalFileSystem::localFileSystem().readFileSystem(scriptExecutionContext, type, fileSystemCallbacks.release()); 199 } 200 201 bool GetFileSystemRootTask::didGetEntry(Entry* entry) 202 { 203 RefPtr<TypeBuilder::FileSystem::Entry> result(TypeBuilder::FileSystem::Entry::create().setUrl(entry->toURL()).setName("/").setIsDirectory(true)); 181 void FileSystemRootRequest::start(ScriptExecutionContext* scriptExecutionContext) 182 { 183 RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallback>::create(this, &FileSystemRootRequest::didGetEntry); 184 RefPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallback>::create(this, &FileSystemRootRequest::didHitError); 185 OwnPtr<ResolveURICallbacks> fileSystemCallbacks = ResolveURICallbacks::create(successCallback, errorCallback, scriptExecutionContext, m_type, "/"); 186 187 LocalFileSystem::localFileSystem().readFileSystem(scriptExecutionContext, m_type, fileSystemCallbacks.release()); 188 } 189 190 bool FileSystemRootRequest::didGetEntry(Entry* entry) 191 { 192 RefPtr<TypeBuilder::FileSystem::Entry> result = TypeBuilder::FileSystem::Entry::create() 193 .setUrl(entry->toURL()) 194 .setName("/") 195 .setIsDirectory(true); 204 196 reportResult(static_cast<FileError::ErrorCode>(0), result); 205 197 return true; 206 198 } 207 199 208 class ReadDirectoryTask : public RefCounted<ReadDirectoryTask> {209 WTF_MAKE_NONCOPYABLE( ReadDirectoryTask);200 class DirectoryContentRequest : public RefCounted<DirectoryContentRequest> { 201 WTF_MAKE_NONCOPYABLE(DirectoryContentRequest); 210 202 public: 211 static PassRefPtr< ReadDirectoryTask> create(PassRefPtr<FrontendProvider> frontendProvider, int requestId, const String& url)212 { 213 return adoptRef(new ReadDirectoryTask(frontendProvider, requestId, url));214 } 215 216 virtual ~ ReadDirectoryTask()203 static PassRefPtr<DirectoryContentRequest> create(PassRefPtr<FrontendProvider> frontendProvider, int requestId, const String& url) 204 { 205 return adoptRef(new DirectoryContentRequest(frontendProvider, requestId, url)); 206 } 207 208 virtual ~DirectoryContentRequest() 217 209 { 218 210 reportResult(FileError::ABORT_ERR, 0); … … 239 231 } 240 232 241 ReadDirectoryTask(PassRefPtr<FrontendProvider> frontendProvider, int requestId, const String& url)233 DirectoryContentRequest(PassRefPtr<FrontendProvider> frontendProvider, int requestId, const String& url) 242 234 : m_frontendProvider(frontendProvider) 243 235 , m_requestId(requestId) … … 253 245 }; 254 246 255 void ReadDirectoryTask::start(ScriptExecutionContext* scriptExecutionContext)247 void DirectoryContentRequest::start(ScriptExecutionContext* scriptExecutionContext) 256 248 { 257 249 ASSERT(scriptExecutionContext); … … 264 256 } 265 257 266 RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallback>::create(this, & ReadDirectoryTask::didGetEntry);267 RefPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallback>::create(this, & ReadDirectoryTask::didHitError);258 RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallback>::create(this, &DirectoryContentRequest::didGetEntry); 259 RefPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallback>::create(this, &DirectoryContentRequest::didHitError); 268 260 OwnPtr<ResolveURICallbacks> fileSystemCallbacks = ResolveURICallbacks::create(successCallback, errorCallback, scriptExecutionContext, type, path); 269 261 … … 271 263 } 272 264 273 bool ReadDirectoryTask::didGetEntry(Entry* entry)265 bool DirectoryContentRequest::didGetEntry(Entry* entry) 274 266 { 275 267 if (!entry->isDirectory()) { … … 284 276 } 285 277 286 void ReadDirectoryTask::readDirectoryEntries()278 void DirectoryContentRequest::readDirectoryEntries() 287 279 { 288 280 if (!m_directoryReader->filesystem()->scriptExecutionContext()) { … … 291 283 } 292 284 293 RefPtr<EntriesCallback> successCallback = CallbackDispatcherFactory<EntriesCallback>::create(this, & ReadDirectoryTask::didReadDirectoryEntries);294 RefPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallback>::create(this, & ReadDirectoryTask::didHitError);285 RefPtr<EntriesCallback> successCallback = CallbackDispatcherFactory<EntriesCallback>::create(this, &DirectoryContentRequest::didReadDirectoryEntries); 286 RefPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallback>::create(this, &DirectoryContentRequest::didHitError); 295 287 m_directoryReader->readEntries(successCallback, errorCallback); 296 288 } 297 289 298 bool ReadDirectoryTask::didReadDirectoryEntries(EntryArray* entries)290 bool DirectoryContentRequest::didReadDirectoryEntries(EntryArray* entries) 299 291 { 300 292 if (!entries->length()) { … … 305 297 for (unsigned i = 0; i < entries->length(); ++i) { 306 298 Entry* entry = entries->item(i); 307 RefPtr<TypeBuilder::FileSystem::Entry> entryForFrontend = TypeBuilder::FileSystem::Entry::create().setUrl(entry->toURL()).setName(entry->name()).setIsDirectory(entry->isDirectory()); 299 RefPtr<TypeBuilder::FileSystem::Entry> entryForFrontend = TypeBuilder::FileSystem::Entry::create() 300 .setUrl(entry->toURL()) 301 .setName(entry->name()) 302 .setIsDirectory(entry->isDirectory()); 308 303 309 304 using TypeBuilder::Page::ResourceType; … … 335 330 } 336 331 337 class GetMetadataTask : public RefCounted<GetMetadataTask> {338 WTF_MAKE_NONCOPYABLE( GetMetadataTask);332 class MetadataRequest : public RefCounted<MetadataRequest> { 333 WTF_MAKE_NONCOPYABLE(MetadataRequest); 339 334 public: 340 static PassRefPtr< GetMetadataTask> create(PassRefPtr<FrontendProvider> frontendProvider, int requestId, const String& url)341 { 342 return adoptRef(new GetMetadataTask(frontendProvider, requestId, url));343 } 344 345 virtual ~ GetMetadataTask()335 static PassRefPtr<MetadataRequest> create(PassRefPtr<FrontendProvider> frontendProvider, int requestId, const String& url) 336 { 337 return adoptRef(new MetadataRequest(frontendProvider, requestId, url)); 338 } 339 340 virtual ~MetadataRequest() 346 341 { 347 342 reportResult(FileError::ABORT_ERR, 0); … … 367 362 368 363 private: 369 GetMetadataTask(PassRefPtr<FrontendProvider> frontendProvider, int requestId, const String& url)364 MetadataRequest(PassRefPtr<FrontendProvider> frontendProvider, int requestId, const String& url) 370 365 : m_frontendProvider(frontendProvider) 371 366 , m_requestId(requestId) … … 379 374 }; 380 375 381 void GetMetadataTask::start(ScriptExecutionContext* scriptExecutionContext)376 void MetadataRequest::start(ScriptExecutionContext* scriptExecutionContext) 382 377 { 383 378 FileSystemType type; 384 379 DOMFileSystemBase::crackFileSystemURL(m_url, type, m_path); 385 380 386 RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallback>::create(this, & GetMetadataTask::didGetEntry);387 RefPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallback>::create(this, & GetMetadataTask::didHitError);381 RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallback>::create(this, &MetadataRequest::didGetEntry); 382 RefPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallback>::create(this, &MetadataRequest::didHitError); 388 383 389 384 OwnPtr<ResolveURICallbacks> fileSystemCallbacks = ResolveURICallbacks::create(successCallback, errorCallback, scriptExecutionContext, type, m_path); … … 391 386 } 392 387 393 bool GetMetadataTask::didGetEntry(Entry* entry)388 bool MetadataRequest::didGetEntry(Entry* entry) 394 389 { 395 390 if (!entry->filesystem()->scriptExecutionContext()) { … … 398 393 } 399 394 400 RefPtr<MetadataCallback> successCallback = CallbackDispatcherFactory<MetadataCallback>::create(this, & GetMetadataTask::didGetMetadata);401 RefPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallback>::create(this, & GetMetadataTask::didHitError);395 RefPtr<MetadataCallback> successCallback = CallbackDispatcherFactory<MetadataCallback>::create(this, &MetadataRequest::didGetMetadata); 396 RefPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallback>::create(this, &MetadataRequest::didHitError); 402 397 entry->getMetadata(successCallback, errorCallback); 403 398 m_isDirectory = entry->isDirectory(); … … 405 400 } 406 401 407 bool GetMetadataTask::didGetMetadata(Metadata* metadata)402 bool MetadataRequest::didGetMetadata(Metadata* metadata) 408 403 { 409 404 using TypeBuilder::FileSystem::Metadata; 410 RefPtr<Metadata> result = Metadata::create().setModificationTime(metadata->modificationTime()).setSize(metadata->size()); 405 RefPtr<Metadata> result = Metadata::create() 406 .setModificationTime(metadata->modificationTime()) 407 .setSize(metadata->size()); 411 408 reportResult(static_cast<FileError::ErrorCode>(0), result); 412 409 return true; 413 410 } 414 411 415 class ReadFileTask: public EventListener {416 WTF_MAKE_NONCOPYABLE( ReadFileTask);412 class FileContentRequest : public EventListener { 413 WTF_MAKE_NONCOPYABLE(FileContentRequest); 417 414 public: 418 static PassRefPtr< ReadFileTask> create(PassRefPtr<FrontendProvider> frontendProvider, int requestId, const String& url, bool readAsText, long long start, long long end, const String& charset)419 { 420 return adoptRef(new ReadFileTask(frontendProvider, requestId, url, readAsText, start, end, charset));421 } 422 423 virtual ~ ReadFileTask()415 static PassRefPtr<FileContentRequest> create(PassRefPtr<FrontendProvider> frontendProvider, int requestId, const String& url, bool readAsText, long long start, long long end, const String& charset) 416 { 417 return adoptRef(new FileContentRequest(frontendProvider, requestId, url, readAsText, start, end, charset)); 418 } 419 420 virtual ~FileContentRequest() 424 421 { 425 422 reportResult(FileError::ABORT_ERR, 0, 0); … … 461 458 } 462 459 463 ReadFileTask(PassRefPtr<FrontendProvider> frontendProvider, int requestId, const String& url, bool readAsText, long long start, long long end, const String& charset)460 FileContentRequest(PassRefPtr<FrontendProvider> frontendProvider, int requestId, const String& url, bool readAsText, long long start, long long end, const String& charset) 464 461 : EventListener(EventListener::CPPEventListenerType) 465 462 , m_frontendProvider(frontendProvider) … … 483 480 }; 484 481 485 void ReadFileTask::start(ScriptExecutionContext* scriptExecutionContext)482 void FileContentRequest::start(ScriptExecutionContext* scriptExecutionContext) 486 483 { 487 484 ASSERT(scriptExecutionContext); … … 494 491 } 495 492 496 RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallback>::create(this, & ReadFileTask::didGetEntry);497 RefPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallback>::create(this, & ReadFileTask::didHitError);493 RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallback>::create(this, &FileContentRequest::didGetEntry); 494 RefPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallback>::create(this, &FileContentRequest::didHitError); 498 495 OwnPtr<ResolveURICallbacks> fileSystemCallbacks = ResolveURICallbacks::create(successCallback, errorCallback, scriptExecutionContext, type, path); 499 496 … … 501 498 } 502 499 503 bool ReadFileTask::didGetEntry(Entry* entry)500 bool FileContentRequest::didGetEntry(Entry* entry) 504 501 { 505 502 if (entry->isDirectory()) { … … 513 510 } 514 511 515 RefPtr<FileCallback> successCallback = CallbackDispatcherFactory<FileCallback>::create(this, & ReadFileTask::didGetFile);516 RefPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallback>::create(this, & ReadFileTask::didHitError);512 RefPtr<FileCallback> successCallback = CallbackDispatcherFactory<FileCallback>::create(this, &FileContentRequest::didGetFile); 513 RefPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallback>::create(this, &FileContentRequest::didHitError); 517 514 static_cast<FileEntry*>(entry)->file(successCallback, errorCallback); 518 515 … … 523 520 } 524 521 525 bool ReadFileTask::didGetFile(File* file)522 bool FileContentRequest::didGetFile(File* file) 526 523 { 527 524 RefPtr<Blob> blob = file->slice(m_start, m_end); … … 534 531 } 535 532 536 void ReadFileTask::didRead()533 void FileContentRequest::didRead() 537 534 { 538 535 RefPtr<ArrayBuffer> buffer = m_reader->arrayBufferResult(); … … 582 579 } 583 580 584 void InspectorFileSystemAgent::requestFileSystemRoot(ErrorString* error, const String& origin, const String& type , int* requestId)581 void InspectorFileSystemAgent::requestFileSystemRoot(ErrorString* error, const String& origin, const String& typeString, int* requestId) 585 582 { 586 583 if (!m_enabled || !m_frontendProvider) { … … 590 587 ASSERT(m_frontendProvider->frontend()); 591 588 589 ScriptExecutionContext* scriptExecutionContext = assertScriptExecutionContextForOrigin(error, SecurityOrigin::createFromString(origin).get()); 590 if (!scriptExecutionContext) 591 return; 592 593 FileSystemType type; 594 if (typeString == DOMFileSystemBase::persistentPathPrefix) 595 type = FileSystemTypePersistent; 596 else if (typeString == DOMFileSystemBase::temporaryPathPrefix) 597 type = FileSystemTypeTemporary; 598 else { 599 *error = "Invalid FileSystem type"; 600 return; 601 } 602 592 603 *requestId = m_nextRequestId++; 593 if (ScriptExecutionContext* scriptExecutionContext = scriptExecutionContextForOrigin(SecurityOrigin::createFromString(origin).get())) 594 GetFileSystemRootTask::create(m_frontendProvider, *requestId, type)->start(scriptExecutionContext); 595 else 596 m_frontendProvider->frontend()->fileSystemRootReceived(*requestId, static_cast<int>(FileError::ABORT_ERR), 0); 604 FileSystemRootRequest::create(m_frontendProvider, *requestId, type)->start(scriptExecutionContext); 597 605 } 598 606 … … 605 613 ASSERT(m_frontendProvider->frontend()); 606 614 615 ScriptExecutionContext* scriptExecutionContext = assertScriptExecutionContextForOrigin(error, SecurityOrigin::createFromString(url).get()); 616 if (!scriptExecutionContext) 617 return; 618 607 619 *requestId = m_nextRequestId++; 608 609 if (ScriptExecutionContext* scriptExecutionContext = scriptExecutionContextForOrigin(SecurityOrigin::createFromString(url).get())) 610 ReadDirectoryTask::create(m_frontendProvider, *requestId, url)->start(scriptExecutionContext); 611 else 612 m_frontendProvider->frontend()->directoryContentReceived(*requestId, static_cast<int>(FileError::ABORT_ERR), 0); 620 DirectoryContentRequest::create(m_frontendProvider, *requestId, url)->start(scriptExecutionContext); 613 621 } 614 622 … … 621 629 ASSERT(m_frontendProvider->frontend()); 622 630 631 ScriptExecutionContext* scriptExecutionContext = assertScriptExecutionContextForOrigin(error, SecurityOrigin::createFromString(url).get()); 632 if (!scriptExecutionContext) 633 return; 634 623 635 *requestId = m_nextRequestId++; 624 625 if (ScriptExecutionContext* scriptExecutionContext = scriptExecutionContextForOrigin(SecurityOrigin::createFromString(url).get())) 626 GetMetadataTask::create(m_frontendProvider, *requestId, url)->start(scriptExecutionContext); 627 else 628 m_frontendProvider->frontend()->metadataReceived(*requestId, static_cast<int>(FileError::ABORT_ERR), 0); 636 MetadataRequest::create(m_frontendProvider, *requestId, url)->start(scriptExecutionContext); 629 637 } 630 638 … … 637 645 ASSERT(m_frontendProvider->frontend()); 638 646 647 ScriptExecutionContext* scriptExecutionContext = assertScriptExecutionContextForOrigin(error, SecurityOrigin::createFromString(url).get()); 648 if (!scriptExecutionContext) 649 return; 650 639 651 *requestId = m_nextRequestId++; 640 652 641 if (ScriptExecutionContext* scriptExecutionContext = scriptExecutionContextForOrigin(SecurityOrigin::createFromString(url).get())) 642 ReadFileTask::create(m_frontendProvider, *requestId, url, readAsText, start ? *start : 0, end ? *end : std::numeric_limits<long long>::max(), charset ? *charset : "")->start(scriptExecutionContext); 643 else 644 m_frontendProvider->frontend()->fileContentReceived(*requestId, static_cast<int>(FileError::ABORT_ERR), 0, 0); 653 long long startPosition = start ? *start : 0; 654 long long endPosition = end ? *end : std::numeric_limits<long long>::max(); 655 FileContentRequest::create(m_frontendProvider, *requestId, url, readAsText, startPosition, endPosition, charset ? *charset : "")->start(scriptExecutionContext); 645 656 } 646 657 … … 678 689 } 679 690 680 ScriptExecutionContext* InspectorFileSystemAgent:: scriptExecutionContextForOrigin(SecurityOrigin* origin)691 ScriptExecutionContext* InspectorFileSystemAgent::assertScriptExecutionContextForOrigin(ErrorString* error, SecurityOrigin* origin) 681 692 { 682 693 for (Frame* frame = m_pageAgent->mainFrame(); frame; frame = frame->tree()->traverseNext()) { … … 684 695 return frame->document(); 685 696 } 697 698 *error = "No frame is available for the request"; 686 699 return 0; 687 700 } -
trunk/Source/WebCore/inspector/InspectorFileSystemAgent.h
r122101 r122313 35 35 36 36 #include "InspectorBaseAgent.h" 37 #include "InspectorFrontend.h"38 37 39 38 #include <wtf/PassOwnPtr.h> … … 42 41 namespace WebCore { 43 42 44 class DOMFileSystem;45 43 class InspectorFrontend; 46 44 class InspectorPageAgent; 47 class InspectorState;48 class InstrumentingAgents;49 45 class ScriptExecutionContext; 50 46 class SecurityOrigin; … … 60 56 virtual void disable(ErrorString*) OVERRIDE; 61 57 62 virtual void requestFileSystemRoot(ErrorString*, const String& origin, const String& type , int* requestId) OVERRIDE;58 virtual void requestFileSystemRoot(ErrorString*, const String& origin, const String& typeString, int* requestId) OVERRIDE; 63 59 virtual void requestDirectoryContent(ErrorString*, const String& url, int* requestId) OVERRIDE; 64 60 virtual void requestMetadata(ErrorString*, const String& url, int* requestId) OVERRIDE; … … 71 67 private: 72 68 InspectorFileSystemAgent(InstrumentingAgents*, InspectorPageAgent*, InspectorState*); 73 ScriptExecutionContext* scriptExecutionContextForOrigin(SecurityOrigin*);69 ScriptExecutionContext* assertScriptExecutionContextForOrigin(ErrorString*, SecurityOrigin*); 74 70 75 71 InspectorPageAgent* m_pageAgent; -
trunk/Source/WebCore/inspector/front-end/FileSystemModel.js
r122101 r122313 469 469 * @param {string} origin 470 470 * @param {string} type 471 * @param {function(number, FileSystemAgent.Entry )=} callback471 * @param {function(number, FileSystemAgent.Entry=)=} callback 472 472 */ 473 473 requestFileSystemRoot: function(origin, type, callback) … … 478 478 function requestAccepted(error, requestId) 479 479 { 480 if (!error) 480 if (error) 481 callback(FileError.SECURITY_ERR); 482 else 481 483 store[requestId] = callback || function() {}; 482 484 } … … 508 510 function requestAccepted(error, requestId) 509 511 { 510 if (!error) 512 if (error) 513 callback(FileError.SECURITY_ERR); 514 else 511 515 store[requestId] = callback || function() {}; 512 516 } … … 538 542 function requestAccepted(error, requestId) 539 543 { 540 if (!error) 544 if (error) 545 callback(FileError.SECURITY_ERR); 546 else 541 547 store[requestId] = callback || function() {}; 542 548 } … … 567 573 function requestAccepted(error, requestId) 568 574 { 569 if (!error) 575 if (error) 576 callback(FileError.SECURITY_ERR); 577 else 570 578 store[requestId] = callback || function() {}; 571 579 }
Note: See TracChangeset
for help on using the changeset viewer.