Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(393)

Side by Side Diff: content/browser/in_process_webkit/indexed_db_callbacks.h

Issue 17840006: Move IndexedDB files out of in_process_webkit (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_CALLBACKS_H_
6 #define CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_CALLBACKS_H_
7
8 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h"
10 #include "content/browser/in_process_webkit/indexed_db_dispatcher_host.h"
11 #include "googleurl/src/gurl.h"
12 #include "third_party/WebKit/public/platform/WebIDBCallbacks.h"
13 #include "third_party/WebKit/public/platform/WebIDBDatabase.h"
14 #include "third_party/WebKit/public/platform/WebIDBDatabaseError.h"
15 #include "third_party/WebKit/public/platform/WebString.h"
16
17 namespace content {
18 class WebIDBCursorImpl;
19 class WebIDBDatabaseImpl;
20 struct IndexedDBDatabaseMetadata;
21
22 class IndexedDBCallbacksBase {
23 public:
24 virtual ~IndexedDBCallbacksBase();
25
26 virtual void onError(const WebKit::WebIDBDatabaseError& error);
27 virtual void onBlocked(long long old_version);
28
29 // implemented by subclasses, but need to be called later
30 virtual void onSuccess(const std::vector<string16>& value);
31 virtual void onSuccess(WebIDBDatabaseImpl* idb_object,
32 const IndexedDBDatabaseMetadata& metadata);
33 virtual void onUpgradeNeeded(long long old_version,
34 WebIDBDatabaseImpl* database,
35 const IndexedDBDatabaseMetadata&,
36 WebKit::WebIDBCallbacks::DataLoss data_loss);
37 virtual void onSuccess(WebIDBCursorImpl* idb_object,
38 const IndexedDBKey& key,
39 const IndexedDBKey& primaryKey,
40 std::vector<char>* value);
41 virtual void onSuccess(const IndexedDBKey& key,
42 const IndexedDBKey& primaryKey,
43 std::vector<char>* value);
44 virtual void onSuccess(std::vector<char>* value);
45 virtual void onSuccessWithPrefetch(
46 const std::vector<IndexedDBKey>& keys,
47 const std::vector<IndexedDBKey>& primaryKeys,
48 const std::vector<std::vector<char> >& values);
49 virtual void onSuccess(const IndexedDBKey& value);
50 virtual void onSuccess(std::vector<char>* value,
51 const IndexedDBKey& key,
52 const IndexedDBKeyPath& keyPath);
53 virtual void onSuccess(long long value);
54 virtual void onSuccess();
55
56 protected:
57 IndexedDBCallbacksBase(IndexedDBDispatcherHost* dispatcher_host,
58 int32 ipc_thread_id,
59 int32 ipc_callbacks_id);
60 IndexedDBDispatcherHost* dispatcher_host() const {
61 return dispatcher_host_.get();
62 }
63 int32 ipc_thread_id() const { return ipc_thread_id_; }
64 int32 ipc_callbacks_id() const { return ipc_callbacks_id_; }
65
66 private:
67 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host_;
68 int32 ipc_callbacks_id_;
69 int32 ipc_thread_id_;
70
71 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacksBase);
72 };
73
74 // TODO(dgrogan): Remove this class and change the remaining specializations
75 // into subclasses of IndexedDBCallbacksBase.
76 template <class WebObjectType>
77 class IndexedDBCallbacks : public IndexedDBCallbacksBase {
78 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks);
79 };
80
81 class IndexedDBCallbacksDatabase : public IndexedDBCallbacksBase {
82 public:
83 IndexedDBCallbacksDatabase(IndexedDBDispatcherHost* dispatcher_host,
84 int32 ipc_thread_id,
85 int32 ipc_callbacks_id,
86 int32 ipc_database_callbacks_id,
87 int64 host_transaction_id,
88 const GURL& origin_url);
89
90 virtual void onSuccess(WebIDBDatabaseImpl* idb_object,
91 const IndexedDBDatabaseMetadata& metadata) OVERRIDE;
92 virtual void onUpgradeNeeded(long long old_version,
93 WebIDBDatabaseImpl* database,
94 const IndexedDBDatabaseMetadata&,
95 WebKit::WebIDBCallbacks::DataLoss data_loss)
96 OVERRIDE;
97
98 private:
99 int64 host_transaction_id_;
100 GURL origin_url_;
101 int32 ipc_database_id_;
102 int32 ipc_database_callbacks_id_;
103 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacksDatabase);
104 };
105
106 // WebIDBCursorImpl uses:
107 // * onSuccess(WebIDBCursorImpl*, WebIDBKey, WebIDBKey, WebData)
108 // when an openCursor()/openKeyCursor() call has succeeded,
109 // * onSuccess(WebIDBKey, WebIDBKey, WebData)
110 // when an advance()/continue() call has succeeded, or
111 // * onSuccess()
112 // to indicate it does not contain any data, i.e., there is no key within
113 // the key range, or it has reached the end.
114 template <>
115 class IndexedDBCallbacks<WebIDBCursorImpl> : public IndexedDBCallbacksBase {
116 public:
117 IndexedDBCallbacks(IndexedDBDispatcherHost* dispatcher_host,
118 int32 ipc_thread_id,
119 int32 ipc_callbacks_id,
120 int32 ipc_cursor_id)
121 : IndexedDBCallbacksBase(dispatcher_host,
122 ipc_thread_id,
123 ipc_callbacks_id),
124 ipc_cursor_id_(ipc_cursor_id) {}
125
126 virtual void onSuccess(WebIDBCursorImpl* idb_object,
127 const IndexedDBKey& key,
128 const IndexedDBKey& primaryKey,
129 std::vector<char>* value);
130 virtual void onSuccess(const IndexedDBKey& key,
131 const IndexedDBKey& primaryKey,
132 std::vector<char>* value);
133 virtual void onSuccess(std::vector<char>* value);
134 virtual void onSuccessWithPrefetch(
135 const std::vector<IndexedDBKey>& keys,
136 const std::vector<IndexedDBKey>& primaryKeys,
137 const std::vector<std::vector<char> >& values);
138
139 private:
140 // The id of the cursor this callback concerns, or -1 if the cursor
141 // does not exist yet.
142 int32 ipc_cursor_id_;
143
144 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks);
145 };
146
147 // WebIDBKey is implemented in WebKit as opposed to being an interface Chromium
148 // implements. Thus we pass a const ___& version and thus we need this
149 // specialization.
150 template <>
151 class IndexedDBCallbacks<IndexedDBKey> : public IndexedDBCallbacksBase {
152 public:
153 IndexedDBCallbacks(IndexedDBDispatcherHost* dispatcher_host,
154 int32 ipc_thread_id,
155 int32 ipc_callbacks_id)
156 : IndexedDBCallbacksBase(dispatcher_host,
157 ipc_thread_id,
158 ipc_callbacks_id) {}
159
160 virtual void onSuccess(const IndexedDBKey& value);
161
162 private:
163 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks);
164 };
165
166 template <>
167 class IndexedDBCallbacks<
168 std::vector<string16> > : public IndexedDBCallbacksBase {
169 public:
170 IndexedDBCallbacks(IndexedDBDispatcherHost* dispatcher_host,
171 int32 ipc_thread_id,
172 int32 ipc_callbacks_id)
173 : IndexedDBCallbacksBase(dispatcher_host,
174 ipc_thread_id,
175 ipc_callbacks_id) {}
176
177 virtual void onSuccess(const std::vector<string16>& value);
178
179 private:
180 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks);
181 };
182
183 // WebData is implemented in WebKit as opposed to being an interface
184 // Chromium implements. Thus we pass a const ___& version and thus we
185 // need this specialization.
186 template <>
187 class IndexedDBCallbacks<std::vector<char> > : public IndexedDBCallbacksBase {
188 public:
189 IndexedDBCallbacks(IndexedDBDispatcherHost* dispatcher_host,
190 int32 ipc_thread_id,
191 int32 ipc_callbacks_id)
192 : IndexedDBCallbacksBase(dispatcher_host,
193 ipc_thread_id,
194 ipc_callbacks_id) {}
195
196 virtual void onSuccess(std::vector<char>* value);
197 virtual void onSuccess(std::vector<char>* value,
198 const IndexedDBKey& key,
199 const IndexedDBKeyPath& keyPath);
200 virtual void onSuccess(long long value);
201 virtual void onSuccess();
202 virtual void onSuccess(const IndexedDBKey& value);
203
204 private:
205 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks);
206 };
207
208 } // namespace content
209
210 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_CALLBACKS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698