Home | History | Annotate | Download | only in platform
      1 /*
      2  * Copyright (C) 2010 Google Inc. All rights reserved.
      3  *
      4  * Redistribution and use in source and binary forms, with or without
      5  * modification, are permitted provided that the following conditions are
      6  * met:
      7  *
      8  *     * Redistributions of source code must retain the above copyright
      9  * notice, this list of conditions and the following disclaimer.
     10  *     * Redistributions in binary form must reproduce the above
     11  * copyright notice, this list of conditions and the following disclaimer
     12  * in the documentation and/or other materials provided with the
     13  * distribution.
     14  *     * Neither the name of Google Inc. nor the names of its
     15  * contributors may be used to endorse or promote products derived from
     16  * this software without specific prior written permission.
     17  *
     18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     29  */
     30 
     31 #ifndef WebFileSystemCallbacks_h
     32 #define WebFileSystemCallbacks_h
     33 
     34 #include "WebCommon.h"
     35 #include "WebFileError.h"
     36 #include "WebFileSystemEntry.h"
     37 #include "WebFileSystemType.h"
     38 #include "WebPrivatePtr.h"
     39 #include "WebVector.h"
     40 
     41 namespace WebCore {
     42 class AsyncFileSystemCallbacks;
     43 }
     44 namespace WTF { template <typename T> class PassOwnPtr; }
     45 
     46 namespace blink {
     47 
     48 struct WebFileInfo;
     49 class WebFileWriter;
     50 class WebString;
     51 class WebURL;
     52 class WebFileSystemCallbacksPrivate;
     53 
     54 class WebFileSystemCallbacks {
     55 public:
     56     ~WebFileSystemCallbacks() { reset(); }
     57     WebFileSystemCallbacks() { }
     58     WebFileSystemCallbacks(const WebFileSystemCallbacks& c) { assign(c); }
     59     WebFileSystemCallbacks& operator=(const WebFileSystemCallbacks& c)
     60     {
     61         assign(c);
     62         return *this;
     63     }
     64 
     65     BLINK_PLATFORM_EXPORT void reset();
     66     BLINK_PLATFORM_EXPORT void assign(const WebFileSystemCallbacks&);
     67 
     68 #if INSIDE_BLINK
     69     BLINK_PLATFORM_EXPORT WebFileSystemCallbacks(const WTF::PassOwnPtr<WebCore::AsyncFileSystemCallbacks>&);
     70 #endif
     71 
     72     // Callback for WebFileSystem's various operations that don't require
     73     // return values.
     74     BLINK_PLATFORM_EXPORT void didSucceed();
     75 
     76     // Callback for WebFileSystem::readMetadata. Called with the file metadata
     77     // for the requested path.
     78     BLINK_PLATFORM_EXPORT void didReadMetadata(const WebFileInfo&);
     79 
     80     // Callback for WebFileSystem::createSnapshot. The metadata also includes the
     81     // platform file path.
     82     BLINK_PLATFORM_EXPORT void didCreateSnapshotFile(const WebFileInfo&);
     83 
     84     // Callback for WebFileSystem::readDirectory. Called with a vector of
     85     // file entries in the requested directory. This callback might be called
     86     // multiple times if the directory has many entries. |hasMore| must be
     87     // true when there are more entries.
     88     BLINK_PLATFORM_EXPORT void didReadDirectory(const WebVector<WebFileSystemEntry>&, bool hasMore);
     89 
     90     // Callback for WebFileSystem::openFileSystem. Called with a name and
     91     // root URL for the FileSystem when the request is accepted.
     92     BLINK_PLATFORM_EXPORT void didOpenFileSystem(const WebString& name, const WebURL& rootURL);
     93 
     94     // Callback for WebFileSystem::resolveURL. Called with a name, root URL and
     95     // file path for the FileSystem when the request is accepted. |isDirectory|
     96     // must be true when an entry to be resolved is a directory.
     97     BLINK_PLATFORM_EXPORT void didResolveURL(const WebString& name, const WebURL& rootURL, WebFileSystemType, const WebString& filePath, bool isDirectory);
     98 
     99     // Callback for WebFileSystem::createFileWriter. Called with an instance
    100     // of WebFileWriter and the target file length. The writer's ownership
    101     // is transferred to the callback.
    102     BLINK_PLATFORM_EXPORT void didCreateFileWriter(WebFileWriter*, long long length);
    103 
    104     // Called with an error code when a requested operation hasn't been
    105     // completed.
    106     BLINK_PLATFORM_EXPORT void didFail(WebFileError);
    107 
    108     // Returns true if the caller expects to be blocked until the request
    109     // is fullfilled.
    110     BLINK_PLATFORM_EXPORT bool shouldBlockUntilCompletion() const;
    111 
    112 private:
    113     WebPrivatePtr<WebFileSystemCallbacksPrivate> m_private;
    114 };
    115 
    116 } // namespace blink
    117 
    118 #endif
    119