| 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_messages.h" | |
| 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCallbacks.h" | 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCallbacks.h" |
| 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCursor.h" | 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCursor.h" |
| 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseError.h
" | 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseError.h
" |
| 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBTransaction.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBTransaction.h" |
| 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBTransactionCall
backs.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBTransactionCall
backs.h" |
| 18 | 17 |
| 18 class IndexedDBMsg_CallbacksSuccessIDBDatabase; |
| 19 class IndexedDBMsg_CallbacksSuccessIDBIndex; |
| 20 class IndexedDBMsg_CallbacksSuccessIDBObjectStore; |
| 21 class IndexedDBMsg_CallbacksSuccessIDBTransaction; |
| 22 |
| 19 // Template magic to figure out what message to send to the renderer based on | 23 // Template magic to figure out what message to send to the renderer based on |
| 20 // which (overloaded) onSuccess method we expect to be called. | 24 // which (overloaded) onSuccess method we expect to be called. |
| 21 template <class Type> struct WebIDBToMsgHelper { }; | 25 template <class Type> struct WebIDBToMsgHelper { }; |
| 22 template <> struct WebIDBToMsgHelper<WebKit::WebIDBDatabase> { | 26 template <> struct WebIDBToMsgHelper<WebKit::WebIDBDatabase> { |
| 23 typedef IndexedDBMsg_CallbacksSuccessIDBDatabase MsgType; | 27 typedef IndexedDBMsg_CallbacksSuccessIDBDatabase MsgType; |
| 24 }; | 28 }; |
| 25 template <> struct WebIDBToMsgHelper<WebKit::WebIDBIndex> { | 29 template <> struct WebIDBToMsgHelper<WebKit::WebIDBIndex> { |
| 26 typedef IndexedDBMsg_CallbacksSuccessIDBIndex MsgType; | 30 typedef IndexedDBMsg_CallbacksSuccessIDBIndex MsgType; |
| 27 }; | 31 }; |
| 28 template <> struct WebIDBToMsgHelper<WebKit::WebIDBObjectStore> { | 32 template <> struct WebIDBToMsgHelper<WebKit::WebIDBObjectStore> { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 // onSuccess() without params to indicate it does not contain any data, i.e., | 82 // onSuccess() without params to indicate it does not contain any data, i.e., |
| 79 // there is no key within the key range, or it has reached the end. | 83 // there is no key within the key range, or it has reached the end. |
| 80 template <> | 84 template <> |
| 81 class IndexedDBCallbacks<WebKit::WebIDBCursor> | 85 class IndexedDBCallbacks<WebKit::WebIDBCursor> |
| 82 : public IndexedDBCallbacksBase { | 86 : public IndexedDBCallbacksBase { |
| 83 public: | 87 public: |
| 84 IndexedDBCallbacks( | 88 IndexedDBCallbacks( |
| 85 IndexedDBDispatcherHost* dispatcher_host, int32 response_id) | 89 IndexedDBDispatcherHost* dispatcher_host, int32 response_id) |
| 86 : IndexedDBCallbacksBase(dispatcher_host, response_id) { } | 90 : IndexedDBCallbacksBase(dispatcher_host, response_id) { } |
| 87 | 91 |
| 88 virtual void onSuccess(WebKit::WebIDBCursor* idb_object) { | 92 virtual void onSuccess(WebKit::WebIDBCursor* idb_object); |
| 89 int32 object_id = dispatcher_host()->Add(idb_object); | 93 virtual void onSuccess(const WebKit::WebSerializedScriptValue& value); |
| 90 dispatcher_host()->Send( | |
| 91 new IndexedDBMsg_CallbacksSuccessIDBCursor(response_id(), object_id)); | |
| 92 } | |
| 93 | |
| 94 virtual void onSuccess(const WebKit::WebSerializedScriptValue& value) { | |
| 95 dispatcher_host()->Send( | |
| 96 new IndexedDBMsg_CallbacksSuccessSerializedScriptValue( | |
| 97 response_id(), SerializedScriptValue(value))); | |
| 98 } | |
| 99 | 94 |
| 100 private: | 95 private: |
| 101 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks); | 96 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks); |
| 102 }; | 97 }; |
| 103 | 98 |
| 104 // WebIDBKey is implemented in WebKit as opposed to being an interface Chromium | 99 // 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 | 100 // implements. Thus we pass a const ___& version and thus we need this |
| 106 // specialization. | 101 // specialization. |
| 107 template <> | 102 template <> |
| 108 class IndexedDBCallbacks<WebKit::WebIDBKey> | 103 class IndexedDBCallbacks<WebKit::WebIDBKey> |
| 109 : public IndexedDBCallbacksBase { | 104 : public IndexedDBCallbacksBase { |
| 110 public: | 105 public: |
| 111 IndexedDBCallbacks( | 106 IndexedDBCallbacks( |
| 112 IndexedDBDispatcherHost* dispatcher_host, int32 response_id) | 107 IndexedDBDispatcherHost* dispatcher_host, int32 response_id) |
| 113 : IndexedDBCallbacksBase(dispatcher_host, response_id) { } | 108 : IndexedDBCallbacksBase(dispatcher_host, response_id) { } |
| 114 | 109 |
| 115 virtual void onSuccess(const WebKit::WebIDBKey& value) { | 110 virtual void onSuccess(const WebKit::WebIDBKey& value); |
| 116 dispatcher_host()->Send( | |
| 117 new IndexedDBMsg_CallbacksSuccessIndexedDBKey( | |
| 118 response_id(), IndexedDBKey(value))); | |
| 119 } | |
| 120 | 111 |
| 121 private: | 112 private: |
| 122 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks); | 113 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks); |
| 123 }; | 114 }; |
| 124 | 115 |
| 125 // WebSerializedScriptValue is implemented in WebKit as opposed to being an | 116 // WebSerializedScriptValue is implemented in WebKit as opposed to being an |
| 126 // interface Chromium implements. Thus we pass a const ___& version and thus | 117 // interface Chromium implements. Thus we pass a const ___& version and thus |
| 127 // we need this specialization. | 118 // we need this specialization. |
| 128 template <> | 119 template <> |
| 129 class IndexedDBCallbacks<WebKit::WebSerializedScriptValue> | 120 class IndexedDBCallbacks<WebKit::WebSerializedScriptValue> |
| 130 : public IndexedDBCallbacksBase { | 121 : public IndexedDBCallbacksBase { |
| 131 public: | 122 public: |
| 132 IndexedDBCallbacks( | 123 IndexedDBCallbacks( |
| 133 IndexedDBDispatcherHost* dispatcher_host, int32 response_id) | 124 IndexedDBDispatcherHost* dispatcher_host, int32 response_id) |
| 134 : IndexedDBCallbacksBase(dispatcher_host, response_id) { } | 125 : IndexedDBCallbacksBase(dispatcher_host, response_id) { } |
| 135 | 126 |
| 136 virtual void onSuccess(const WebKit::WebSerializedScriptValue& value) { | 127 virtual void onSuccess(const WebKit::WebSerializedScriptValue& value); |
| 137 dispatcher_host()->Send( | |
| 138 new IndexedDBMsg_CallbacksSuccessSerializedScriptValue( | |
| 139 response_id(), SerializedScriptValue(value))); | |
| 140 } | |
| 141 | 128 |
| 142 private: | 129 private: |
| 143 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks); | 130 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks); |
| 144 }; | 131 }; |
| 145 | 132 |
| 146 class IndexedDBTransactionCallbacks | 133 class IndexedDBTransactionCallbacks |
| 147 : public WebKit::WebIDBTransactionCallbacks { | 134 : public WebKit::WebIDBTransactionCallbacks { |
| 148 public: | 135 public: |
| 149 IndexedDBTransactionCallbacks(IndexedDBDispatcherHost* dispatcher_host, | 136 IndexedDBTransactionCallbacks(IndexedDBDispatcherHost* dispatcher_host, |
| 150 int transaction_id); | 137 int transaction_id); |
| 151 | 138 |
| 152 virtual ~IndexedDBTransactionCallbacks(); | 139 virtual ~IndexedDBTransactionCallbacks(); |
| 153 | 140 |
| 154 virtual void onAbort(); | 141 virtual void onAbort(); |
| 155 | 142 |
| 156 virtual void onComplete(); | 143 virtual void onComplete(); |
| 157 | 144 |
| 158 virtual void onTimeout(); | 145 virtual void onTimeout(); |
| 159 | 146 |
| 160 private: | 147 private: |
| 161 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host_; | 148 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host_; |
| 162 int transaction_id_; | 149 int transaction_id_; |
| 163 }; | 150 }; |
| 164 | 151 |
| 165 #endif // CHROME_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_CALLBACKS_H_ | 152 #endif // CHROME_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_CALLBACKS_H_ |
| OLD | NEW |