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 "WebFileError.h"
     35 #include "WebFileSystemEntry.h"
     36 #include "WebVector.h"
     37 
     38 namespace WebKit {
     39 
     40 struct WebFileInfo;
     41 class WebFileWriter;
     42 class WebString;
     43 class WebURL;
     44 
     45 class WebFileSystemCallbacks {
     46 public:
     47     // Callback for WebFileSystem's various operations that don't require
     48     // return values.
     49     virtual void didSucceed() = 0;
     50 
     51     // Callback for WebFileSystem::readMetadata. Called with the file metadata
     52     // for the requested path.
     53     virtual void didReadMetadata(const WebFileInfo&) = 0;
     54 
     55     // Callback for WebFileSystem::createSnapshot. The metadata also includes the
     56     // platform file path.
     57     virtual void didCreateSnapshotFile(const WebFileInfo&) { WEBKIT_ASSERT_NOT_REACHED(); }
     58 
     59     // Callback for WebFileSystem::readDirectory. Called with a vector of
     60     // file entries in the requested directory. This callback might be called
     61     // multiple times if the directory has many entries. |hasMore| must be
     62     // true when there are more entries.
     63     virtual void didReadDirectory(const WebVector<WebFileSystemEntry>&, bool hasMore) = 0;
     64 
     65     // Callback for WebFrameClient::openFileSystem. Called with a name and
     66     // root URL for the FileSystem when the request is accepted.
     67     virtual void didOpenFileSystem(const WebString& name, const WebURL& rootURL) = 0;
     68 
     69     // Callback for WebFrameClient::createFileWriter. Called with an instance
     70     // of WebFileWriter and the target file length. The writer's ownership
     71     // is transferred to the callback.
     72     virtual void didCreateFileWriter(WebFileWriter* writer, long long length) { WEBKIT_ASSERT_NOT_REACHED(); }
     73 
     74     // Called with an error code when a requested operation hasn't been
     75     // completed.
     76     virtual void didFail(WebFileError) = 0;
     77 
     78     // Returns true if the caller expects to be blocked until the request
     79     // is fullfilled.
     80     virtual bool shouldBlockUntilCompletion() const = 0;
     81 
     82 protected:
     83     virtual ~WebFileSystemCallbacks() { }
     84 };
     85 
     86 } // namespace WebKit
     87 
     88 #endif
     89