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