Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / public / platform / WebFileSystemCallbacks.h
blobe53e87c4410628423b7039fd389ee735dd5bb622
1 /*
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
6 * met:
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.
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"
41 namespace WTF { template <typename T> class PassOwnPtr; }
43 namespace blink {
45 class AsyncFileSystemCallbacks;
46 class WebFileWriter;
47 class WebString;
48 class WebURL;
49 class WebFileSystemCallbacksPrivate;
50 struct WebFileInfo;
52 class WebFileSystemCallbacks {
53 public:
54 ~WebFileSystemCallbacks() { reset(); }
55 WebFileSystemCallbacks() { }
56 WebFileSystemCallbacks(const WebFileSystemCallbacks& c) { assign(c); }
57 WebFileSystemCallbacks& operator=(const WebFileSystemCallbacks& c)
59 assign(c);
60 return *this;
63 BLINK_PLATFORM_EXPORT void reset();
64 BLINK_PLATFORM_EXPORT void assign(const WebFileSystemCallbacks&);
66 #if INSIDE_BLINK
67 BLINK_PLATFORM_EXPORT WebFileSystemCallbacks(const WTF::PassOwnPtr<AsyncFileSystemCallbacks>&);
68 #endif
70 // Callback for WebFileSystem's various operations that don't require
71 // return values.
72 BLINK_PLATFORM_EXPORT void didSucceed();
74 // Callback for WebFileSystem::readMetadata. Called with the file metadata
75 // for the requested path.
76 BLINK_PLATFORM_EXPORT void didReadMetadata(const WebFileInfo&);
78 // Callback for WebFileSystem::createSnapshot. The metadata also includes the
79 // platform file path.
80 BLINK_PLATFORM_EXPORT void didCreateSnapshotFile(const WebFileInfo&);
82 // Callback for WebFileSystem::readDirectory. Called with a vector of
83 // file entries in the requested directory. This callback might be called
84 // multiple times if the directory has many entries. |hasMore| must be
85 // true when there are more entries.
86 BLINK_PLATFORM_EXPORT void didReadDirectory(const WebVector<WebFileSystemEntry>&, bool hasMore);
88 // Callback for WebFileSystem::openFileSystem. Called with a name and
89 // root URL for the FileSystem when the request is accepted.
90 BLINK_PLATFORM_EXPORT void didOpenFileSystem(const WebString& name, const WebURL& rootURL);
92 // Callback for WebFileSystem::resolveURL. Called with a name, root URL and
93 // file path for the FileSystem when the request is accepted. |isDirectory|
94 // must be true when an entry to be resolved is a directory.
95 BLINK_PLATFORM_EXPORT void didResolveURL(const WebString& name, const WebURL& rootURL, WebFileSystemType, const WebString& filePath, bool isDirectory);
97 // Callback for WebFileSystem::createFileWriter. Called with an instance
98 // of WebFileWriter and the target file length. The writer's ownership
99 // is transferred to the callback.
100 BLINK_PLATFORM_EXPORT void didCreateFileWriter(WebFileWriter*, long long length);
102 // Called with an error code when a requested operation hasn't been
103 // completed.
104 BLINK_PLATFORM_EXPORT void didFail(WebFileError);
106 // Returns true if the caller expects to be blocked until the request
107 // is fullfilled.
108 BLINK_PLATFORM_EXPORT bool shouldBlockUntilCompletion() const;
110 private:
111 WebPrivatePtr<WebFileSystemCallbacksPrivate> m_private;
114 } // namespace blink
116 #endif