193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)/*
293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * Copyright (C) 2010 Google Inc. All rights reserved.
393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) *
493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * Redistribution and use in source and binary forms, with or without
593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * modification, are permitted provided that the following conditions are
693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * met:
793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) *
893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) *     * Redistributions of source code must retain the above copyright
993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * notice, this list of conditions and the following disclaimer.
1093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) *     * Redistributions in binary form must reproduce the above
1193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * copyright notice, this list of conditions and the following disclaimer
1293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * in the documentation and/or other materials provided with the
1393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * distribution.
1493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) *     * Neither the name of Google Inc. nor the names of its
1593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * contributors may be used to endorse or promote products derived from
1693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * this software without specific prior written permission.
1793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) *
1893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) */
3093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
3193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#ifndef WebFileSystemCallbacks_h
3293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#define WebFileSystemCallbacks_h
3393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
348abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)#include "WebCommon.h"
3593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#include "WebFileError.h"
3693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#include "WebFileSystemEntry.h"
379bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles)#include "WebFileSystemType.h"
388abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)#include "WebPrivatePtr.h"
3993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#include "WebVector.h"
4093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
418abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)namespace WTF { template <typename T> class PassOwnPtr; }
428abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)
4351b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)namespace blink {
4493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
45e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)class AsyncFileSystemCallbacks;
46e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdochclass WebFileWriter;
4793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)class WebString;
4893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)class WebURL;
498abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)class WebFileSystemCallbacksPrivate;
50e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)struct WebFileInfo;
5193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
5293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)class WebFileSystemCallbacks {
5393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)public:
548abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)    ~WebFileSystemCallbacks() { reset(); }
558abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)    WebFileSystemCallbacks() { }
568abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)    WebFileSystemCallbacks(const WebFileSystemCallbacks& c) { assign(c); }
578abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)    WebFileSystemCallbacks& operator=(const WebFileSystemCallbacks& c)
588abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)    {
598abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)        assign(c);
608abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)        return *this;
618abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)    }
628abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)
63f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles)    BLINK_PLATFORM_EXPORT void reset();
64f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles)    BLINK_PLATFORM_EXPORT void assign(const WebFileSystemCallbacks&);
658abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)
66f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles)#if INSIDE_BLINK
67e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)    BLINK_PLATFORM_EXPORT WebFileSystemCallbacks(const WTF::PassOwnPtr<AsyncFileSystemCallbacks>&);
688abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)#endif
698abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)
7093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    // Callback for WebFileSystem's various operations that don't require
7193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    // return values.
72f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles)    BLINK_PLATFORM_EXPORT void didSucceed();
7393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
7493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    // Callback for WebFileSystem::readMetadata. Called with the file metadata
7593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    // for the requested path.
76f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles)    BLINK_PLATFORM_EXPORT void didReadMetadata(const WebFileInfo&);
7793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
7893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    // Callback for WebFileSystem::createSnapshot. The metadata also includes the
7993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    // platform file path.
80f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles)    BLINK_PLATFORM_EXPORT void didCreateSnapshotFile(const WebFileInfo&);
8193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
8293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    // Callback for WebFileSystem::readDirectory. Called with a vector of
8393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    // file entries in the requested directory. This callback might be called
8493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    // multiple times if the directory has many entries. |hasMore| must be
8593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    // true when there are more entries.
86f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles)    BLINK_PLATFORM_EXPORT void didReadDirectory(const WebVector<WebFileSystemEntry>&, bool hasMore);
8793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
88e1f1df5f01594c0e62e751e4b46e779b85c2faa5Torne (Richard Coles)    // Callback for WebFileSystem::openFileSystem. Called with a name and
8993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    // root URL for the FileSystem when the request is accepted.
90f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles)    BLINK_PLATFORM_EXPORT void didOpenFileSystem(const WebString& name, const WebURL& rootURL);
9193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
929bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles)    // Callback for WebFileSystem::resolveURL. Called with a name, root URL and
939bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles)    // file path for the FileSystem when the request is accepted. |isDirectory|
949bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles)    // must be true when an entry to be resolved is a directory.
95f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles)    BLINK_PLATFORM_EXPORT void didResolveURL(const WebString& name, const WebURL& rootURL, WebFileSystemType, const WebString& filePath, bool isDirectory);
969bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles)
97e1f1df5f01594c0e62e751e4b46e779b85c2faa5Torne (Richard Coles)    // Callback for WebFileSystem::createFileWriter. Called with an instance
98e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    // of WebFileWriter and the target file length. The writer's ownership
99e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    // is transferred to the callback.
100f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles)    BLINK_PLATFORM_EXPORT void didCreateFileWriter(WebFileWriter*, long long length);
101e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch
10293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    // Called with an error code when a requested operation hasn't been
10393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    // completed.
104f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles)    BLINK_PLATFORM_EXPORT void didFail(WebFileError);
10593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
106e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    // Returns true if the caller expects to be blocked until the request
107e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    // is fullfilled.
108f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles)    BLINK_PLATFORM_EXPORT bool shouldBlockUntilCompletion() const;
109e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch
1108abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)private:
1118abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)    WebPrivatePtr<WebFileSystemCallbacksPrivate> m_private;
11293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)};
11393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
11451b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)} // namespace blink
11593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
11693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#endif
117