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

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

Issue 8747002: Dispatch IndexedDB IPC messages to worker threads (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
72 void RendererWebIDBObjectStoreImpl::get( 72 void RendererWebIDBObjectStoreImpl::get(
73 const WebIDBKey& key, 73 const WebIDBKey& key,
74 WebIDBCallbacks* callbacks, 74 WebIDBCallbacks* callbacks,
75 const WebIDBTransaction& transaction, 75 const WebIDBTransaction& transaction,
76 WebExceptionCode& ec) { 76 WebExceptionCode& ec) {
77 IndexedDBDispatcher* dispatcher = 77 IndexedDBDispatcher* dispatcher =
78 RenderThreadImpl::current()->indexed_db_dispatcher(); 78 ChildThread::current()->indexed_db_dispatcher();
79 dispatcher->RequestIDBObjectStoreGet( 79 dispatcher->RequestIDBObjectStoreGet(
80 IndexedDBKey(key), callbacks, idb_object_store_id_, transaction, &ec); 80 IndexedDBKey(key), callbacks, idb_object_store_id_, transaction, &ec);
81 } 81 }
82 82
83 void RendererWebIDBObjectStoreImpl::put( 83 void RendererWebIDBObjectStoreImpl::put(
84 const WebSerializedScriptValue& value, 84 const WebSerializedScriptValue& value,
85 const WebIDBKey& key, 85 const WebIDBKey& key,
86 PutMode put_mode, 86 PutMode put_mode,
87 WebIDBCallbacks* callbacks, 87 WebIDBCallbacks* callbacks,
88 const WebIDBTransaction& transaction, 88 const WebIDBTransaction& transaction,
89 WebExceptionCode& ec) { 89 WebExceptionCode& ec) {
90 IndexedDBDispatcher* dispatcher = 90 IndexedDBDispatcher* dispatcher =
91 RenderThreadImpl::current()->indexed_db_dispatcher(); 91 ChildThread::current()->indexed_db_dispatcher();
92 dispatcher->RequestIDBObjectStorePut( 92 dispatcher->RequestIDBObjectStorePut(
93 content::SerializedScriptValue(value), IndexedDBKey(key), put_mode, 93 content::SerializedScriptValue(value), IndexedDBKey(key), put_mode,
94 callbacks, idb_object_store_id_, transaction, &ec); 94 callbacks, idb_object_store_id_, transaction, &ec);
95 } 95 }
96 96
97 void RendererWebIDBObjectStoreImpl::deleteFunction( 97 void RendererWebIDBObjectStoreImpl::deleteFunction(
98 const WebIDBKey& key, 98 const WebIDBKey& key,
99 WebIDBCallbacks* callbacks, 99 WebIDBCallbacks* callbacks,
100 const WebIDBTransaction& transaction, 100 const WebIDBTransaction& transaction,
101 WebExceptionCode& ec) { 101 WebExceptionCode& ec) {
102 IndexedDBDispatcher* dispatcher = 102 IndexedDBDispatcher* dispatcher =
103 RenderThreadImpl::current()->indexed_db_dispatcher(); 103 ChildThread::current()->indexed_db_dispatcher();
104 dispatcher->RequestIDBObjectStoreDelete( 104 dispatcher->RequestIDBObjectStoreDelete(
105 IndexedDBKey(key), callbacks, idb_object_store_id_, transaction, &ec); 105 IndexedDBKey(key), callbacks, idb_object_store_id_, transaction, &ec);
106 } 106 }
107 107
108 void RendererWebIDBObjectStoreImpl::clear( 108 void RendererWebIDBObjectStoreImpl::clear(
109 WebIDBCallbacks* callbacks, 109 WebIDBCallbacks* callbacks,
110 const WebIDBTransaction& transaction, 110 const WebIDBTransaction& transaction,
111 WebExceptionCode& ec) { 111 WebExceptionCode& ec) {
112 IndexedDBDispatcher* dispatcher = 112 IndexedDBDispatcher* dispatcher =
113 RenderThreadImpl::current()->indexed_db_dispatcher(); 113 ChildThread::current()->indexed_db_dispatcher();
114 dispatcher->RequestIDBObjectStoreClear( 114 dispatcher->RequestIDBObjectStoreClear(
115 callbacks, idb_object_store_id_, transaction, &ec); 115 callbacks, idb_object_store_id_, transaction, &ec);
116 } 116 }
117 117
118 WebIDBIndex* RendererWebIDBObjectStoreImpl::createIndex( 118 WebIDBIndex* RendererWebIDBObjectStoreImpl::createIndex(
119 const WebString& name, 119 const WebString& name,
120 const WebString& key_path, 120 const WebString& key_path,
121 bool unique, 121 bool unique,
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 ChildThread::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