| 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 #include "content/common/indexed_db/proxy_webidbobjectstore_impl.h" | 5 #include "content/common/indexed_db/proxy_webidbobjectstore_impl.h" |
| 6 | 6 |
| 7 #include "content/common/indexed_db/indexed_db_messages.h" | 7 #include "content/common/indexed_db/indexed_db_messages.h" |
| 8 #include "content/public/common/serialized_script_value.h" | 8 #include "content/public/common/serialized_script_value.h" |
| 9 #include "content/common/indexed_db/indexed_db_dispatcher.h" | 9 #include "content/common/indexed_db/indexed_db_dispatcher.h" |
| 10 #include "content/common/indexed_db/proxy_webidbindex_impl.h" | 10 #include "content/common/indexed_db/proxy_webidbindex_impl.h" |
| 11 #include "content/common/indexed_db/proxy_webidbtransaction_impl.h" | 11 #include "content/common/indexed_db/proxy_webidbtransaction_impl.h" |
| 12 #include "content/common/child_thread.h" | 12 #include "content/common/child_thread.h" |
| 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMStringList.h" | 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMStringList.h" |
| 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKey.h" | 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKey.h" |
| 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKeyPath.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKeyPath.h" |
| 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKeyRange.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKeyRange.h" |
| 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBTransaction.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBTransaction.h" |
| 18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSerialize
dScriptValue.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSerialize
dScriptValue.h" |
| 19 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
| 20 | 20 |
| 21 using content::IndexedDBKeyPath; |
| 22 using content::SerializedScriptValue; |
| 21 using WebKit::WebDOMStringList; | 23 using WebKit::WebDOMStringList; |
| 22 using WebKit::WebExceptionCode; | 24 using WebKit::WebExceptionCode; |
| 23 using WebKit::WebFrame; | 25 using WebKit::WebFrame; |
| 24 using WebKit::WebIDBCallbacks; | 26 using WebKit::WebIDBCallbacks; |
| 25 using WebKit::WebIDBKeyPath; | 27 using WebKit::WebIDBKeyPath; |
| 26 using WebKit::WebIDBKeyRange; | 28 using WebKit::WebIDBKeyRange; |
| 27 using WebKit::WebIDBIndex; | 29 using WebKit::WebIDBIndex; |
| 28 using WebKit::WebIDBKey; | 30 using WebKit::WebIDBKey; |
| 29 using WebKit::WebIDBTransaction; | 31 using WebKit::WebIDBTransaction; |
| 30 using WebKit::WebSerializedScriptValue; | 32 using WebKit::WebSerializedScriptValue; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 45 } | 47 } |
| 46 | 48 |
| 47 WebString RendererWebIDBObjectStoreImpl::name() const { | 49 WebString RendererWebIDBObjectStoreImpl::name() const { |
| 48 string16 result; | 50 string16 result; |
| 49 IndexedDBDispatcher::Send( | 51 IndexedDBDispatcher::Send( |
| 50 new IndexedDBHostMsg_ObjectStoreName(idb_object_store_id_, &result)); | 52 new IndexedDBHostMsg_ObjectStoreName(idb_object_store_id_, &result)); |
| 51 return result; | 53 return result; |
| 52 } | 54 } |
| 53 | 55 |
| 54 WebIDBKeyPath RendererWebIDBObjectStoreImpl::keyPath() const { | 56 WebIDBKeyPath RendererWebIDBObjectStoreImpl::keyPath() const { |
| 55 content::IndexedDBKeyPath result; | 57 IndexedDBKeyPath result; |
| 56 IndexedDBDispatcher::Send( | 58 IndexedDBDispatcher::Send( |
| 57 new IndexedDBHostMsg_ObjectStoreKeyPath(idb_object_store_id_, &result)); | 59 new IndexedDBHostMsg_ObjectStoreKeyPath(idb_object_store_id_, &result)); |
| 58 return result; | 60 return result; |
| 59 } | 61 } |
| 60 | 62 |
| 61 WebDOMStringList RendererWebIDBObjectStoreImpl::indexNames() const { | 63 WebDOMStringList RendererWebIDBObjectStoreImpl::indexNames() const { |
| 62 std::vector<string16> result; | 64 std::vector<string16> result; |
| 63 IndexedDBDispatcher::Send( | 65 IndexedDBDispatcher::Send( |
| 64 new IndexedDBHostMsg_ObjectStoreIndexNames( | 66 new IndexedDBHostMsg_ObjectStoreIndexNames( |
| 65 idb_object_store_id_, &result)); | 67 idb_object_store_id_, &result)); |
| 66 WebDOMStringList web_result; | 68 WebDOMStringList web_result; |
| 67 for (std::vector<string16>::const_iterator it = result.begin(); | 69 for (std::vector<string16>::const_iterator it = result.begin(); |
| 68 it != result.end(); ++it) { | 70 it != result.end(); ++it) { |
| 69 web_result.append(*it); | 71 web_result.append(*it); |
| 70 } | 72 } |
| 71 return web_result; | 73 return web_result; |
| 72 } | 74 } |
| 73 | 75 |
| 74 void RendererWebIDBObjectStoreImpl::get( | 76 void RendererWebIDBObjectStoreImpl::get( |
| 75 const WebIDBKeyRange& key_range, | 77 const WebIDBKeyRange& key_range, |
| 76 WebIDBCallbacks* callbacks, | 78 WebIDBCallbacks* callbacks, |
| 77 const WebIDBTransaction& transaction, | 79 const WebIDBTransaction& transaction, |
| 78 WebExceptionCode& ec) { | 80 WebExceptionCode& ec) { |
| 79 IndexedDBDispatcher* dispatcher = | 81 IndexedDBDispatcher* dispatcher = |
| 80 IndexedDBDispatcher::ThreadSpecificInstance(); | 82 IndexedDBDispatcher::ThreadSpecificInstance(); |
| 81 dispatcher->RequestIDBObjectStoreGet( | 83 dispatcher->RequestIDBObjectStoreGet( |
| 82 IndexedDBKeyRange(key_range), callbacks, | 84 content::IndexedDBKeyRange(key_range), callbacks, |
| 83 idb_object_store_id_, transaction, &ec); | 85 idb_object_store_id_, transaction, &ec); |
| 84 } | 86 } |
| 85 | 87 |
| 86 void RendererWebIDBObjectStoreImpl::put( | 88 void RendererWebIDBObjectStoreImpl::put( |
| 87 const WebSerializedScriptValue& value, | 89 const WebSerializedScriptValue& value, |
| 88 const WebIDBKey& key, | 90 const WebIDBKey& key, |
| 89 PutMode put_mode, | 91 PutMode put_mode, |
| 90 WebIDBCallbacks* callbacks, | 92 WebIDBCallbacks* callbacks, |
| 91 const WebIDBTransaction& transaction, | 93 const WebIDBTransaction& transaction, |
| 92 WebExceptionCode& ec) { | 94 WebExceptionCode& ec) { |
| 93 IndexedDBDispatcher* dispatcher = | 95 IndexedDBDispatcher* dispatcher = |
| 94 IndexedDBDispatcher::ThreadSpecificInstance(); | 96 IndexedDBDispatcher::ThreadSpecificInstance(); |
| 95 dispatcher->RequestIDBObjectStorePut( | 97 dispatcher->RequestIDBObjectStorePut( |
| 96 content::SerializedScriptValue(value), IndexedDBKey(key), put_mode, | 98 SerializedScriptValue(value), content::IndexedDBKey(key), |
| 97 callbacks, idb_object_store_id_, transaction, &ec); | 99 put_mode, callbacks, idb_object_store_id_, transaction, &ec); |
| 98 } | 100 } |
| 99 | 101 |
| 100 void RendererWebIDBObjectStoreImpl::deleteFunction( | 102 void RendererWebIDBObjectStoreImpl::deleteFunction( |
| 101 const WebIDBKey& key, | 103 const WebIDBKey& key, |
| 102 WebIDBCallbacks* callbacks, | 104 WebIDBCallbacks* callbacks, |
| 103 const WebIDBTransaction& transaction, | 105 const WebIDBTransaction& transaction, |
| 104 WebExceptionCode& ec) { | 106 WebExceptionCode& ec) { |
| 105 IndexedDBDispatcher* dispatcher = | 107 IndexedDBDispatcher* dispatcher = |
| 106 IndexedDBDispatcher::ThreadSpecificInstance(); | 108 IndexedDBDispatcher::ThreadSpecificInstance(); |
| 107 dispatcher->RequestIDBObjectStoreDelete( | 109 dispatcher->RequestIDBObjectStoreDelete( |
| 108 IndexedDBKey(key), callbacks, idb_object_store_id_, transaction, &ec); | 110 content::IndexedDBKey(key), callbacks, idb_object_store_id_, |
| 111 transaction, &ec); |
| 109 } | 112 } |
| 110 | 113 |
| 111 void RendererWebIDBObjectStoreImpl::deleteFunction( | 114 void RendererWebIDBObjectStoreImpl::deleteFunction( |
| 112 const WebIDBKeyRange& key_range, | 115 const WebIDBKeyRange& key_range, |
| 113 WebIDBCallbacks* callbacks, | 116 WebIDBCallbacks* callbacks, |
| 114 const WebIDBTransaction& transaction, | 117 const WebIDBTransaction& transaction, |
| 115 WebExceptionCode& ec) { | 118 WebExceptionCode& ec) { |
| 116 IndexedDBDispatcher* dispatcher = | 119 IndexedDBDispatcher* dispatcher = |
| 117 IndexedDBDispatcher::ThreadSpecificInstance(); | 120 IndexedDBDispatcher::ThreadSpecificInstance(); |
| 118 dispatcher->RequestIDBObjectStoreDeleteRange( | 121 dispatcher->RequestIDBObjectStoreDeleteRange( |
| 119 IndexedDBKeyRange(key_range), callbacks, idb_object_store_id_, | 122 content::IndexedDBKeyRange(key_range), callbacks, idb_object_store_id_, |
| 120 transaction, &ec); | 123 transaction, &ec); |
| 121 } | 124 } |
| 122 | 125 |
| 123 void RendererWebIDBObjectStoreImpl::clear( | 126 void RendererWebIDBObjectStoreImpl::clear( |
| 124 WebIDBCallbacks* callbacks, | 127 WebIDBCallbacks* callbacks, |
| 125 const WebIDBTransaction& transaction, | 128 const WebIDBTransaction& transaction, |
| 126 WebExceptionCode& ec) { | 129 WebExceptionCode& ec) { |
| 127 IndexedDBDispatcher* dispatcher = | 130 IndexedDBDispatcher* dispatcher = |
| 128 IndexedDBDispatcher::ThreadSpecificInstance(); | 131 IndexedDBDispatcher::ThreadSpecificInstance(); |
| 129 dispatcher->RequestIDBObjectStoreClear( | 132 dispatcher->RequestIDBObjectStoreClear( |
| 130 callbacks, idb_object_store_id_, transaction, &ec); | 133 callbacks, idb_object_store_id_, transaction, &ec); |
| 131 } | 134 } |
| 132 | 135 |
| 133 WebIDBIndex* RendererWebIDBObjectStoreImpl::createIndex( | 136 WebIDBIndex* RendererWebIDBObjectStoreImpl::createIndex( |
| 134 const WebString& name, | 137 const WebString& name, |
| 135 const WebIDBKeyPath& key_path, | 138 const WebIDBKeyPath& key_path, |
| 136 bool unique, | 139 bool unique, |
| 137 bool multi_entry, | 140 bool multi_entry, |
| 138 const WebIDBTransaction& transaction, | 141 const WebIDBTransaction& transaction, |
| 139 WebExceptionCode& ec) { | 142 WebExceptionCode& ec) { |
| 140 IndexedDBHostMsg_ObjectStoreCreateIndex_Params params; | 143 IndexedDBHostMsg_ObjectStoreCreateIndex_Params params; |
| 141 params.name = name; | 144 params.name = name; |
| 142 params.key_path = content::IndexedDBKeyPath(key_path); | 145 params.key_path = IndexedDBKeyPath(key_path); |
| 143 params.unique = unique; | 146 params.unique = unique; |
| 144 params.multi_entry = multi_entry; | 147 params.multi_entry = multi_entry; |
| 145 params.transaction_id = IndexedDBDispatcher::TransactionId(transaction); | 148 params.transaction_id = IndexedDBDispatcher::TransactionId(transaction); |
| 146 params.idb_object_store_id = idb_object_store_id_; | 149 params.idb_object_store_id = idb_object_store_id_; |
| 147 | 150 |
| 148 int32 index_id; | 151 int32 index_id; |
| 149 IndexedDBDispatcher::Send( | 152 IndexedDBDispatcher::Send( |
| 150 new IndexedDBHostMsg_ObjectStoreCreateIndex(params, &index_id, &ec)); | 153 new IndexedDBHostMsg_ObjectStoreCreateIndex(params, &index_id, &ec)); |
| 151 if (!index_id) | 154 if (!index_id) |
| 152 return NULL; | 155 return NULL; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 const WebIDBKeyRange& idb_key_range, | 194 const WebIDBKeyRange& idb_key_range, |
| 192 WebIDBCallbacks* callbacks, | 195 WebIDBCallbacks* callbacks, |
| 193 const WebIDBTransaction& transaction, | 196 const WebIDBTransaction& transaction, |
| 194 WebExceptionCode& ec) { | 197 WebExceptionCode& ec) { |
| 195 IndexedDBDispatcher* dispatcher = | 198 IndexedDBDispatcher* dispatcher = |
| 196 IndexedDBDispatcher::ThreadSpecificInstance(); | 199 IndexedDBDispatcher::ThreadSpecificInstance(); |
| 197 dispatcher->RequestIDBObjectStoreCount( | 200 dispatcher->RequestIDBObjectStoreCount( |
| 198 idb_key_range, callbacks, idb_object_store_id_, | 201 idb_key_range, callbacks, idb_object_store_id_, |
| 199 transaction, &ec); | 202 transaction, &ec); |
| 200 } | 203 } |
| OLD | NEW |