Changeset 122313 in webkit


Ignore:
Timestamp:
Jul 11, 2012 2:04:27 AM (12 years ago)
Author:
kinuko@chromium.org
Message:

Web Inspector: Clean up FileSystem related code
https://bugs.webkit.org/show_bug.cgi?id=90592

Patch by Taiju Tsuiki <tzik@chromium.org> on 2012-07-11
Reviewed by Vsevolod Vlasov.

Clean up FileSystem related code in Inspector as follows:

  • Clean up layout tests and add test case for error case,
  • Fix error handling on request,
  • s/GetFileSystemRootTask/FileSystemRootRequest/g
  • s/ReadDirectoryTask/DirectoryContentRequest/g
  • s/ReadFileTask/FileContentRequest/g

Source/WebCore:

Tests: http/tests/inspector/filesystem/request-directory-content.html

http/tests/inspector/filesystem/request-file-content.html
http/tests/inspector/filesystem/request-filesystem-root.html
http/tests/inspector/filesystem/request-metadata.html

  • inspector/InspectorFileSystemAgent.cpp:

(WebCore):
(WebCore::InspectorFileSystemAgent::requestFileSystemRoot): Add early error handling.
(WebCore::InspectorFileSystemAgent::requestDirectoryContent): Add early error handling.
(WebCore::InspectorFileSystemAgent::requestMetadata): Add early error handling.
(WebCore::InspectorFileSystemAgent::requestFileContent): Add early error handling.

  • inspector/InspectorFileSystemAgent.h: Remove unused forward declaration and unused header.

(WebCore):
(InspectorFileSystemAgent):

  • inspector/front-end/FileSystemModel.js:

(WebInspector.FileSystemRequestManager.prototype.requestFileSystemRoot.requestAccepted):
(WebInspector.FileSystemRequestManager.prototype.requestFileSystemRoot): Add early error handling.
(WebInspector.FileSystemRequestManager.prototype.requestDirectoryContent.requestAccepted):
(WebInspector.FileSystemRequestManager.prototype.requestDirectoryContent): Add early error handling.
(WebInspector.FileSystemRequestManager.prototype.requestMetadata.requestAccepted):
(WebInspector.FileSystemRequestManager.prototype.requestMetadata): Add early error handling.
(WebInspector.FileSystemRequestManager.prototype.requestFileContent.requestAccepted):
(WebInspector.FileSystemRequestManager.prototype.requestFileContent): Add early error handling.

LayoutTests:

  • http/tests/inspector/filesystem/filesystem-test.js:

(initialize_FileSystemTest.InspectorTest.dumpFileSystemRootRequestResult):
(initialize_FileSystemTest.InspectorTest.dumpDirectoryContentRequestResult):
(initialize_FileSystemTest.InspectorTest.dumpMetadataRequestResult):
(initialize_FileSystemTest.InspectorTest.dumpFileContentRequestResult):
(initialize_FileSystemTest):

  • http/tests/inspector/filesystem/request-directory-content-expected.txt: Renamed from LayoutTests/http/tests/inspector/filesystem/read-directory-expected.txt.
  • 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.
  • http/tests/inspector/filesystem/request-file-content-expected.txt: Renamed from LayoutTests/http/tests/inspector/filesystem/read-file-expected.txt.
  • 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.
  • http/tests/inspector/filesystem/request-filesystem-root-expected.txt: Renamed from LayoutTests/http/tests/inspector/filesystem/get-filesystem-expected.txt.
  • 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.
  • http/tests/inspector/filesystem/request-metadata-expected.txt: Renamed from LayoutTests/http/tests/inspector/filesystem/get-metadata-expected.txt.
  • 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.
Location:
trunk
Files:
6 added
6 deleted
6 edited
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r122312 r122313  
     12012-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
    1302012-07-09  Eugene Klyuchnikov  <eustas.bug@gmail.com>
    231
  • trunk/LayoutTests/http/tests/inspector/filesystem/filesystem-test.js

    r121542 r122313  
    7171    };
    7272
    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)
    7484    {
    7585        InspectorTest.addResult("errorCode: " + errorCode);
     
    7787        if (!entries) {
    7888            InspectorTest.addResult("entries: (null)");
     89            InspectorTest.addResult("");
    7990            return;
    8091        }
     
    8697            InspectorTest.addResult("    " + j + ": " + entries[i][j]);
    8798        }
     99        InspectorTest.addResult("");
    88100    };
    89101
     
    98110            InspectorTest.addResult("metadata: (null)");
    99111        }
     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("");
    100126    };
    101127}
  • trunk/LayoutTests/http/tests/inspector/filesystem/request-directory-content-expected.txt

    • Property svn:eol-style set to LF
    r122312 r122313  
    1 Tests readDirectory.
     1Tests requestDirectoryContent command.
    22
    33errorCode: 0
     
    1414    name: fuga
    1515    isDirectory: true
     16
    1617errorCode: 1
    1718entries: (null)
    1819
     20errorCode: 2
     21entries: (null)
     22
     23All tests have done.
     24
  • trunk/LayoutTests/http/tests/inspector/filesystem/request-metadata-expected.txt

    r122312 r122313  
    1 Tests getMetadata.
     1Tests requestMetadata command.
    22
    33errorCode: 0
     
    55  modificationTime: (exists)
    66  size: 4
     7
    78errorCode: 0
    89metadata:
     
    1011  size: 0
    1112
     13errorCode: 1
     14metadata: (null)
     15
     16All tests have done.
     17
  • trunk/Source/WebCore/ChangeLog

    r122312 r122313  
     12012-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
    1392012-07-09  Eugene Klyuchnikov  <eustas.bug@gmail.com>
    240
  • trunk/Source/WebCore/inspector/InspectorFileSystemAgent.cpp

    r122101 r122313  
    4242#include "Document.h"
    4343#include "EntriesCallback.h"
    44 #include "Entry.h"
    4544#include "EntryArray.h"
    4645#include "EntryCallback.h"
     
    142141};
    143142
    144 class GetFileSystemRootTask : public RefCounted<GetFileSystemRootTask> {
    145     WTF_MAKE_NONCOPYABLE(GetFileSystemRootTask);
     143class FileSystemRootRequest : public RefCounted<FileSystemRootRequest> {
     144    WTF_MAKE_NONCOPYABLE(FileSystemRootRequest);
    146145public:
    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));
    150149    }
    151150
     
    164163    }
    165164
    166     GetFileSystemRootTask(PassRefPtr<FrontendProvider> frontendProvider, int requestId, const String& type)
     165    FileSystemRootRequest(PassRefPtr<FrontendProvider> frontendProvider, int requestId, FileSystemType type)
    167166        : m_frontendProvider(frontendProvider)
    168167        , m_requestId(requestId)
     
    171170    RefPtr<FrontendProvider> m_frontendProvider;
    172171    int m_requestId;
    173     String m_type;
     172    FileSystemType m_type;
    174173};
    175174
    176 bool GetFileSystemRootTask::didHitError(FileError* error)
     175bool FileSystemRootRequest::didHitError(FileError* error)
    177176{
    178177    reportResult(error->code(), 0);
     
    180179}
    181180
    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));
     181void 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
     190bool FileSystemRootRequest::didGetEntry(Entry* entry)
     191{
     192    RefPtr<TypeBuilder::FileSystem::Entry> result = TypeBuilder::FileSystem::Entry::create()
     193        .setUrl(entry->toURL())
     194        .setName("/")
     195        .setIsDirectory(true);
    204196    reportResult(static_cast<FileError::ErrorCode>(0), result);
    205197    return true;
    206198}
    207199
    208 class ReadDirectoryTask : public RefCounted<ReadDirectoryTask> {
    209     WTF_MAKE_NONCOPYABLE(ReadDirectoryTask);
     200class DirectoryContentRequest : public RefCounted<DirectoryContentRequest> {
     201    WTF_MAKE_NONCOPYABLE(DirectoryContentRequest);
    210202public:
    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()
    217209    {
    218210        reportResult(FileError::ABORT_ERR, 0);
     
    239231    }
    240232
    241     ReadDirectoryTask(PassRefPtr<FrontendProvider> frontendProvider, int requestId, const String& url)
     233    DirectoryContentRequest(PassRefPtr<FrontendProvider> frontendProvider, int requestId, const String& url)
    242234        : m_frontendProvider(frontendProvider)
    243235        , m_requestId(requestId)
     
    253245};
    254246
    255 void ReadDirectoryTask::start(ScriptExecutionContext* scriptExecutionContext)
     247void DirectoryContentRequest::start(ScriptExecutionContext* scriptExecutionContext)
    256248{
    257249    ASSERT(scriptExecutionContext);
     
    264256    }
    265257
    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);
    268260    OwnPtr<ResolveURICallbacks> fileSystemCallbacks = ResolveURICallbacks::create(successCallback, errorCallback, scriptExecutionContext, type, path);
    269261
     
    271263}
    272264
    273 bool ReadDirectoryTask::didGetEntry(Entry* entry)
     265bool DirectoryContentRequest::didGetEntry(Entry* entry)
    274266{
    275267    if (!entry->isDirectory()) {
     
    284276}
    285277
    286 void ReadDirectoryTask::readDirectoryEntries()
     278void DirectoryContentRequest::readDirectoryEntries()
    287279{
    288280    if (!m_directoryReader->filesystem()->scriptExecutionContext()) {
     
    291283    }
    292284
    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);
    295287    m_directoryReader->readEntries(successCallback, errorCallback);
    296288}
    297289
    298 bool ReadDirectoryTask::didReadDirectoryEntries(EntryArray* entries)
     290bool DirectoryContentRequest::didReadDirectoryEntries(EntryArray* entries)
    299291{
    300292    if (!entries->length()) {
     
    305297    for (unsigned i = 0; i < entries->length(); ++i) {
    306298        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());
    308303
    309304        using TypeBuilder::Page::ResourceType;
     
    335330}
    336331
    337 class GetMetadataTask : public RefCounted<GetMetadataTask> {
    338     WTF_MAKE_NONCOPYABLE(GetMetadataTask);
     332class MetadataRequest : public RefCounted<MetadataRequest> {
     333    WTF_MAKE_NONCOPYABLE(MetadataRequest);
    339334public:
    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()
    346341    {
    347342        reportResult(FileError::ABORT_ERR, 0);
     
    367362
    368363private:
    369     GetMetadataTask(PassRefPtr<FrontendProvider> frontendProvider, int requestId, const String& url)
     364    MetadataRequest(PassRefPtr<FrontendProvider> frontendProvider, int requestId, const String& url)
    370365        : m_frontendProvider(frontendProvider)
    371366        , m_requestId(requestId)
     
    379374};
    380375
    381 void GetMetadataTask::start(ScriptExecutionContext* scriptExecutionContext)
     376void MetadataRequest::start(ScriptExecutionContext* scriptExecutionContext)
    382377{
    383378    FileSystemType type;
    384379    DOMFileSystemBase::crackFileSystemURL(m_url, type, m_path);
    385380
    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);
    388383
    389384    OwnPtr<ResolveURICallbacks> fileSystemCallbacks = ResolveURICallbacks::create(successCallback, errorCallback, scriptExecutionContext, type, m_path);
     
    391386}
    392387
    393 bool GetMetadataTask::didGetEntry(Entry* entry)
     388bool MetadataRequest::didGetEntry(Entry* entry)
    394389{
    395390    if (!entry->filesystem()->scriptExecutionContext()) {
     
    398393    }
    399394
    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);
    402397    entry->getMetadata(successCallback, errorCallback);
    403398    m_isDirectory = entry->isDirectory();
     
    405400}
    406401
    407 bool GetMetadataTask::didGetMetadata(Metadata* metadata)
     402bool MetadataRequest::didGetMetadata(Metadata* metadata)
    408403{
    409404    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());
    411408    reportResult(static_cast<FileError::ErrorCode>(0), result);
    412409    return true;
    413410}
    414411
    415 class ReadFileTask : public EventListener {
    416     WTF_MAKE_NONCOPYABLE(ReadFileTask);
     412class FileContentRequest : public EventListener {
     413    WTF_MAKE_NONCOPYABLE(FileContentRequest);
    417414public:
    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()
    424421    {
    425422        reportResult(FileError::ABORT_ERR, 0, 0);
     
    461458    }
    462459
    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)
    464461        : EventListener(EventListener::CPPEventListenerType)
    465462        , m_frontendProvider(frontendProvider)
     
    483480};
    484481
    485 void ReadFileTask::start(ScriptExecutionContext* scriptExecutionContext)
     482void FileContentRequest::start(ScriptExecutionContext* scriptExecutionContext)
    486483{
    487484    ASSERT(scriptExecutionContext);
     
    494491    }
    495492
    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);
    498495    OwnPtr<ResolveURICallbacks> fileSystemCallbacks = ResolveURICallbacks::create(successCallback, errorCallback, scriptExecutionContext, type, path);
    499496
     
    501498}
    502499
    503 bool ReadFileTask::didGetEntry(Entry* entry)
     500bool FileContentRequest::didGetEntry(Entry* entry)
    504501{
    505502    if (entry->isDirectory()) {
     
    513510    }
    514511
    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);
    517514    static_cast<FileEntry*>(entry)->file(successCallback, errorCallback);
    518515
     
    523520}
    524521
    525 bool ReadFileTask::didGetFile(File* file)
     522bool FileContentRequest::didGetFile(File* file)
    526523{
    527524    RefPtr<Blob> blob = file->slice(m_start, m_end);
     
    534531}
    535532
    536 void ReadFileTask::didRead()
     533void FileContentRequest::didRead()
    537534{
    538535    RefPtr<ArrayBuffer> buffer = m_reader->arrayBufferResult();
     
    582579}
    583580
    584 void InspectorFileSystemAgent::requestFileSystemRoot(ErrorString* error, const String& origin, const String& type, int* requestId)
     581void InspectorFileSystemAgent::requestFileSystemRoot(ErrorString* error, const String& origin, const String& typeString, int* requestId)
    585582{
    586583    if (!m_enabled || !m_frontendProvider) {
     
    590587    ASSERT(m_frontendProvider->frontend());
    591588
     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
    592603    *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);
    597605}
    598606
     
    605613    ASSERT(m_frontendProvider->frontend());
    606614
     615    ScriptExecutionContext* scriptExecutionContext = assertScriptExecutionContextForOrigin(error, SecurityOrigin::createFromString(url).get());
     616    if (!scriptExecutionContext)
     617        return;
     618
    607619    *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);
    613621}
    614622
     
    621629    ASSERT(m_frontendProvider->frontend());
    622630
     631    ScriptExecutionContext* scriptExecutionContext = assertScriptExecutionContextForOrigin(error, SecurityOrigin::createFromString(url).get());
     632    if (!scriptExecutionContext)
     633        return;
     634
    623635    *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);
    629637}
    630638
     
    637645    ASSERT(m_frontendProvider->frontend());
    638646
     647    ScriptExecutionContext* scriptExecutionContext = assertScriptExecutionContextForOrigin(error, SecurityOrigin::createFromString(url).get());
     648    if (!scriptExecutionContext)
     649        return;
     650
    639651    *requestId = m_nextRequestId++;
    640652
    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);
    645656}
    646657
     
    678689}
    679690
    680 ScriptExecutionContext* InspectorFileSystemAgent::scriptExecutionContextForOrigin(SecurityOrigin* origin)
     691ScriptExecutionContext* InspectorFileSystemAgent::assertScriptExecutionContextForOrigin(ErrorString* error, SecurityOrigin* origin)
    681692{
    682693    for (Frame* frame = m_pageAgent->mainFrame(); frame; frame = frame->tree()->traverseNext()) {
     
    684695            return frame->document();
    685696    }
     697
     698    *error = "No frame is available for the request";
    686699    return 0;
    687700}
  • trunk/Source/WebCore/inspector/InspectorFileSystemAgent.h

    r122101 r122313  
    3535
    3636#include "InspectorBaseAgent.h"
    37 #include "InspectorFrontend.h"
    3837
    3938#include <wtf/PassOwnPtr.h>
     
    4241namespace WebCore {
    4342
    44 class DOMFileSystem;
    4543class InspectorFrontend;
    4644class InspectorPageAgent;
    47 class InspectorState;
    48 class InstrumentingAgents;
    4945class ScriptExecutionContext;
    5046class SecurityOrigin;
     
    6056    virtual void disable(ErrorString*) OVERRIDE;
    6157
    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;
    6359    virtual void requestDirectoryContent(ErrorString*, const String& url, int* requestId) OVERRIDE;
    6460    virtual void requestMetadata(ErrorString*, const String& url, int* requestId) OVERRIDE;
     
    7167private:
    7268    InspectorFileSystemAgent(InstrumentingAgents*, InspectorPageAgent*, InspectorState*);
    73     ScriptExecutionContext* scriptExecutionContextForOrigin(SecurityOrigin*);
     69    ScriptExecutionContext* assertScriptExecutionContextForOrigin(ErrorString*, SecurityOrigin*);
    7470
    7571    InspectorPageAgent* m_pageAgent;
  • trunk/Source/WebCore/inspector/front-end/FileSystemModel.js

    r122101 r122313  
    469469     * @param {string} origin
    470470     * @param {string} type
    471      * @param {function(number, FileSystemAgent.Entry)=} callback
     471     * @param {function(number, FileSystemAgent.Entry=)=} callback
    472472     */
    473473    requestFileSystemRoot: function(origin, type, callback)
     
    478478        function requestAccepted(error, requestId)
    479479        {
    480             if (!error)
     480            if (error)
     481                callback(FileError.SECURITY_ERR);
     482            else
    481483                store[requestId] = callback || function() {};
    482484        }
     
    508510        function requestAccepted(error, requestId)
    509511        {
    510             if (!error)
     512            if (error)
     513                callback(FileError.SECURITY_ERR);
     514            else
    511515                store[requestId] = callback || function() {};
    512516        }
     
    538542        function requestAccepted(error, requestId)
    539543        {
    540             if (!error)
     544            if (error)
     545                callback(FileError.SECURITY_ERR);
     546            else
    541547                store[requestId] = callback || function() {};
    542548        }
     
    567573        function requestAccepted(error, requestId)
    568574        {
    569             if (!error)
     575            if (error)
     576                callback(FileError.SECURITY_ERR);
     577            else
    570578                store[requestId] = callback || function() {};
    571579        }
Note: See TracChangeset for help on using the changeset viewer.