Merge "Use EwkView's variables instead of drawingScaleFactor and drawingScrollPositio...
[framework/web/webkit-efl.git] / Source / WebKit2 / UIProcess / WebDatabaseManagerProxy.h
1 /*
2  * Copyright (C) 2010 Apple 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
6  * are met:
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.
12  *
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.
24  */
25
26 #ifndef WebDatabaseManagerProxy_h
27 #define WebDatabaseManagerProxy_h
28
29 #if ENABLE(SQL_DATABASE)
30
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>
38
39 namespace CoreIPC {
40 class ArgumentDecoder;
41 class Connection;
42 class MessageID;
43 }
44
45 namespace WebKit {
46
47 class WebContext;
48 class WebProcessProxy;
49 class WebSecurityOrigin;
50
51 typedef GenericCallback<WKArrayRef> ArrayCallback;
52 #if ENABLE(TIZEN_SQL_DATABASE)
53 typedef GenericCallback<WKStringRef, StringImpl*> DatabaseStringCallback;
54 typedef GenericCallback<WKUInt64Ref> DatabaseUInt64Callback;
55 #endif
56
57 class WebDatabaseManagerProxy : public APIObject {
58 public:
59     static const Type APIType = TypeDatabaseManager;
60
61     static PassRefPtr<WebDatabaseManagerProxy> create(WebContext*);
62     virtual ~WebDatabaseManagerProxy();
63
64     void invalidate();
65     void clearContext() { m_webContext = 0; }
66
67     void initializeClient(const WKDatabaseManagerClient*);
68
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*);
78 #endif
79     void setQuotaForOrigin(WebSecurityOrigin*, uint64_t quota);
80     
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();
89
90     void didReceiveWebDatabaseManagerProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
91
92     bool shouldTerminate(WebProcessProxy*) const;
93
94 private:
95     explicit WebDatabaseManagerProxy(WebContext*);
96
97     virtual Type type() const { return APIType; }
98
99     // Message handlers.
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);
106 #endif
107     void didModifyOrigin(const String& originIdentifier);
108     void didModifyDatabase(const String& originIdentifier, const String& databaseIdentifier);
109
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;
115 #endif
116
117     WebDatabaseManagerProxyClient m_client;
118 };
119
120 } // namespace WebKit
121
122 #endif // ENABLE(SQL_DATABASE)
123
124 #endif // DatabaseManagerProxy_h