1/*
2 * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free
16 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301 USA
18 */
19
20#ifndef PlatformAsyncFileSystemCallbacks_h
21#define PlatformAsyncFileSystemCallbacks_h
22
23#if ENABLE(FILE_SYSTEM)
24#include "AsyncFileSystemCallbacks.h"
25#include "KURL.h"
26
27#include <BlackBerryPlatformWebFileSystem.h>
28#include <wtf/OwnPtr.h>
29#include <wtf/PassOwnPtr.h>
30#include <wtf/text/WTFString.h>
31
32namespace WebCore {
33
34String platformFileSystemTypeToString(BlackBerry::Platform::WebFileSystem::Type);
35
36class AsyncFileSystem;
37class AsyncFileWriter;
38class AsyncFileWriterClient;
39
40class PlatformAsyncFileSystemCallbacks: public BlackBerry::Platform::WebFileSystemCallbacks {
41public:
42    PlatformAsyncFileSystemCallbacks(PassOwnPtr<AsyncFileSystemCallbacks> callbacks, const KURL& rootURL = KURL())
43        : m_callbacks(callbacks)
44        , m_writerClient(0)
45        , m_rootURL(rootURL)
46    {
47    }
48
49    // For createWriter.
50    PlatformAsyncFileSystemCallbacks(PassOwnPtr<AsyncFileSystemCallbacks> callbacks, AsyncFileWriterClient* client)
51        : m_callbacks(callbacks)
52        , m_writerClient(client)
53    {
54    }
55
56    virtual void notifyOpenFileSystem(BlackBerry::Platform::WebFileSystem* platformFileSystem);
57    virtual void notifySucceed();
58    virtual void notifyFail(BlackBerry::Platform::WebFileError);
59    virtual void notifyReadMetadata(const BlackBerry::Platform::WebFileInfo&);
60    virtual void notifyCreateSnapshotFileAndReadMetadata(const BlackBerry::Platform::WebFileInfo&);
61    virtual void notifyReadDirectory(const std::vector<BlackBerry::Platform::WebFileSystemEntry>& entries, bool hasMore);
62    virtual void notifyCreateFileWriter(BlackBerry::Platform::WebFileWriter* platformWriter, long long length);
63    virtual void deleteMe();
64    virtual PassOwnPtr<AsyncFileSystem> createAsyncFileSystem(PassOwnPtr<BlackBerry::Platform::WebFileSystem> platformFileSystem);
65    virtual PassOwnPtr<AsyncFileWriter> createAsyncFileWriter(PassOwnPtr<BlackBerry::Platform::WebFileWriter> platformWriter);
66
67protected:
68    ~PlatformAsyncFileSystemCallbacks() { }
69    OwnPtr<AsyncFileSystemCallbacks> m_callbacks;
70    AsyncFileWriterClient* m_writerClient;
71
72private:
73    KURL m_rootURL;
74};
75
76} // namespace WebCore
77#endif
78#endif
79