Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: content/renderer/renderer_webidbobjectstore_impl.cc

Issue 8745003: Allow IndexedDB to send messages from any thread in the renderer process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "content/renderer/renderer_webidbobjectstore_impl.h" 5 #include "content/renderer/renderer_webidbobjectstore_impl.h"
6 6
7 #include "content/common/indexed_db_messages.h" 7 #include "content/common/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/renderer/indexed_db_dispatcher.h" 9 #include "content/renderer/indexed_db_dispatcher.h"
10 #include "content/renderer/render_thread_impl.h" 10 #include "content/renderer/render_thread_impl.h"
(...skipping 20 matching lines...) Expand all
31 RendererWebIDBObjectStoreImpl::RendererWebIDBObjectStoreImpl( 31 RendererWebIDBObjectStoreImpl::RendererWebIDBObjectStoreImpl(
32 int32 idb_object_store_id) 32 int32 idb_object_store_id)
33 : idb_object_store_id_(idb_object_store_id) { 33 : idb_object_store_id_(idb_object_store_id) {
34 } 34 }
35 35
36 RendererWebIDBObjectStoreImpl::~RendererWebIDBObjectStoreImpl() { 36 RendererWebIDBObjectStoreImpl::~RendererWebIDBObjectStoreImpl() {
37 // It's not possible for there to be pending callbacks that address this 37 // It's not possible for there to be pending callbacks that address this
38 // object since inside WebKit, they hold a reference to the object wich owns 38 // object since inside WebKit, they hold a reference to the object wich owns
39 // this object. But, if that ever changed, then we'd need to invalidate 39 // this object. But, if that ever changed, then we'd need to invalidate
40 // any such pointers. 40 // any such pointers.
41 RenderThreadImpl::current()->Send( 41 ChildThread::current()->Send(
42 new IndexedDBHostMsg_ObjectStoreDestroyed(idb_object_store_id_)); 42 new IndexedDBHostMsg_ObjectStoreDestroyed(idb_object_store_id_));
43 } 43 }
44 44
45 WebString RendererWebIDBObjectStoreImpl::name() const { 45 WebString RendererWebIDBObjectStoreImpl::name() const {
46 string16 result; 46 string16 result;
47 RenderThreadImpl::current()->Send( 47 ChildThread::current()->Send(
48 new IndexedDBHostMsg_ObjectStoreName(idb_object_store_id_, &result)); 48 new IndexedDBHostMsg_ObjectStoreName(idb_object_store_id_, &result));
49 return result; 49 return result;
50 } 50 }
51 51
52 WebString RendererWebIDBObjectStoreImpl::keyPath() const { 52 WebString RendererWebIDBObjectStoreImpl::keyPath() const {
53 NullableString16 result; 53 NullableString16 result;
54 RenderThreadImpl::current()->Send( 54 ChildThread::current()->Send(
55 new IndexedDBHostMsg_ObjectStoreKeyPath(idb_object_store_id_, &result)); 55 new IndexedDBHostMsg_ObjectStoreKeyPath(idb_object_store_id_, &result));
56 return result; 56 return result;
57 } 57 }
58 58
59 WebDOMStringList RendererWebIDBObjectStoreImpl::indexNames() const { 59 WebDOMStringList RendererWebIDBObjectStoreImpl::indexNames() const {
60 std::vector<string16> result; 60 std::vector<string16> result;
61 RenderThreadImpl::current()->Send( 61 ChildThread::current()->Send(
62 new IndexedDBHostMsg_ObjectStoreIndexNames( 62 new IndexedDBHostMsg_ObjectStoreIndexNames(
63 idb_object_store_id_, &result)); 63 idb_object_store_id_, &result));
64 WebDOMStringList web_result; 64 WebDOMStringList web_result;
65 for (std::vector<string16>::const_iterator it = result.begin(); 65 for (std::vector<string16>::const_iterator it = result.begin();
66 it != result.end(); ++it) { 66 it != result.end(); ++it) {
67 web_result.append(*it); 67 web_result.append(*it);
68 } 68 }
69 return web_result; 69 return web_result;
70 } 70 }
71 71
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 const WebIDBTransaction& transaction, 122 const WebIDBTransaction& transaction,
123 WebExceptionCode& ec) { 123 WebExceptionCode& ec) {
124 IndexedDBHostMsg_ObjectStoreCreateIndex_Params params; 124 IndexedDBHostMsg_ObjectStoreCreateIndex_Params params;
125 params.name = name; 125 params.name = name;
126 params.key_path = key_path; 126 params.key_path = key_path;
127 params.unique = unique; 127 params.unique = unique;
128 params.transaction_id = IndexedDBDispatcher::TransactionId(transaction); 128 params.transaction_id = IndexedDBDispatcher::TransactionId(transaction);
129 params.idb_object_store_id = idb_object_store_id_; 129 params.idb_object_store_id = idb_object_store_id_;
130 130
131 int32 index_id; 131 int32 index_id;
132 RenderThreadImpl::current()->Send( 132 ChildThread::current()->Send(
133 new IndexedDBHostMsg_ObjectStoreCreateIndex(params, &index_id, &ec)); 133 new IndexedDBHostMsg_ObjectStoreCreateIndex(params, &index_id, &ec));
134 if (!index_id) 134 if (!index_id)
135 return NULL; 135 return NULL;
136 return new RendererWebIDBIndexImpl(index_id); 136 return new RendererWebIDBIndexImpl(index_id);
137 } 137 }
138 138
139 WebIDBIndex* RendererWebIDBObjectStoreImpl::index( 139 WebIDBIndex* RendererWebIDBObjectStoreImpl::index(
140 const WebString& name, 140 const WebString& name,
141 WebExceptionCode& ec) { 141 WebExceptionCode& ec) {
142 int32 idb_index_id; 142 int32 idb_index_id;
143 RenderThreadImpl::current()->Send( 143 ChildThread::current()->Send(
144 new IndexedDBHostMsg_ObjectStoreIndex(idb_object_store_id_, name, 144 new IndexedDBHostMsg_ObjectStoreIndex(idb_object_store_id_, name,
145 &idb_index_id, &ec)); 145 &idb_index_id, &ec));
146 if (!idb_index_id) 146 if (!idb_index_id)
147 return NULL; 147 return NULL;
148 return new RendererWebIDBIndexImpl(idb_index_id); 148 return new RendererWebIDBIndexImpl(idb_index_id);
149 } 149 }
150 150
151 void RendererWebIDBObjectStoreImpl::deleteIndex( 151 void RendererWebIDBObjectStoreImpl::deleteIndex(
152 const WebString& name, 152 const WebString& name,
153 const WebIDBTransaction& transaction, 153 const WebIDBTransaction& transaction,
154 WebExceptionCode& ec) { 154 WebExceptionCode& ec) {
155 RenderThreadImpl::current()->Send( 155 ChildThread::current()->Send(
156 new IndexedDBHostMsg_ObjectStoreDeleteIndex( 156 new IndexedDBHostMsg_ObjectStoreDeleteIndex(
157 idb_object_store_id_, name, 157 idb_object_store_id_, name,
158 IndexedDBDispatcher::TransactionId(transaction), &ec)); 158 IndexedDBDispatcher::TransactionId(transaction), &ec));
159 } 159 }
160 160
161 void RendererWebIDBObjectStoreImpl::openCursor( 161 void RendererWebIDBObjectStoreImpl::openCursor(
162 const WebIDBKeyRange& idb_key_range, 162 const WebIDBKeyRange& idb_key_range,
163 unsigned short direction, WebIDBCallbacks* callbacks, 163 unsigned short direction, WebIDBCallbacks* callbacks,
164 const WebIDBTransaction& transaction, 164 const WebIDBTransaction& transaction,
165 WebExceptionCode& ec) { 165 WebExceptionCode& ec) {
166 IndexedDBDispatcher* dispatcher = 166 IndexedDBDispatcher* dispatcher =
167 RenderThreadImpl::current()->indexed_db_dispatcher(); 167 RenderThreadImpl::current()->indexed_db_dispatcher();
168 dispatcher->RequestIDBObjectStoreOpenCursor( 168 dispatcher->RequestIDBObjectStoreOpenCursor(
169 idb_key_range, direction, callbacks, idb_object_store_id_, 169 idb_key_range, direction, callbacks, idb_object_store_id_,
170 transaction, &ec); 170 transaction, &ec);
171 } 171 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698