2 * Copyright (C) 2010 Apple 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
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
26 #ifndef WebDatabaseManagerProxy_h
27 #define WebDatabaseManagerProxy_h
29 #if ENABLE(SQL_DATABASE)
31 #include "APIObject.h"
32 #include "Arguments.h"
33 #include "GenericCallback.h"
34 #include "OriginAndDatabases.h"
35 #include "WebDatabaseManagerProxyClient.h"
36 #include <wtf/HashMap.h>
37 #include <wtf/PassRefPtr.h>
40 class ArgumentDecoder;
48 class WebProcessProxy;
49 class WebSecurityOrigin;
51 typedef GenericCallback<WKArrayRef> ArrayCallback;
52 #if ENABLE(TIZEN_SQL_DATABASE)
53 typedef GenericCallback<WKStringRef, StringImpl*> DatabaseStringCallback;
54 typedef GenericCallback<WKUInt64Ref> DatabaseUInt64Callback;
57 class WebDatabaseManagerProxy : public APIObject {
59 static const Type APIType = TypeDatabaseManager;
61 static PassRefPtr<WebDatabaseManagerProxy> create(WebContext*);
62 virtual ~WebDatabaseManagerProxy();
65 void clearContext() { m_webContext = 0; }
67 void initializeClient(const WKDatabaseManagerClient*);
69 void getDatabasesByOrigin(PassRefPtr<ArrayCallback>);
70 void getDatabaseOrigins(PassRefPtr<ArrayCallback>);
71 void deleteDatabaseWithNameForOrigin(const String& databaseIdentifier, WebSecurityOrigin*);
72 void deleteDatabasesForOrigin(WebSecurityOrigin*);
73 void deleteAllDatabases();
74 #if ENABLE(TIZEN_SQL_DATABASE)
75 void getDatabasePath(PassRefPtr<DatabaseStringCallback>);
76 void getQuotaForOrigin(PassRefPtr<DatabaseUInt64Callback>, WebSecurityOrigin*);
77 void getUsageForOrigin(PassRefPtr<DatabaseUInt64Callback>, WebSecurityOrigin*);
79 void setQuotaForOrigin(WebSecurityOrigin*, uint64_t quota);
81 static String originKey();
82 static String originQuotaKey();
83 static String originUsageKey();
84 static String databaseDetailsKey();
85 static String databaseDetailsNameKey();
86 static String databaseDetailsDisplayNameKey();
87 static String databaseDetailsExpectedUsageKey();
88 static String databaseDetailsCurrentUsageKey();
90 void didReceiveWebDatabaseManagerProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
92 bool shouldTerminate(WebProcessProxy*) const;
95 explicit WebDatabaseManagerProxy(WebContext*);
97 virtual Type type() const { return APIType; }
100 void didGetDatabasesByOrigin(const Vector<OriginAndDatabases>& originAndDatabases, uint64_t callbackID);
101 void didGetDatabaseOrigins(const Vector<String>& originIdentifiers, uint64_t callbackID);
102 #if ENABLE(TIZEN_SQL_DATABASE)
103 void didGetDatabasePath(const String& path, uint64_t callbackID);
104 void didGetQuotaForOrigin(const uint64_t quota, uint64_t callbackID);
105 void didGetUsageForOrigin(const uint64_t usage, uint64_t callbackID);
107 void didModifyOrigin(const String& originIdentifier);
108 void didModifyDatabase(const String& originIdentifier, const String& databaseIdentifier);
110 WebContext* m_webContext;
111 HashMap<uint64_t, RefPtr<ArrayCallback> > m_arrayCallbacks;
112 #if ENABLE(TIZEN_SQL_DATABASE)
113 HashMap<uint64_t, RefPtr<DatabaseStringCallback> > m_databaseStringCallbacks;
114 HashMap<uint64_t, RefPtr<DatabaseUInt64Callback> > m_databaseUInt64Callbacks;
117 WebDatabaseManagerProxyClient m_client;
120 } // namespace WebKit
122 #endif // ENABLE(SQL_DATABASE)
124 #endif // DatabaseManagerProxy_h