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 #include "chrome/renderer/renderer_webidbobjectstore_impl.h" | 5 #include "chrome/renderer/renderer_webidbobjectstore_impl.h" |
6 | 6 |
7 #include "chrome/common/indexed_db_key.h" | 7 #include "chrome/common/indexed_db_messages.h" |
8 #include "chrome/common/render_messages.h" | |
9 #include "chrome/common/render_messages_params.h" | |
10 #include "chrome/common/serialized_script_value.h" | 8 #include "chrome/common/serialized_script_value.h" |
11 #include "chrome/renderer/indexed_db_dispatcher.h" | 9 #include "chrome/renderer/indexed_db_dispatcher.h" |
12 #include "chrome/renderer/render_thread.h" | 10 #include "chrome/renderer/render_thread.h" |
13 #include "chrome/renderer/renderer_webidbindex_impl.h" | 11 #include "chrome/renderer/renderer_webidbindex_impl.h" |
14 #include "chrome/renderer/renderer_webidbtransaction_impl.h" | 12 #include "chrome/renderer/renderer_webidbtransaction_impl.h" |
15 #include "third_party/WebKit/WebKit/chromium/public/WebDOMStringList.h" | 13 #include "third_party/WebKit/WebKit/chromium/public/WebDOMStringList.h" |
16 #include "third_party/WebKit/WebKit/chromium/public/WebIDBKey.h" | 14 #include "third_party/WebKit/WebKit/chromium/public/WebIDBKey.h" |
17 #include "third_party/WebKit/WebKit/chromium/public/WebIDBKeyRange.h" | 15 #include "third_party/WebKit/WebKit/chromium/public/WebIDBKeyRange.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/WebSerializedScriptValue.h" | 17 #include "third_party/WebKit/WebKit/chromium/public/WebSerializedScriptValue.h" |
(...skipping 10 matching lines...) Expand all Loading... |
30 using WebKit::WebSerializedScriptValue; | 28 using WebKit::WebSerializedScriptValue; |
31 using WebKit::WebString; | 29 using WebKit::WebString; |
32 | 30 |
33 RendererWebIDBObjectStoreImpl::RendererWebIDBObjectStoreImpl( | 31 RendererWebIDBObjectStoreImpl::RendererWebIDBObjectStoreImpl( |
34 int32 idb_object_store_id) | 32 int32 idb_object_store_id) |
35 : idb_object_store_id_(idb_object_store_id) { | 33 : idb_object_store_id_(idb_object_store_id) { |
36 } | 34 } |
37 | 35 |
38 RendererWebIDBObjectStoreImpl::~RendererWebIDBObjectStoreImpl() { | 36 RendererWebIDBObjectStoreImpl::~RendererWebIDBObjectStoreImpl() { |
39 RenderThread::current()->Send( | 37 RenderThread::current()->Send( |
40 new ViewHostMsg_IDBObjectStoreDestroyed(idb_object_store_id_)); | 38 new IndexedDBHostMsg_ObjectStoreDestroyed(idb_object_store_id_)); |
41 } | 39 } |
42 | 40 |
43 WebString RendererWebIDBObjectStoreImpl::name() const { | 41 WebString RendererWebIDBObjectStoreImpl::name() const { |
44 string16 result; | 42 string16 result; |
45 RenderThread::current()->Send( | 43 RenderThread::current()->Send( |
46 new ViewHostMsg_IDBObjectStoreName(idb_object_store_id_, &result)); | 44 new IndexedDBHostMsg_ObjectStoreName(idb_object_store_id_, &result)); |
47 return result; | 45 return result; |
48 } | 46 } |
49 | 47 |
50 WebString RendererWebIDBObjectStoreImpl::keyPath() const { | 48 WebString RendererWebIDBObjectStoreImpl::keyPath() const { |
51 NullableString16 result; | 49 NullableString16 result; |
52 RenderThread::current()->Send( | 50 RenderThread::current()->Send( |
53 new ViewHostMsg_IDBObjectStoreKeyPath(idb_object_store_id_, &result)); | 51 new IndexedDBHostMsg_ObjectStoreKeyPath(idb_object_store_id_, &result)); |
54 return result; | 52 return result; |
55 } | 53 } |
56 | 54 |
57 WebDOMStringList RendererWebIDBObjectStoreImpl::indexNames() const { | 55 WebDOMStringList RendererWebIDBObjectStoreImpl::indexNames() const { |
58 std::vector<string16> result; | 56 std::vector<string16> result; |
59 RenderThread::current()->Send( | 57 RenderThread::current()->Send( |
60 new ViewHostMsg_IDBObjectStoreIndexNames(idb_object_store_id_, &result)); | 58 new IndexedDBHostMsg_ObjectStoreIndexNames( |
| 59 idb_object_store_id_, &result)); |
61 WebDOMStringList web_result; | 60 WebDOMStringList web_result; |
62 for (std::vector<string16>::const_iterator it = result.begin(); | 61 for (std::vector<string16>::const_iterator it = result.begin(); |
63 it != result.end(); ++it) { | 62 it != result.end(); ++it) { |
64 web_result.append(*it); | 63 web_result.append(*it); |
65 } | 64 } |
66 return web_result; | 65 return web_result; |
67 } | 66 } |
68 | 67 |
69 void RendererWebIDBObjectStoreImpl::get( | 68 void RendererWebIDBObjectStoreImpl::get( |
70 const WebIDBKey& key, | 69 const WebIDBKey& key, |
(...skipping 30 matching lines...) Expand all Loading... |
101 dispatcher->RequestIDBObjectStoreDelete( | 100 dispatcher->RequestIDBObjectStoreDelete( |
102 IndexedDBKey(key), callbacks, idb_object_store_id_, transaction, &ec); | 101 IndexedDBKey(key), callbacks, idb_object_store_id_, transaction, &ec); |
103 } | 102 } |
104 | 103 |
105 WebIDBIndex* RendererWebIDBObjectStoreImpl::createIndex( | 104 WebIDBIndex* RendererWebIDBObjectStoreImpl::createIndex( |
106 const WebString& name, | 105 const WebString& name, |
107 const WebString& key_path, | 106 const WebString& key_path, |
108 bool unique, | 107 bool unique, |
109 const WebIDBTransaction& transaction, | 108 const WebIDBTransaction& transaction, |
110 WebExceptionCode& ec) { | 109 WebExceptionCode& ec) { |
111 ViewHostMsg_IDBObjectStoreCreateIndex_Params params; | 110 IndexedDBHostMsg_ObjectStoreCreateIndex_Params params; |
112 params.name_ = name; | 111 params.name = name; |
113 params.key_path_ = key_path; | 112 params.key_path = key_path; |
114 params.unique_ = unique; | 113 params.unique = unique; |
115 params.transaction_id_ = IndexedDBDispatcher::TransactionId(transaction); | 114 params.transaction_id = IndexedDBDispatcher::TransactionId(transaction); |
116 params.idb_object_store_id_ = idb_object_store_id_; | 115 params.idb_object_store_id = idb_object_store_id_; |
117 | 116 |
118 int32 index_id; | 117 int32 index_id; |
119 RenderThread::current()->Send( | 118 RenderThread::current()->Send( |
120 new ViewHostMsg_IDBObjectStoreCreateIndex(params, &index_id, &ec)); | 119 new IndexedDBHostMsg_ObjectStoreCreateIndex(params, &index_id, &ec)); |
121 if (!index_id) | 120 if (!index_id) |
122 return NULL; | 121 return NULL; |
123 return new RendererWebIDBIndexImpl(index_id); | 122 return new RendererWebIDBIndexImpl(index_id); |
124 } | 123 } |
125 | 124 |
126 WebIDBIndex* RendererWebIDBObjectStoreImpl::index( | 125 WebIDBIndex* RendererWebIDBObjectStoreImpl::index( |
127 const WebString& name, | 126 const WebString& name, |
128 WebExceptionCode& ec) { | 127 WebExceptionCode& ec) { |
129 int32 idb_index_id; | 128 int32 idb_index_id; |
130 RenderThread::current()->Send( | 129 RenderThread::current()->Send( |
131 new ViewHostMsg_IDBObjectStoreIndex(idb_object_store_id_, name, | 130 new IndexedDBHostMsg_ObjectStoreIndex(idb_object_store_id_, name, |
132 &idb_index_id, &ec)); | 131 &idb_index_id, &ec)); |
133 if (!idb_index_id) | 132 if (!idb_index_id) |
134 return NULL; | 133 return NULL; |
135 return new RendererWebIDBIndexImpl(idb_index_id); | 134 return new RendererWebIDBIndexImpl(idb_index_id); |
136 } | 135 } |
137 | 136 |
138 void RendererWebIDBObjectStoreImpl::deleteIndex( | 137 void RendererWebIDBObjectStoreImpl::deleteIndex( |
139 const WebString& name, | 138 const WebString& name, |
140 const WebIDBTransaction& transaction, | 139 const WebIDBTransaction& transaction, |
141 WebExceptionCode& ec) { | 140 WebExceptionCode& ec) { |
142 RenderThread::current()->Send( | 141 RenderThread::current()->Send( |
143 new ViewHostMsg_IDBObjectStoreDeleteIndex( | 142 new IndexedDBHostMsg_ObjectStoreDeleteIndex( |
144 idb_object_store_id_, name, | 143 idb_object_store_id_, name, |
145 IndexedDBDispatcher::TransactionId(transaction), &ec)); | 144 IndexedDBDispatcher::TransactionId(transaction), &ec)); |
146 } | 145 } |
147 | 146 |
148 void RendererWebIDBObjectStoreImpl::openCursor( | 147 void RendererWebIDBObjectStoreImpl::openCursor( |
149 const WebIDBKeyRange& idb_key_range, | 148 const WebIDBKeyRange& idb_key_range, |
150 unsigned short direction, WebIDBCallbacks* callbacks, | 149 unsigned short direction, WebIDBCallbacks* callbacks, |
151 const WebIDBTransaction& transaction, | 150 const WebIDBTransaction& transaction, |
152 WebExceptionCode& ec) { | 151 WebExceptionCode& ec) { |
153 IndexedDBDispatcher* dispatcher = | 152 IndexedDBDispatcher* dispatcher = |
154 RenderThread::current()->indexed_db_dispatcher(); | 153 RenderThread::current()->indexed_db_dispatcher(); |
155 dispatcher->RequestIDBObjectStoreOpenCursor( | 154 dispatcher->RequestIDBObjectStoreOpenCursor( |
156 idb_key_range, direction, callbacks, idb_object_store_id_, | 155 idb_key_range, direction, callbacks, idb_object_store_id_, |
157 transaction, &ec); | 156 transaction, &ec); |
158 } | 157 } |
OLD | NEW |