| Differences between
and this patch
- Source/WebCore/ChangeLog +31 lines
Lines 1-3 Source/WebCore/ChangeLog_sec1
1
2013-03-11  Michael Nordman  <michaeln@google.com>
2
3
        FileSystem mods: Changes to snapshot file creation to reduce dependencies on blob URLs.
4
        Adding a new minimal BlobDataHandle class which will be reimplemented/built upon in later CLs. In this
5
        patch, it's just enough to refactor the FileSystem code to not function in terms of blobURLs.
6
        https://bugs.webkit.org/show_bug.cgi?id=108851
7
8
        Reviewed by NOBODY (OOPS!).
9
10
        No new tests. This is strictly a refactoring of the existing code.
11
12
        * Modules/filesystem/DOMFileSystem.cpp:
13
        (WebCore):
14
        (WebCore::DOMFileSystem::createFile):
15
        * Modules/filesystem/DOMFileSystemSync.cpp:
16
        (WebCore):
17
        * platform/AsyncFileSystemCallbacks.h:
18
        (AsyncFileSystemCallbacks):
19
        (WebCore::AsyncFileSystemCallbacks::didCreateSnapshotFile):
20
        * platform/gtk/AsyncFileSystemGtk.cpp:
21
        (WebCore::AsyncFileSystemGtk::createSnapshotFileAndReadMetadata):
22
        (WebCore):
23
        * platform/network/BlobData.cpp:
24
        (WebCore):
25
        (WebCore::BlobDataHandle::BlobDataHandle):
26
        (WebCore::BlobDataHandle::~BlobDataHandle):
27
        * platform/network/BlobData.h:
28
        (WebCore):
29
        (BlobDataHandle):
30
        (WebCore::BlobDataHandle::create):
31
1
2013-03-11  Alexey Proskuryakov  <ap@apple.com>
32
2013-03-11  Alexey Proskuryakov  <ap@apple.com>
2
33
3
        Chromium build fix. Forked files strike again.
34
        Chromium build fix. Forked files strike again.
- Source/WebCore/Modules/filesystem/DOMFileSystem.cpp -6 / +11 lines
Lines 148-166 void DOMFileSystem::createWriter(const F Source/WebCore/Modules/filesystem/DOMFileSystem.cpp_sec1
148
148
149
namespace {
149
namespace {
150
150
151
class GetMetadataCallback : public FileSystemCallbacksBase {
151
class SnapshotFileCallback : public FileSystemCallbacksBase {
152
public:
152
public:
153
    static PassOwnPtr<GetMetadataCallback> create(PassRefPtr<DOMFileSystem> filesystem, const String& name, const KURL& url, PassRefPtr<FileCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
153
    static PassOwnPtr<SnapshotFileCallback> create(PassRefPtr<DOMFileSystem> filesystem, const String& name, const KURL& url, PassRefPtr<FileCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
154
    {
154
    {
155
        return adoptPtr(new GetMetadataCallback(filesystem, name, url, successCallback, errorCallback));
155
        return adoptPtr(new SnapshotFileCallback(filesystem, name, url, successCallback, errorCallback));
156
    }
156
    }
157
157
158
    virtual void didReadMetadata(const FileMetadata& metadata)
158
    virtual void didCreateSnapshotFile(const FileMetadata& metadata, PassRefPtr<BlobDataHandle> snapshot)
159
    {
159
    {
160
        ASSERT(!metadata.platformPath.isEmpty());
160
        ASSERT(!metadata.platformPath.isEmpty());
161
        if (!m_successCallback)
161
        if (!m_successCallback)
162
            return;
162
            return;
163
163
164
        // We can't directly use the snapshot blob data handle because the content type on it hasn't been set.
165
        // The |snapshot| param is here to provide a a chain of custody thru thread bridging that is held onto until
166
        // *after* we've coined a File with a new handle that has the correct type set on it. This allows the
167
        // blob storage system to track when a temp file can and can't be safely deleted.
168
164
        // For regular filesystem types (temporary or persistent), we should not cache file metadata as it could change File semantics.
169
        // For regular filesystem types (temporary or persistent), we should not cache file metadata as it could change File semantics.
165
        // For other filesystem types (which could be platform-specific ones), there's a chance that the files are on remote filesystem. If the port has returned metadata just pass it to File constructor (so we may cache the metadata).
170
        // For other filesystem types (which could be platform-specific ones), there's a chance that the files are on remote filesystem. If the port has returned metadata just pass it to File constructor (so we may cache the metadata).
166
        // FIXME: We should use the snapshot metadata for all files.
171
        // FIXME: We should use the snapshot metadata for all files.
Lines 179-185 public: Source/WebCore/Modules/filesystem/DOMFileSystem.cpp_sec2
179
    }
184
    }
180
185
181
private:
186
private:
182
    GetMetadataCallback(PassRefPtr<DOMFileSystem> filesystem, const String& name,  const KURL& url, PassRefPtr<FileCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
187
    SnapshotFileCallback(PassRefPtr<DOMFileSystem> filesystem, const String& name,  const KURL& url, PassRefPtr<FileCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
183
        : FileSystemCallbacksBase(errorCallback)
188
        : FileSystemCallbacksBase(errorCallback)
184
        , m_filesystem(filesystem)
189
        , m_filesystem(filesystem)
185
        , m_name(name)
190
        , m_name(name)
Lines 199-205 private: Source/WebCore/Modules/filesystem/DOMFileSystem.cpp_sec3
199
void DOMFileSystem::createFile(const FileEntry* fileEntry, PassRefPtr<FileCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
204
void DOMFileSystem::createFile(const FileEntry* fileEntry, PassRefPtr<FileCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
200
{
205
{
201
    KURL fileSystemURL = createFileSystemURL(fileEntry);
206
    KURL fileSystemURL = createFileSystemURL(fileEntry);
202
    m_asyncFileSystem->createSnapshotFileAndReadMetadata(fileSystemURL, GetMetadataCallback::create(this, fileEntry->name(), fileSystemURL, successCallback, errorCallback));
207
    m_asyncFileSystem->createSnapshotFileAndReadMetadata(fileSystemURL, SnapshotFileCallback::create(this, fileEntry->name(), fileSystemURL, successCallback, errorCallback));
203
}
208
}
204
209
205
} // namespace WebCore
210
} // namespace WebCore
- Source/WebCore/Modules/filesystem/DOMFileSystemSync.cpp -2 / +8 lines
Lines 113-122 public: Source/WebCore/Modules/filesystem/DOMFileSystemSync.cpp_sec1
113
    {
113
    {
114
    }
114
    }
115
115
116
    void didReadMetadata(const FileMetadata& metadata)
116
    virtual void didCreateSnapshotFile(const FileMetadata& metadata, PassRefPtr<BlobDataHandle> snapshot)
117
    {
117
    {
118
        // We can't directly use the snapshot blob data handle because the content type on it hasn't been set.
119
        // The |snapshot| param is here to provide a a chain of custody thru thread bridging that is held onto until
120
        // *after* we've coined a File with a new handle that has the correct type set on it. This allows the
121
        // blob storage system to track when a temp file can and can't be safely deleted.
122
118
        // For regular filesystem types (temporary or persistent), we should not cache file metadata as it could change File semantics.
123
        // For regular filesystem types (temporary or persistent), we should not cache file metadata as it could change File semantics.
119
        // For other filesystem types (which could be platform-specific ones), there's a chance that the files are on remote filesystem. If the port has returned metadata just pass it to File constructor (so we may cache the metadata).
124
        // For other filesystem types (which could be platform-specific ones), there's a chance that the files are on remote filesystem.
125
        // If the port has returned metadata just pass it to File constructor (so we may cache the metadata).
120
        // FIXME: We should use the snapshot metadata for all files.
126
        // FIXME: We should use the snapshot metadata for all files.
121
        // https://www.w3.org/Bugs/Public/show_bug.cgi?id=17746
127
        // https://www.w3.org/Bugs/Public/show_bug.cgi?id=17746
122
        if (m_type == FileSystemTypeTemporary || m_type == FileSystemTypePersistent) {
128
        if (m_type == FileSystemTypeTemporary || m_type == FileSystemTypePersistent) {
- Source/WebCore/platform/AsyncFileSystemCallbacks.h +4 lines
Lines 35-40 Source/WebCore/platform/AsyncFileSystemCallbacks.h_sec1
35
35
36
#include "AsyncFileSystem.h"
36
#include "AsyncFileSystem.h"
37
#include "AsyncFileWriter.h"
37
#include "AsyncFileWriter.h"
38
#include "BlobData.h"
38
#include "FileMetadata.h"
39
#include "FileMetadata.h"
39
#include <wtf/text/WTFString.h>
40
#include <wtf/text/WTFString.h>
40
41
Lines 54-59 public: Source/WebCore/platform/AsyncFileSystemCallbacks.h_sec2
54
    // Called when a file metadata is read successfully.
55
    // Called when a file metadata is read successfully.
55
    virtual void didReadMetadata(const FileMetadata&) { ASSERT_NOT_REACHED(); }
56
    virtual void didReadMetadata(const FileMetadata&) { ASSERT_NOT_REACHED(); }
56
57
58
    // Called when a snapshot file is created successfully.
59
    virtual void didCreateSnapshotFile(const FileMetadata&, PassRefPtr<BlobDataHandle> snapshot) { ASSERT_NOT_REACHED(); }
60
57
    // Called when a directory entry is read.
61
    // Called when a directory entry is read.
58
    virtual void didReadDirectoryEntry(const String& name, bool isDirectory) { ASSERT_NOT_REACHED(); }
62
    virtual void didReadDirectoryEntry(const String& name, bool isDirectory) { ASSERT_NOT_REACHED(); }
59
63
- Source/WebCore/platform/gtk/AsyncFileSystemGtk.cpp +5 lines
Lines 118-123 void AsyncFileSystemGtk::createWriter(As Source/WebCore/platform/gtk/AsyncFileSystemGtk.cpp_sec1
118
    notImplemented();
118
    notImplemented();
119
}
119
}
120
120
121
void AsyncFileSystemGtk::createSnapshotFileAndReadMetadata(const KURL&, PassOwnPtr<AsyncFileSystemCallbacks>)
122
{
123
    notImplemented();
124
}
125
121
} // namespace WebCore
126
} // namespace WebCore
122
127
123
#endif
128
#endif
- Source/WebCore/platform/network/BlobData.cpp +15 lines
Lines 30-35 Source/WebCore/platform/network/BlobData.cpp_sec1
30
30
31
#include "config.h"
31
#include "config.h"
32
#include "BlobData.h"
32
#include "BlobData.h"
33
#include "BlobURL.h"
34
#include "ThreadableBlobRegistry.h"
33
35
34
#include <wtf/OwnPtr.h>
36
#include <wtf/OwnPtr.h>
35
#include <wtf/PassOwnPtr.h>
37
#include <wtf/PassOwnPtr.h>
Lines 101-104 void BlobData::swapItems(BlobDataItemLis Source/WebCore/platform/network/BlobData.cpp_sec2
101
    m_items.swap(items);
103
    m_items.swap(items);
102
}
104
}
103
105
106
107
BlobDataHandle::BlobDataHandle(PassOwnPtr<BlobData> data, long long size)
108
{
109
    UNUSED_PARAM(size);
110
    m_internalURL = BlobURL::createInternalURL();
111
    ThreadableBlobRegistry::registerBlobURL(m_internalURL, data);
112
}
113
114
BlobDataHandle::~BlobDataHandle()
115
{
116
    ThreadableBlobRegistry::unregisterBlobURL(m_internalURL);
117
}
118
104
} // namespace WebCore
119
} // namespace WebCore
- Source/WebCore/platform/network/BlobData.h +16 lines
Lines 202-207 private: Source/WebCore/platform/network/BlobData.h_sec1
202
    BlobDataItemList m_items;
202
    BlobDataItemList m_items;
203
};
203
};
204
204
205
// FIXME: This class is mostly place holder until I get farther along in landing
206
// https://codereview.chromium.org/11192017/.
207
class BlobDataHandle : public ThreadSafeRefCounted<BlobDataHandle> {
208
public:
209
    static PassRefPtr<BlobDataHandle> create(PassOwnPtr<BlobData> data, long long size)
210
    {
211
        return adoptRef(new BlobDataHandle(data, size));
212
    }
213
214
    ~BlobDataHandle();
215
216
private:
217
    BlobDataHandle(PassOwnPtr<BlobData>, long long size);
218
    KURL m_internalURL;
219
};
220
205
} // namespace WebCore
221
} // namespace WebCore
206
222
207
#endif // BlobData_h
223
#endif // BlobData_h
- Source/WebKit/chromium/ChangeLog +41 lines
Lines 1-3 Source/WebKit/chromium/ChangeLog_sec1
1
2013-03-11  Michael Nordman  <michaeln@google.com>
2
3
        [Chromium] FileSystem mods: Changes to snapshot file creation to reduce dependencies on blobs.
4
        No longer send a |blobURL| to the browser process, no longer expect the browser process
5
        to have registered a blob with that url.
6
        https://bugs.webkit.org/show_bug.cgi?id=108851
7
8
        Reviewed by NOBODY (OOPS!).
9
10
        * src/AsyncFileSystemChromium.cpp:
11
        (WebCore):
12
        (WebCore::FileWriterHelperCallbacks::didCreateSnapshotFile):
13
        (WebCore::AsyncFileSystemChromium::createSnapshotFileAndReadMetadata):
14
        * src/AsyncFileSystemChromium.h:
15
        (AsyncFileSystemChromium):
16
        * src/LocalFileSystemChromium.cpp:
17
        (WebCore):
18
        * src/WebFileSystemCallbacksImpl.cpp:
19
        (WebKit::WebFileSystemCallbacksImpl::didCreateSnapshotFile):
20
        (WebKit):
21
        * src/WebFileSystemCallbacksImpl.h:
22
        (WebCore):
23
        (WebFileSystemCallbacksImpl):
24
        * src/WorkerAsyncFileSystemChromium.cpp:
25
        (WebCore::WorkerAsyncFileSystemChromium::createSnapshotFileAndReadMetadata):
26
        (WebCore::WorkerAsyncFileSystemChromium::createWorkerFileSystemCallbacksBridge):
27
        * src/WorkerFileSystemCallbacksBridge.cpp:
28
        (WebKit::MainThreadFileSystemCallbacks::didCreateSnapshotFile):
29
        (MainThreadFileSystemCallbacks):
30
        (WebKit::WorkerFileSystemCallbacksBridge::postCreateSnapshotFileToMainThread):
31
        (WebKit::WorkerFileSystemCallbacksBridge::createSnapshotFileOnMainThread):
32
        (WebKit::WorkerFileSystemCallbacksBridge::didCreateSnapshotFileOnMainThread):
33
        (WebKit):
34
        (WebKit::WorkerFileSystemCallbacksBridge::WorkerFileSystemCallbacksBridge):
35
        (WebKit::WorkerFileSystemCallbacksBridge::didCreateSnapshotFileOnWorkerThread):
36
        * src/WorkerFileSystemCallbacksBridge.h:
37
        (WebCore):
38
        (WebKit):
39
        (WebKit::WorkerFileSystemCallbacksBridge::create):
40
        (WorkerFileSystemCallbacksBridge):
41
1
2013-03-11  Xiyuan Xia  <xiyuan@chromium.org>
42
2013-03-11  Xiyuan Xia  <xiyuan@chromium.org>
2
43
3
        [Chromium] chromium/linux breaks expectation of select popup background due to bad UA css rules
44
        [Chromium] chromium/linux breaks expectation of select popup background due to bad UA css rules
- Source/WebKit/chromium/src/AsyncFileSystemChromium.cpp -50 / +6 lines
Lines 48-93 Source/WebKit/chromium/src/AsyncFileSystemChromium.cpp_sec1
48
48
49
namespace WebCore {
49
namespace WebCore {
50
50
51
namespace {
52
53
// Specialized callback class for createSnapshotFileAndReadMetadata.
54
class SnapshotFileCallbacks : public AsyncFileSystemCallbacks {
55
public:
56
    static PassOwnPtr<SnapshotFileCallbacks> create(const KURL& internalBlobURL, PassOwnPtr<WebCore::AsyncFileSystemCallbacks> callbacks)
57
    {
58
        return adoptPtr(new SnapshotFileCallbacks(internalBlobURL, callbacks));
59
    }
60
61
    virtual void didReadMetadata(const FileMetadata& metadata)
62
    {
63
        ASSERT(m_callbacks);
64
65
        // This will create a new File object using the metadata.
66
        m_callbacks->didReadMetadata(metadata);
67
68
        // Now that we've registered the snapshot file, we can unregister our internalBlobURL which has played a placeholder for the file during the IPC.
69
        ThreadableBlobRegistry::unregisterBlobURL(m_internalBlobURL);
70
    }
71
72
    virtual void didFail(int error)
73
    {
74
        ASSERT(m_callbacks);
75
        m_callbacks->didFail(error);
76
    }
77
78
private:
79
    SnapshotFileCallbacks(const KURL& internalBlobURL, PassOwnPtr<WebCore::AsyncFileSystemCallbacks> callbacks)
80
        : m_internalBlobURL(internalBlobURL)
81
        , m_callbacks(callbacks)
82
    {
83
    }
84
85
    KURL m_internalBlobURL;
86
    OwnPtr<WebCore::AsyncFileSystemCallbacks> m_callbacks;
87
};
88
89
} // namespace
90
91
bool AsyncFileSystem::isAvailable()
51
bool AsyncFileSystem::isAvailable()
92
{
52
{
93
    return true;
53
    return true;
Lines 186-192 public: Source/WebKit/chromium/src/AsyncFileSystemChromium.cpp_sec2
186
        }
146
        }
187
        delete this;
147
        delete this;
188
    }
148
    }
189
149
    virtual void didCreateSnapshotFile(const WebKit::WebFileInfo& info)
150
    {
151
        ASSERT_NOT_REACHED();
152
        delete this;
153
    }
190
    virtual void didReadDirectory(const WebKit::WebVector<WebKit::WebFileSystemEntry>& entries, bool hasMore)
154
    virtual void didReadDirectory(const WebKit::WebVector<WebKit::WebFileSystemEntry>& entries, bool hasMore)
191
    {
155
    {
192
        ASSERT_NOT_REACHED();
156
        ASSERT_NOT_REACHED();
Lines 219-233 void AsyncFileSystemChromium::createWrit Source/WebKit/chromium/src/AsyncFileSystemChromium.cpp_sec3
219
183
220
void AsyncFileSystemChromium::createSnapshotFileAndReadMetadata(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
184
void AsyncFileSystemChromium::createSnapshotFileAndReadMetadata(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
221
{
185
{
222
    KURL internalBlobURL = BlobURL::createInternalURL();
186
    m_webFileSystem->createSnapshotFileAndReadMetadata(path, new WebKit::WebFileSystemCallbacksImpl(callbacks));
223
224
    // This will create a snapshot file and register the file to a blob using the given internalBlobURL.
225
    m_webFileSystem->createSnapshotFileAndReadMetadata(internalBlobURL, path, new WebKit::WebFileSystemCallbacksImpl(createSnapshotFileCallback(internalBlobURL, callbacks)));
226
}
227
228
PassOwnPtr<AsyncFileSystemCallbacks> AsyncFileSystemChromium::createSnapshotFileCallback(const KURL& internalBlobURL, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) const
229
{
230
    return SnapshotFileCallbacks::create(internalBlobURL, callbacks);
231
}
187
}
232
188
233
} // namespace WebCore
189
} // namespace WebCore
- Source/WebKit/chromium/src/AsyncFileSystemChromium.h -2 lines
Lines 69-76 public: Source/WebKit/chromium/src/AsyncFileSystemChromium.h_sec1
69
protected:
69
protected:
70
    AsyncFileSystemChromium();
70
    AsyncFileSystemChromium();
71
71
72
    PassOwnPtr<AsyncFileSystemCallbacks> createSnapshotFileCallback(const KURL& internalBlobURL, PassOwnPtr<AsyncFileSystemCallbacks>) const;
73
74
    WebKit::WebFileSystem* m_webFileSystem;
72
    WebKit::WebFileSystem* m_webFileSystem;
75
};
73
};
76
74
- Source/WebKit/chromium/src/LocalFileSystemChromium.cpp -1 / +1 lines
Lines 153-159 bool allowFileSystemForWorker(WebCommonW Source/WebKit/chromium/src/LocalFileSystemChromium.cpp_sec1
153
    return bridge->result();
153
    return bridge->result();
154
}
154
}
155
155
156
void openFileSystemForWorker(WebCommonWorkerClient* commonClient, WebFileSystem::Type type, long long size, bool create, WebFileSystemCallbacks* callbacks, FileSystemSynchronousType synchronousType)
156
void openFileSystemForWorker(WebCommonWorkerClient* commonClient, WebFileSystem::Type type, long long size, bool create, WebFileSystemCallbacksImpl* callbacks, FileSystemSynchronousType synchronousType)
157
{
157
{
158
    WorkerScriptController* controller = WorkerScriptController::controllerForContext();
158
    WorkerScriptController* controller = WorkerScriptController::controllerForContext();
159
    WorkerContext* workerContext = controller->workerContext();
159
    WorkerContext* workerContext = controller->workerContext();
- Source/WebKit/chromium/src/WebFileSystemCallbacksImpl.cpp +21 lines
Lines 76-81 void WebFileSystemCallbacksImpl::didRead Source/WebKit/chromium/src/WebFileSystemCallbacksImpl.cpp_sec1
76
    delete this;
76
    delete this;
77
}
77
}
78
78
79
void WebFileSystemCallbacksImpl::didCreateSnapshotFile(const WebFileInfo& webFileInfo)
80
{
81
    // It's important to create a BlobDataHandle that refers to the platform file path prior
82
    // to return from this method so the underlying file will not be deleted.
83
    OwnPtr<BlobData> blobData = BlobData::create();
84
    blobData->appendFile(webFileInfo.platformPath);
85
    RefPtr<BlobDataHandle> snapshotBlob = BlobDataHandle::create(blobData.release(), webFileInfo.length);
86
    didCreateSnapshotFile(webFileInfo, snapshotBlob);
87
}
88
89
void WebFileSystemCallbacksImpl::didCreateSnapshotFile(const WebFileInfo& webFileInfo, PassRefPtr<WebCore::BlobDataHandle> snapshot)
90
{
91
    FileMetadata fileMetadata;
92
    fileMetadata.modificationTime = webFileInfo.modificationTime;
93
    fileMetadata.length = webFileInfo.length;
94
    fileMetadata.type = static_cast<FileMetadata::Type>(webFileInfo.type);
95
    fileMetadata.platformPath = webFileInfo.platformPath;
96
    m_callbacks->didCreateSnapshotFile(fileMetadata, snapshot);
97
    delete this;
98
}
99
79
void WebFileSystemCallbacksImpl::didReadDirectory(const WebVector<WebFileSystemEntry>& entries, bool hasMore)
100
void WebFileSystemCallbacksImpl::didReadDirectory(const WebVector<WebFileSystemEntry>& entries, bool hasMore)
80
{
101
{
81
    for (size_t i = 0; i < entries.size(); ++i)
102
    for (size_t i = 0; i < entries.size(); ++i)
- Source/WebKit/chromium/src/WebFileSystemCallbacksImpl.h -1 / +8 lines
Lines 40-45 Source/WebKit/chromium/src/WebFileSystemCallbacksImpl.h_sec1
40
40
41
namespace WebCore {
41
namespace WebCore {
42
class AsyncFileSystemCallbacks;
42
class AsyncFileSystemCallbacks;
43
class BlobDataHandle;
43
class ScriptExecutionContext;
44
class ScriptExecutionContext;
44
}
45
}
45
46
Lines 56-66 public: Source/WebKit/chromium/src/WebFileSystemCallbacksImpl.h_sec2
56
    virtual ~WebFileSystemCallbacksImpl();
57
    virtual ~WebFileSystemCallbacksImpl();
57
58
58
    virtual void didSucceed();
59
    virtual void didSucceed();
59
    virtual void didReadMetadata(const WebFileInfo& info);
60
    virtual void didReadMetadata(const WebFileInfo&);
61
    virtual void didCreateSnapshotFile(const WebFileInfo&);
60
    virtual void didReadDirectory(const WebVector<WebFileSystemEntry>& entries, bool hasMore);
62
    virtual void didReadDirectory(const WebVector<WebFileSystemEntry>& entries, bool hasMore);
61
    virtual void didOpenFileSystem(const WebString& name, const WebURL& rootURL);
63
    virtual void didOpenFileSystem(const WebString& name, const WebURL& rootURL);
62
    virtual void didFail(WebFileError error);
64
    virtual void didFail(WebFileError error);
63
65
66
    // This internal overload is used by WorkerFileSystemCallbacksBridge to deliver a blob data handle
67
    // created on the main thread to an  AsyncFileSystemCallback on a background worker thread. The other
68
    // virtual method is invoked by the embedder.
69
    void didCreateSnapshotFile(const WebFileInfo&, PassRefPtr<WebCore::BlobDataHandle> snapshot);
70
64
private:
71
private:
65
    OwnPtr<WebCore::AsyncFileSystemCallbacks> m_callbacks;
72
    OwnPtr<WebCore::AsyncFileSystemCallbacks> m_callbacks;
66
73
- Source/WebKit/chromium/src/WorkerAsyncFileSystemChromium.cpp -4 / +1 lines
Lines 179-193 void WorkerAsyncFileSystemChromium::crea Source/WebKit/chromium/src/WorkerAsyncFileSystemChromium.cpp_sec1
179
179
180
void WorkerAsyncFileSystemChromium::createSnapshotFileAndReadMetadata(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
180
void WorkerAsyncFileSystemChromium::createSnapshotFileAndReadMetadata(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
181
{
181
{
182
    KURL internalBlobURL = BlobURL::createInternalURL();
182
    createWorkerFileSystemCallbacksBridge(callbacks)->postCreateSnapshotFileToMainThread(m_webFileSystem, path, m_modeForCurrentOperation);
183
184
    createWorkerFileSystemCallbacksBridge(createSnapshotFileCallback(internalBlobURL, callbacks))->postCreateSnapshotFileToMainThread(m_webFileSystem, internalBlobURL, path, m_modeForCurrentOperation);
185
}
183
}
186
184
187
PassRefPtr<WorkerFileSystemCallbacksBridge> WorkerAsyncFileSystemChromium::createWorkerFileSystemCallbacksBridge(PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
185
PassRefPtr<WorkerFileSystemCallbacksBridge> WorkerAsyncFileSystemChromium::createWorkerFileSystemCallbacksBridge(PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
188
{
186
{
189
    ASSERT(m_synchronousType == AsynchronousFileSystem || !m_bridgeForCurrentOperation);
187
    ASSERT(m_synchronousType == AsynchronousFileSystem || !m_bridgeForCurrentOperation);
190
    (void)m_synchronousType;
191
188
192
    m_modeForCurrentOperation = fileSystemOperationsMode;
189
    m_modeForCurrentOperation = fileSystemOperationsMode;
193
    m_modeForCurrentOperation.append(String::number(m_workerContext->thread()->runLoop().createUniqueId()));
190
    m_modeForCurrentOperation.append(String::number(m_workerContext->thread()->runLoop().createUniqueId()));
- Source/WebKit/chromium/src/WorkerFileSystemCallbacksBridge.cpp -6 / +28 lines
Lines 33-42 Source/WebKit/chromium/src/WorkerFileSystemCallbacksBridge.cpp_sec1
33
33
34
#if ENABLE(FILE_SYSTEM) && ENABLE(WORKERS)
34
#if ENABLE(FILE_SYSTEM) && ENABLE(WORKERS)
35
35
36
#include "BlobData.h"
36
#include "CrossThreadTask.h"
37
#include "CrossThreadTask.h"
37
#include "KURL.h"
38
#include "KURL.h"
38
#include "WebCommonWorkerClient.h"
39
#include "WebCommonWorkerClient.h"
39
#include "WebFileSystemCallbacks.h"
40
#include "WebFileSystemCallbacksImpl.h"
40
#include "WebFileSystemEntry.h"
41
#include "WebFileSystemEntry.h"
41
#include "WebWorkerBase.h"
42
#include "WebWorkerBase.h"
42
#include "WorkerContext.h"
43
#include "WorkerContext.h"
Lines 124-129 public: Source/WebKit/chromium/src/WorkerFileSystemCallbacksBridge.cpp_sec2
124
        delete this;
125
        delete this;
125
    }
126
    }
126
127
128
    virtual void didCreateSnapshotFile(const WebFileInfo& info)
129
    {
130
        // It's important to create a BlobDataHandle that refers to the platform file path prior
131
        // to return from this method so the underlying file will not be deleted.
132
        OwnPtr<BlobData> blobData = BlobData::create();
133
        blobData->appendFile(info.platformPath);
134
        RefPtr<BlobDataHandle> snapshotBlob = BlobDataHandle::create(blobData.release(), info.length);
135
        m_bridge->didCreateSnapshotFileOnMainThread(info, m_mode, snapshotBlob);
136
        delete this;
137
    }
138
127
    virtual void didReadDirectory(const WebVector<WebFileSystemEntry>& entries, bool hasMore)
139
    virtual void didReadDirectory(const WebVector<WebFileSystemEntry>& entries, bool hasMore)
128
    {
140
    {
129
        m_bridge->didReadDirectoryOnMainThread(entries, hasMore, m_mode);
141
        m_bridge->didReadDirectoryOnMainThread(entries, hasMore, m_mode);
Lines 289-301 void WorkerFileSystemCallbacksBridge::po Source/WebKit/chromium/src/WorkerFileSystemCallbacksBridge.cpp_sec3
289
                           this, mode));
301
                           this, mode));
290
}
302
}
291
303
292
void WorkerFileSystemCallbacksBridge::postCreateSnapshotFileToMainThread(WebFileSystem* fileSystem, const KURL& internalBlobURL, const KURL& path, const String& mode)
304
void WorkerFileSystemCallbacksBridge::postCreateSnapshotFileToMainThread(WebFileSystem* fileSystem, const KURL& path, const String& mode)
293
{
305
{
294
    ASSERT(fileSystem);
306
    ASSERT(fileSystem);
295
    dispatchTaskToMainThread(
307
    dispatchTaskToMainThread(
296
        createCallbackTask(&createSnapshotFileOnMainThread,
308
        createCallbackTask(&createSnapshotFileOnMainThread,
297
                           AllowCrossThreadAccess(fileSystem),
309
                           AllowCrossThreadAccess(fileSystem),
298
                           internalBlobURL, path, this, mode));
310
                           path, this, mode));
299
}
311
}
300
312
301
void WorkerFileSystemCallbacksBridge::openFileSystemOnMainThread(ScriptExecutionContext*, WebCommonWorkerClient* commonClient, WebFileSystem::Type type, long long size, bool create, PassRefPtr<WorkerFileSystemCallbacksBridge> bridge, const String& mode)
313
void WorkerFileSystemCallbacksBridge::openFileSystemOnMainThread(ScriptExecutionContext*, WebCommonWorkerClient* commonClient, WebFileSystem::Type type, long long size, bool create, PassRefPtr<WorkerFileSystemCallbacksBridge> bridge, const String& mode)
Lines 357-365 void WorkerFileSystemCallbacksBridge::re Source/WebKit/chromium/src/WorkerFileSystemCallbacksBridge.cpp_sec4
357
    fileSystem->readDirectory(path, MainThreadFileSystemCallbacks::createLeakedPtr(bridge, mode));
369
    fileSystem->readDirectory(path, MainThreadFileSystemCallbacks::createLeakedPtr(bridge, mode));
358
}
370
}
359
371
360
void WorkerFileSystemCallbacksBridge::createSnapshotFileOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem* fileSystem, const KURL& internalBlobURL, const KURL& path, PassRefPtr<WorkerFileSystemCallbacksBridge> bridge, const String& mode)
372
void WorkerFileSystemCallbacksBridge::createSnapshotFileOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem* fileSystem, const KURL& path, PassRefPtr<WorkerFileSystemCallbacksBridge> bridge, const String& mode)
361
{
373
{
362
    fileSystem->createSnapshotFileAndReadMetadata(internalBlobURL, path, MainThreadFileSystemCallbacks::createLeakedPtr(bridge, mode));
374
    fileSystem->createSnapshotFileAndReadMetadata(path, MainThreadFileSystemCallbacks::createLeakedPtr(bridge, mode));
363
}
375
}
364
376
365
void WorkerFileSystemCallbacksBridge::didFailOnMainThread(WebFileError error, const String& mode)
377
void WorkerFileSystemCallbacksBridge::didFailOnMainThread(WebFileError error, const String& mode)
Lines 383-388 void WorkerFileSystemCallbacksBridge::di Source/WebKit/chromium/src/WorkerFileSystemCallbacksBridge.cpp_sec5
383
    mayPostTaskToWorker(createCallbackTask(&didReadMetadataOnWorkerThread, this, info), mode);
395
    mayPostTaskToWorker(createCallbackTask(&didReadMetadataOnWorkerThread, this, info), mode);
384
}
396
}
385
397
398
void WorkerFileSystemCallbacksBridge::didCreateSnapshotFileOnMainThread(const WebFileInfo& info, const String& mode, PassRefPtr<BlobDataHandle> snapshotBlob)
399
{
400
    mayPostTaskToWorker(createCallbackTask(&didCreateSnapshotFileOnWorkerThread, this, info, snapshotBlob), mode);
401
}
402
386
void WorkerFileSystemCallbacksBridge::didReadDirectoryOnMainThread(const WebVector<WebFileSystemEntry>& entries, bool hasMore, const String& mode)
403
void WorkerFileSystemCallbacksBridge::didReadDirectoryOnMainThread(const WebVector<WebFileSystemEntry>& entries, bool hasMore, const String& mode)
387
{
404
{
388
    mayPostTaskToWorker(
405
    mayPostTaskToWorker(
Lines 390-396 void WorkerFileSystemCallbacksBridge::di Source/WebKit/chromium/src/WorkerFileSystemCallbacksBridge.cpp_sec6
390
                           this, entries, hasMore), mode);
407
                           this, entries, hasMore), mode);
391
}
408
}
392
409
393
WorkerFileSystemCallbacksBridge::WorkerFileSystemCallbacksBridge(WebCore::WorkerLoaderProxy* workerLoaderProxy, ScriptExecutionContext* scriptExecutionContext, WebFileSystemCallbacks* callbacks)
410
WorkerFileSystemCallbacksBridge::WorkerFileSystemCallbacksBridge(WebCore::WorkerLoaderProxy* workerLoaderProxy, ScriptExecutionContext* scriptExecutionContext, WebFileSystemCallbacksImpl* callbacks)
394
    : m_workerLoaderProxy(workerLoaderProxy)
411
    : m_workerLoaderProxy(workerLoaderProxy)
395
    , m_workerContext(scriptExecutionContext)
412
    , m_workerContext(scriptExecutionContext)
396
    , m_workerContextObserver(WorkerFileSystemContextObserver::create(static_cast<WorkerContext*>(m_workerContext), this).leakPtr())
413
    , m_workerContextObserver(WorkerFileSystemContextObserver::create(static_cast<WorkerContext*>(m_workerContext), this).leakPtr())
Lines 424-429 void WorkerFileSystemCallbacksBridge::di Source/WebKit/chromium/src/WorkerFileSystemCallbacksBridge.cpp_sec7
424
    bridge->m_callbacksOnWorkerThread->didReadMetadata(info);
441
    bridge->m_callbacksOnWorkerThread->didReadMetadata(info);
425
}
442
}
426
443
444
void WorkerFileSystemCallbacksBridge::didCreateSnapshotFileOnWorkerThread(ScriptExecutionContext*, PassRefPtr<WorkerFileSystemCallbacksBridge> bridge, const WebFileInfo& info, PassRefPtr<BlobDataHandle> snapshotBlob)
445
{
446
    bridge->m_callbacksOnWorkerThread->didCreateSnapshotFile(info, snapshotBlob);
447
}
448
427
void WorkerFileSystemCallbacksBridge::didReadDirectoryOnWorkerThread(ScriptExecutionContext*, PassRefPtr<WorkerFileSystemCallbacksBridge> bridge, const WebVector<WebFileSystemEntry>& entries, bool hasMore)
449
void WorkerFileSystemCallbacksBridge::didReadDirectoryOnWorkerThread(ScriptExecutionContext*, PassRefPtr<WorkerFileSystemCallbacksBridge> bridge, const WebVector<WebFileSystemEntry>& entries, bool hasMore)
428
{
450
{
429
    bridge->m_callbacksOnWorkerThread->didReadDirectory(entries, hasMore);
451
    bridge->m_callbacksOnWorkerThread->didReadDirectory(entries, hasMore);
- Source/WebKit/chromium/src/WorkerFileSystemCallbacksBridge.h -6 / +9 lines
Lines 43-48 Source/WebKit/chromium/src/WorkerFileSystemCallbacksBridge.h_sec1
43
#include <wtf/text/WTFString.h>
43
#include <wtf/text/WTFString.h>
44
44
45
namespace WebCore {
45
namespace WebCore {
46
class BlobDataHandle;
46
class WorkerLoaderProxy;
47
class WorkerLoaderProxy;
47
}
48
}
48
49
Lines 52-58 class AsyncFileSystem; Source/WebKit/chromium/src/WorkerFileSystemCallbacksBridge.h_sec2
52
class MainThreadFileSystemCallbacks;
53
class MainThreadFileSystemCallbacks;
53
class WebCommonWorkerClient;
54
class WebCommonWorkerClient;
54
class ThreadableCallbacksBridgeWrapper;
55
class ThreadableCallbacksBridgeWrapper;
55
class WebFileSystemCallbacks;
56
class WebFileSystemCallbacksImpl;
56
class WorkerFileSystemContextObserver;
57
class WorkerFileSystemContextObserver;
57
struct WebFileInfo;
58
struct WebFileInfo;
58
struct WebFileSystemEntry;
59
struct WebFileSystemEntry;
Lines 77-83 public: Source/WebKit/chromium/src/WorkerFileSystemCallbacksBridge.h_sec3
77
78
78
    void stop();
79
    void stop();
79
80
80
    static PassRefPtr<WorkerFileSystemCallbacksBridge> create(WebCore::WorkerLoaderProxy* workerLoaderProxy, WebCore::ScriptExecutionContext* workerContext, WebFileSystemCallbacks* callbacks)
81
    static PassRefPtr<WorkerFileSystemCallbacksBridge> create(WebCore::WorkerLoaderProxy* workerLoaderProxy, WebCore::ScriptExecutionContext* workerContext, WebFileSystemCallbacksImpl* callbacks)
81
    {
82
    {
82
        return adoptRef(new WorkerFileSystemCallbacksBridge(workerLoaderProxy, workerContext, callbacks));
83
        return adoptRef(new WorkerFileSystemCallbacksBridge(workerLoaderProxy, workerContext, callbacks));
83
    }
84
    }
Lines 94-110 public: Source/WebKit/chromium/src/WorkerFileSystemCallbacksBridge.h_sec4
94
    void postFileExistsToMainThread(WebFileSystem*, const WebCore::KURL& path, const String& mode);
95
    void postFileExistsToMainThread(WebFileSystem*, const WebCore::KURL& path, const String& mode);
95
    void postDirectoryExistsToMainThread(WebFileSystem*, const WebCore::KURL& path, const String& mode);
96
    void postDirectoryExistsToMainThread(WebFileSystem*, const WebCore::KURL& path, const String& mode);
96
    void postReadDirectoryToMainThread(WebFileSystem*, const WebCore::KURL& path, const String& mode);
97
    void postReadDirectoryToMainThread(WebFileSystem*, const WebCore::KURL& path, const String& mode);
97
    void postCreateSnapshotFileToMainThread(WebFileSystem*, const WebCore::KURL& internalBlobURL, const WebCore::KURL& path, const String& mode);
98
    void postCreateSnapshotFileToMainThread(WebFileSystem*, const WebCore::KURL& path, const String& mode);
98
99
99
    // Callback methods that are called on the main thread.
100
    // Callback methods that are called on the main thread.
100
    void didFailOnMainThread(WebFileError, const String& mode);
101
    void didFailOnMainThread(WebFileError, const String& mode);
101
    void didOpenFileSystemOnMainThread(const String& name, const WebCore::KURL& rootURL, const String& mode);
102
    void didOpenFileSystemOnMainThread(const String& name, const WebCore::KURL& rootURL, const String& mode);
102
    void didSucceedOnMainThread(const String& mode);
103
    void didSucceedOnMainThread(const String& mode);
103
    void didReadMetadataOnMainThread(const WebFileInfo&, const String& mode);
104
    void didReadMetadataOnMainThread(const WebFileInfo&, const String& mode);
105
    void didCreateSnapshotFileOnMainThread(const WebFileInfo&, const String& mode, PassRefPtr<WebCore::BlobDataHandle> snapshotBlob);
104
    void didReadDirectoryOnMainThread(const WebVector<WebFileSystemEntry>&, bool hasMore, const String& mode);
106
    void didReadDirectoryOnMainThread(const WebVector<WebFileSystemEntry>&, bool hasMore, const String& mode);
105
107
106
private:
108
private:
107
    WorkerFileSystemCallbacksBridge(WebCore::WorkerLoaderProxy*, WebCore::ScriptExecutionContext*, WebFileSystemCallbacks*);
109
    WorkerFileSystemCallbacksBridge(WebCore::WorkerLoaderProxy*, WebCore::ScriptExecutionContext*, WebFileSystemCallbacksImpl*);
108
110
109
    // Methods that are to be called on the main thread.
111
    // Methods that are to be called on the main thread.
110
    static void openFileSystemOnMainThread(WebCore::ScriptExecutionContext*, WebCommonWorkerClient*, WebFileSystem::Type, long long size, bool create, PassRefPtr<WorkerFileSystemCallbacksBridge>, const String& mode);
112
    static void openFileSystemOnMainThread(WebCore::ScriptExecutionContext*, WebCommonWorkerClient*, WebFileSystem::Type, long long size, bool create, PassRefPtr<WorkerFileSystemCallbacksBridge>, const String& mode);
Lines 118-124 private: Source/WebKit/chromium/src/WorkerFileSystemCallbacksBridge.h_sec5
118
    static void fileExistsOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const WebCore::KURL& path, PassRefPtr<WorkerFileSystemCallbacksBridge>, const String& mode);
120
    static void fileExistsOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const WebCore::KURL& path, PassRefPtr<WorkerFileSystemCallbacksBridge>, const String& mode);
119
    static void directoryExistsOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const WebCore::KURL& path, PassRefPtr<WorkerFileSystemCallbacksBridge>, const String& mode);
121
    static void directoryExistsOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const WebCore::KURL& path, PassRefPtr<WorkerFileSystemCallbacksBridge>, const String& mode);
120
    static void readDirectoryOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const WebCore::KURL& path, PassRefPtr<WorkerFileSystemCallbacksBridge>, const String& mode);
122
    static void readDirectoryOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const WebCore::KURL& path, PassRefPtr<WorkerFileSystemCallbacksBridge>, const String& mode);
121
    static void createSnapshotFileOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const WebCore::KURL& internalBlobURL, const WebCore::KURL& path, PassRefPtr<WorkerFileSystemCallbacksBridge>, const String& mode);
123
    static void createSnapshotFileOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const WebCore::KURL& path, PassRefPtr<WorkerFileSystemCallbacksBridge>, const String& mode);
122
124
123
    friend class MainThreadFileSystemCallbacks;
125
    friend class MainThreadFileSystemCallbacks;
124
126
Lines 127-132 private: Source/WebKit/chromium/src/WorkerFileSystemCallbacksBridge.h_sec6
127
    static void didOpenFileSystemOnWorkerThread(WebCore::ScriptExecutionContext*, PassRefPtr<WorkerFileSystemCallbacksBridge>, const String& name, const WebCore::KURL& rootPath);
129
    static void didOpenFileSystemOnWorkerThread(WebCore::ScriptExecutionContext*, PassRefPtr<WorkerFileSystemCallbacksBridge>, const String& name, const WebCore::KURL& rootPath);
128
    static void didSucceedOnWorkerThread(WebCore::ScriptExecutionContext*, PassRefPtr<WorkerFileSystemCallbacksBridge>);
130
    static void didSucceedOnWorkerThread(WebCore::ScriptExecutionContext*, PassRefPtr<WorkerFileSystemCallbacksBridge>);
129
    static void didReadMetadataOnWorkerThread(WebCore::ScriptExecutionContext*, PassRefPtr<WorkerFileSystemCallbacksBridge>, const WebFileInfo&);
131
    static void didReadMetadataOnWorkerThread(WebCore::ScriptExecutionContext*, PassRefPtr<WorkerFileSystemCallbacksBridge>, const WebFileInfo&);
132
    static void didCreateSnapshotFileOnWorkerThread(WebCore::ScriptExecutionContext*, PassRefPtr<WorkerFileSystemCallbacksBridge>, const WebFileInfo&, PassRefPtr<WebCore::BlobDataHandle> snapshotBlob);
130
    static void didReadDirectoryOnWorkerThread(WebCore::ScriptExecutionContext*, PassRefPtr<WorkerFileSystemCallbacksBridge>, const WebVector<WebFileSystemEntry>&, bool hasMore);
133
    static void didReadDirectoryOnWorkerThread(WebCore::ScriptExecutionContext*, PassRefPtr<WorkerFileSystemCallbacksBridge>, const WebVector<WebFileSystemEntry>&, bool hasMore);
131
134
132
    static void runTaskOnMainThread(WebCore::ScriptExecutionContext*, PassRefPtr<WorkerFileSystemCallbacksBridge>, PassOwnPtr<WebCore::ScriptExecutionContext::Task>);
135
    static void runTaskOnMainThread(WebCore::ScriptExecutionContext*, PassRefPtr<WorkerFileSystemCallbacksBridge>, PassOwnPtr<WebCore::ScriptExecutionContext::Task>);
Lines 146-152 private: Source/WebKit/chromium/src/WorkerFileSystemCallbacksBridge.h_sec7
146
    WorkerFileSystemContextObserver* m_workerContextObserver;
149
    WorkerFileSystemContextObserver* m_workerContextObserver;
147
150
148
    // This is self-destructed and must be fired on the worker thread.
151
    // This is self-destructed and must be fired on the worker thread.
149
    WebFileSystemCallbacks* m_callbacksOnWorkerThread;
152
    WebFileSystemCallbacksImpl* m_callbacksOnWorkerThread;
150
};
153
};
151
154
152
} // namespace WebCore
155
} // namespace WebCore

Return to Bug 108851