2 * Copyright (C) 2010 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
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
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.
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.
31 #ifndef WebFileSystemCallbacks_h
32 #define WebFileSystemCallbacks_h
34 #include "WebCommon.h"
35 #include "WebFileError.h"
36 #include "WebFileSystemEntry.h"
37 #include "WebFileSystemType.h"
38 #include "WebPrivatePtr.h"
39 #include "WebVector.h"
42 class AsyncFileSystemCallbacks;
44 namespace WTF { template <typename T> class PassOwnPtr; }
52 class WebFileSystemCallbacksPrivate;
54 class WebFileSystemCallbacks {
56 ~WebFileSystemCallbacks() { reset(); }
57 WebFileSystemCallbacks() { }
58 WebFileSystemCallbacks(const WebFileSystemCallbacks& c) { assign(c); }
59 WebFileSystemCallbacks& operator=(const WebFileSystemCallbacks& c)
65 BLINK_PLATFORM_EXPORT void reset();
66 BLINK_PLATFORM_EXPORT void assign(const WebFileSystemCallbacks&);
69 BLINK_PLATFORM_EXPORT WebFileSystemCallbacks(const WTF::PassOwnPtr<WebCore::AsyncFileSystemCallbacks>&);
72 // Callback for WebFileSystem's various operations that don't require
74 BLINK_PLATFORM_EXPORT void didSucceed();
76 // Callback for WebFileSystem::readMetadata. Called with the file metadata
77 // for the requested path.
78 BLINK_PLATFORM_EXPORT void didReadMetadata(const WebFileInfo&);
80 // Callback for WebFileSystem::createSnapshot. The metadata also includes the
81 // platform file path.
82 BLINK_PLATFORM_EXPORT void didCreateSnapshotFile(const WebFileInfo&);
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);
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);
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);
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);
104 // Called with an error code when a requested operation hasn't been
106 BLINK_PLATFORM_EXPORT void didFail(WebFileError);
108 // Returns true if the caller expects to be blocked until the request
110 BLINK_PLATFORM_EXPORT bool shouldBlockUntilCompletion() const;
113 WebPrivatePtr<WebFileSystemCallbacksPrivate> m_private;