| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 CHROME_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_CALLBACKS_H_ | 5 #ifndef CHROME_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_CALLBACKS_H_ |
| 6 #define CHROME_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_CALLBACKS_H_ | 6 #define CHROME_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_CALLBACKS_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/ref_counted.h" | 10 #include "base/ref_counted.h" |
| 11 #include "chrome/browser/in_process_webkit/indexed_db_dispatcher_host.h" | 11 #include "chrome/browser/in_process_webkit/indexed_db_dispatcher_host.h" |
| 12 #include "chrome/common/indexed_db_key.h" | 12 #include "chrome/common/indexed_db_messages.h" |
| 13 #include "chrome/common/render_messages.h" | |
| 14 #include "chrome/common/serialized_script_value.h" | |
| 15 #include "third_party/WebKit/WebKit/chromium/public/WebIDBCallbacks.h" | 13 #include "third_party/WebKit/WebKit/chromium/public/WebIDBCallbacks.h" |
| 16 #include "third_party/WebKit/WebKit/chromium/public/WebIDBCursor.h" | 14 #include "third_party/WebKit/WebKit/chromium/public/WebIDBCursor.h" |
| 17 #include "third_party/WebKit/WebKit/chromium/public/WebIDBDatabaseError.h" | 15 #include "third_party/WebKit/WebKit/chromium/public/WebIDBDatabaseError.h" |
| 18 #include "third_party/WebKit/WebKit/chromium/public/WebIDBTransaction.h" | 16 #include "third_party/WebKit/WebKit/chromium/public/WebIDBTransaction.h" |
| 19 #include "third_party/WebKit/WebKit/chromium/public/WebIDBTransactionCallbacks.h
" | 17 #include "third_party/WebKit/WebKit/chromium/public/WebIDBTransactionCallbacks.h
" |
| 20 | 18 |
| 21 // Template magic to figure out what message to send to the renderer based on | 19 // Template magic to figure out what message to send to the renderer based on |
| 22 // which (overloaded) onSuccess method we expect to be called. | 20 // which (overloaded) onSuccess method we expect to be called. |
| 23 template <class Type> struct WebIDBToMsgHelper { }; | 21 template <class Type> struct WebIDBToMsgHelper { }; |
| 24 template <> struct WebIDBToMsgHelper<WebKit::WebIDBDatabase> { | 22 template <> struct WebIDBToMsgHelper<WebKit::WebIDBDatabase> { |
| 25 typedef ViewMsg_IDBCallbacksSuccessIDBDatabase MsgType; | 23 typedef IndexedDBMsg_CallbacksSuccessIDBDatabase MsgType; |
| 26 }; | 24 }; |
| 27 template <> struct WebIDBToMsgHelper<WebKit::WebIDBIndex> { | 25 template <> struct WebIDBToMsgHelper<WebKit::WebIDBIndex> { |
| 28 typedef ViewMsg_IDBCallbacksSuccessIDBIndex MsgType; | 26 typedef IndexedDBMsg_CallbacksSuccessIDBIndex MsgType; |
| 29 }; | 27 }; |
| 30 template <> struct WebIDBToMsgHelper<WebKit::WebIDBObjectStore> { | 28 template <> struct WebIDBToMsgHelper<WebKit::WebIDBObjectStore> { |
| 31 typedef ViewMsg_IDBCallbacksSuccessIDBObjectStore MsgType; | 29 typedef IndexedDBMsg_CallbacksSuccessIDBObjectStore MsgType; |
| 32 }; | 30 }; |
| 33 template <> struct WebIDBToMsgHelper<WebKit::WebIDBTransaction> { | 31 template <> struct WebIDBToMsgHelper<WebKit::WebIDBTransaction> { |
| 34 typedef ViewMsg_IDBCallbacksSuccessIDBTransaction MsgType; | 32 typedef IndexedDBMsg_CallbacksSuccessIDBTransaction MsgType; |
| 35 }; | 33 }; |
| 36 | 34 |
| 37 // The code the following two classes share. | 35 // The code the following two classes share. |
| 38 class IndexedDBCallbacksBase : public WebKit::WebIDBCallbacks { | 36 class IndexedDBCallbacksBase : public WebKit::WebIDBCallbacks { |
| 39 public: | 37 public: |
| 40 IndexedDBCallbacksBase(IndexedDBDispatcherHost* dispatcher_host, | 38 IndexedDBCallbacksBase(IndexedDBDispatcherHost* dispatcher_host, |
| 41 int32 response_id); | 39 int32 response_id); |
| 42 | 40 |
| 43 virtual ~IndexedDBCallbacksBase(); | 41 virtual ~IndexedDBCallbacksBase(); |
| 44 | 42 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 class IndexedDBCallbacks<WebKit::WebIDBCursor> | 81 class IndexedDBCallbacks<WebKit::WebIDBCursor> |
| 84 : public IndexedDBCallbacksBase { | 82 : public IndexedDBCallbacksBase { |
| 85 public: | 83 public: |
| 86 IndexedDBCallbacks( | 84 IndexedDBCallbacks( |
| 87 IndexedDBDispatcherHost* dispatcher_host, int32 response_id) | 85 IndexedDBDispatcherHost* dispatcher_host, int32 response_id) |
| 88 : IndexedDBCallbacksBase(dispatcher_host, response_id) { } | 86 : IndexedDBCallbacksBase(dispatcher_host, response_id) { } |
| 89 | 87 |
| 90 virtual void onSuccess(WebKit::WebIDBCursor* idb_object) { | 88 virtual void onSuccess(WebKit::WebIDBCursor* idb_object) { |
| 91 int32 object_id = dispatcher_host()->Add(idb_object); | 89 int32 object_id = dispatcher_host()->Add(idb_object); |
| 92 dispatcher_host()->Send( | 90 dispatcher_host()->Send( |
| 93 new ViewMsg_IDBCallbacksSuccessIDBCursor(response_id(), object_id)); | 91 new IndexedDBMsg_CallbacksSuccessIDBCursor(response_id(), object_id)); |
| 94 } | 92 } |
| 95 | 93 |
| 96 virtual void onSuccess() { | 94 virtual void onSuccess() { |
| 97 dispatcher_host()->Send(new ViewMsg_IDBCallbacksSuccessNull(response_id())); | 95 dispatcher_host()->Send(new IndexedDBMsg_CallbacksSuccessNull( |
| 96 response_id())); |
| 98 } | 97 } |
| 99 | 98 |
| 100 private: | 99 private: |
| 101 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks); | 100 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks); |
| 102 }; | 101 }; |
| 103 | 102 |
| 104 // WebIDBKey is implemented in WebKit as opposed to being an interface Chromium | 103 // WebIDBKey is implemented in WebKit as opposed to being an interface Chromium |
| 105 // implements. Thus we pass a const ___& version and thus we need this | 104 // implements. Thus we pass a const ___& version and thus we need this |
| 106 // specialization. | 105 // specialization. |
| 107 template <> | 106 template <> |
| 108 class IndexedDBCallbacks<WebKit::WebIDBKey> | 107 class IndexedDBCallbacks<WebKit::WebIDBKey> |
| 109 : public IndexedDBCallbacksBase { | 108 : public IndexedDBCallbacksBase { |
| 110 public: | 109 public: |
| 111 IndexedDBCallbacks( | 110 IndexedDBCallbacks( |
| 112 IndexedDBDispatcherHost* dispatcher_host, int32 response_id) | 111 IndexedDBDispatcherHost* dispatcher_host, int32 response_id) |
| 113 : IndexedDBCallbacksBase(dispatcher_host, response_id) { } | 112 : IndexedDBCallbacksBase(dispatcher_host, response_id) { } |
| 114 | 113 |
| 115 virtual void onSuccess(const WebKit::WebIDBKey& value) { | 114 virtual void onSuccess(const WebKit::WebIDBKey& value) { |
| 116 dispatcher_host()->Send( | 115 dispatcher_host()->Send( |
| 117 new ViewMsg_IDBCallbacksSuccessIndexedDBKey( | 116 new IndexedDBMsg_CallbacksSuccessIndexedDBKey( |
| 118 response_id(), IndexedDBKey(value))); | 117 response_id(), IndexedDBKey(value))); |
| 119 } | 118 } |
| 120 | 119 |
| 121 private: | 120 private: |
| 122 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks); | 121 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks); |
| 123 }; | 122 }; |
| 124 | 123 |
| 125 // WebSerializedScriptValue is implemented in WebKit as opposed to being an | 124 // WebSerializedScriptValue is implemented in WebKit as opposed to being an |
| 126 // interface Chromium implements. Thus we pass a const ___& version and thus | 125 // interface Chromium implements. Thus we pass a const ___& version and thus |
| 127 // we need this specialization. | 126 // we need this specialization. |
| 128 template <> | 127 template <> |
| 129 class IndexedDBCallbacks<WebKit::WebSerializedScriptValue> | 128 class IndexedDBCallbacks<WebKit::WebSerializedScriptValue> |
| 130 : public IndexedDBCallbacksBase { | 129 : public IndexedDBCallbacksBase { |
| 131 public: | 130 public: |
| 132 IndexedDBCallbacks( | 131 IndexedDBCallbacks( |
| 133 IndexedDBDispatcherHost* dispatcher_host, int32 response_id) | 132 IndexedDBDispatcherHost* dispatcher_host, int32 response_id) |
| 134 : IndexedDBCallbacksBase(dispatcher_host, response_id) { } | 133 : IndexedDBCallbacksBase(dispatcher_host, response_id) { } |
| 135 | 134 |
| 136 virtual void onSuccess(const WebKit::WebSerializedScriptValue& value) { | 135 virtual void onSuccess(const WebKit::WebSerializedScriptValue& value) { |
| 137 dispatcher_host()->Send( | 136 dispatcher_host()->Send( |
| 138 new ViewMsg_IDBCallbacksSuccessSerializedScriptValue( | 137 new IndexedDBMsg_CallbacksSuccessSerializedScriptValue( |
| 139 response_id(), SerializedScriptValue(value))); | 138 response_id(), SerializedScriptValue(value))); |
| 140 } | 139 } |
| 141 | 140 |
| 142 private: | 141 private: |
| 143 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks); | 142 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks); |
| 144 }; | 143 }; |
| 145 | 144 |
| 146 // A WebIDBCallbacks implementation that doesn't return a result. | 145 // A WebIDBCallbacks implementation that doesn't return a result. |
| 147 template <> | 146 template <> |
| 148 class IndexedDBCallbacks<void> : public IndexedDBCallbacksBase { | 147 class IndexedDBCallbacks<void> : public IndexedDBCallbacksBase { |
| 149 public: | 148 public: |
| 150 IndexedDBCallbacks( | 149 IndexedDBCallbacks( |
| 151 IndexedDBDispatcherHost* dispatcher_host, int32 response_id) | 150 IndexedDBDispatcherHost* dispatcher_host, int32 response_id) |
| 152 : IndexedDBCallbacksBase(dispatcher_host, response_id) { } | 151 : IndexedDBCallbacksBase(dispatcher_host, response_id) { } |
| 153 | 152 |
| 154 virtual void onSuccess() { | 153 virtual void onSuccess() { |
| 155 dispatcher_host()->Send( | 154 dispatcher_host()->Send( |
| 156 new ViewMsg_IDBCallbacksSuccessNull(response_id())); | 155 new IndexedDBMsg_CallbacksSuccessNull(response_id())); |
| 157 } | 156 } |
| 158 | 157 |
| 159 private: | 158 private: |
| 160 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks); | 159 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks); |
| 161 }; | 160 }; |
| 162 | 161 |
| 163 class IndexedDBTransactionCallbacks | 162 class IndexedDBTransactionCallbacks |
| 164 : public WebKit::WebIDBTransactionCallbacks { | 163 : public WebKit::WebIDBTransactionCallbacks { |
| 165 public: | 164 public: |
| 166 IndexedDBTransactionCallbacks(IndexedDBDispatcherHost* dispatcher_host, | 165 IndexedDBTransactionCallbacks(IndexedDBDispatcherHost* dispatcher_host, |
| 167 int transaction_id); | 166 int transaction_id); |
| 168 | 167 |
| 169 virtual ~IndexedDBTransactionCallbacks(); | 168 virtual ~IndexedDBTransactionCallbacks(); |
| 170 | 169 |
| 171 virtual void onAbort(); | 170 virtual void onAbort(); |
| 172 | 171 |
| 173 virtual void onComplete(); | 172 virtual void onComplete(); |
| 174 | 173 |
| 175 virtual void onTimeout(); | 174 virtual void onTimeout(); |
| 176 | 175 |
| 177 private: | 176 private: |
| 178 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host_; | 177 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host_; |
| 179 int transaction_id_; | 178 int transaction_id_; |
| 180 }; | 179 }; |
| 181 | 180 |
| 182 #endif // CHROME_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_CALLBACKS_H_ | 181 #endif // CHROME_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_CALLBACKS_H_ |
| OLD | NEW |