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

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

Issue 9368053: Move indexed db files from content/renderer to content/common. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix checkdeps by adding method to ChildThread Created 8 years, 10 months 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
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/renderer/indexed_db/renderer_webidbobjectstore_impl.h"
6
7 #include "content/common/indexed_db/indexed_db_messages.h"
8 #include "content/public/common/serialized_script_value.h"
9 #include "content/renderer/indexed_db/indexed_db_dispatcher.h"
10 #include "content/renderer/indexed_db/renderer_webidbindex_impl.h"
11 #include "content/renderer/indexed_db/renderer_webidbtransaction_impl.h"
12 #include "content/renderer/render_thread_impl.h"
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMStringList.h"
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKey.h"
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKeyRange.h"
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBTransaction.h"
17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSerialize dScriptValue.h"
18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
19
20 using WebKit::WebDOMStringList;
21 using WebKit::WebExceptionCode;
22 using WebKit::WebFrame;
23 using WebKit::WebIDBCallbacks;
24 using WebKit::WebIDBKeyRange;
25 using WebKit::WebIDBIndex;
26 using WebKit::WebIDBKey;
27 using WebKit::WebIDBTransaction;
28 using WebKit::WebSerializedScriptValue;
29 using WebKit::WebString;
30
31 RendererWebIDBObjectStoreImpl::RendererWebIDBObjectStoreImpl(
32 int32 idb_object_store_id)
33 : idb_object_store_id_(idb_object_store_id) {
34 }
35
36 RendererWebIDBObjectStoreImpl::~RendererWebIDBObjectStoreImpl() {
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
39 // this object. But, if that ever changed, then we'd need to invalidate
40 // any such pointers.
41 ChildThread::current()->Send(
42 new IndexedDBHostMsg_ObjectStoreDestroyed(idb_object_store_id_));
43 }
44
45 WebString RendererWebIDBObjectStoreImpl::name() const {
46 string16 result;
47 ChildThread::current()->Send(
48 new IndexedDBHostMsg_ObjectStoreName(idb_object_store_id_, &result));
49 return result;
50 }
51
52 WebString RendererWebIDBObjectStoreImpl::keyPath() const {
53 NullableString16 result;
54 ChildThread::current()->Send(
55 new IndexedDBHostMsg_ObjectStoreKeyPath(idb_object_store_id_, &result));
56 return result;
57 }
58
59 WebDOMStringList RendererWebIDBObjectStoreImpl::indexNames() const {
60 std::vector<string16> result;
61 ChildThread::current()->Send(
62 new IndexedDBHostMsg_ObjectStoreIndexNames(
63 idb_object_store_id_, &result));
64 WebDOMStringList web_result;
65 for (std::vector<string16>::const_iterator it = result.begin();
66 it != result.end(); ++it) {
67 web_result.append(*it);
68 }
69 return web_result;
70 }
71
72 void RendererWebIDBObjectStoreImpl::get(
73 const WebIDBKey& key,
74 WebIDBCallbacks* callbacks,
75 const WebIDBTransaction& transaction,
76 WebExceptionCode& ec) {
77 IndexedDBDispatcher* dispatcher =
78 IndexedDBDispatcher::ThreadSpecificInstance();
79 dispatcher->RequestIDBObjectStoreGet(
80 IndexedDBKey(key), callbacks, idb_object_store_id_, transaction, &ec);
81 }
82
83 void RendererWebIDBObjectStoreImpl::put(
84 const WebSerializedScriptValue& value,
85 const WebIDBKey& key,
86 PutMode put_mode,
87 WebIDBCallbacks* callbacks,
88 const WebIDBTransaction& transaction,
89 WebExceptionCode& ec) {
90 IndexedDBDispatcher* dispatcher =
91 IndexedDBDispatcher::ThreadSpecificInstance();
92 dispatcher->RequestIDBObjectStorePut(
93 content::SerializedScriptValue(value), IndexedDBKey(key), put_mode,
94 callbacks, idb_object_store_id_, transaction, &ec);
95 }
96
97 void RendererWebIDBObjectStoreImpl::deleteFunction(
98 const WebIDBKey& key,
99 WebIDBCallbacks* callbacks,
100 const WebIDBTransaction& transaction,
101 WebExceptionCode& ec) {
102 IndexedDBDispatcher* dispatcher =
103 IndexedDBDispatcher::ThreadSpecificInstance();
104 dispatcher->RequestIDBObjectStoreDelete(
105 IndexedDBKey(key), callbacks, idb_object_store_id_, transaction, &ec);
106 }
107
108 void RendererWebIDBObjectStoreImpl::clear(
109 WebIDBCallbacks* callbacks,
110 const WebIDBTransaction& transaction,
111 WebExceptionCode& ec) {
112 IndexedDBDispatcher* dispatcher =
113 IndexedDBDispatcher::ThreadSpecificInstance();
114 dispatcher->RequestIDBObjectStoreClear(
115 callbacks, idb_object_store_id_, transaction, &ec);
116 }
117
118 WebIDBIndex* RendererWebIDBObjectStoreImpl::createIndex(
119 const WebString& name,
120 const WebString& key_path,
121 bool unique,
122 bool multi_entry,
123 const WebIDBTransaction& transaction,
124 WebExceptionCode& ec) {
125 IndexedDBHostMsg_ObjectStoreCreateIndex_Params params;
126 params.name = name;
127 params.key_path = key_path;
128 params.unique = unique;
129 params.multi_entry = multi_entry;
130 params.transaction_id = IndexedDBDispatcher::TransactionId(transaction);
131 params.idb_object_store_id = idb_object_store_id_;
132
133 int32 index_id;
134 ChildThread::current()->Send(
135 new IndexedDBHostMsg_ObjectStoreCreateIndex(params, &index_id, &ec));
136 if (!index_id)
137 return NULL;
138 return new RendererWebIDBIndexImpl(index_id);
139 }
140
141 WebIDBIndex* RendererWebIDBObjectStoreImpl::index(
142 const WebString& name,
143 WebExceptionCode& ec) {
144 int32 idb_index_id;
145 ChildThread::current()->Send(
146 new IndexedDBHostMsg_ObjectStoreIndex(idb_object_store_id_, name,
147 &idb_index_id, &ec));
148 if (!idb_index_id)
149 return NULL;
150 return new RendererWebIDBIndexImpl(idb_index_id);
151 }
152
153 void RendererWebIDBObjectStoreImpl::deleteIndex(
154 const WebString& name,
155 const WebIDBTransaction& transaction,
156 WebExceptionCode& ec) {
157 ChildThread::current()->Send(
158 new IndexedDBHostMsg_ObjectStoreDeleteIndex(
159 idb_object_store_id_, name,
160 IndexedDBDispatcher::TransactionId(transaction), &ec));
161 }
162
163 void RendererWebIDBObjectStoreImpl::openCursor(
164 const WebIDBKeyRange& idb_key_range,
165 unsigned short direction, WebIDBCallbacks* callbacks,
166 const WebIDBTransaction& transaction,
167 WebExceptionCode& ec) {
168 IndexedDBDispatcher* dispatcher =
169 IndexedDBDispatcher::ThreadSpecificInstance();
170 dispatcher->RequestIDBObjectStoreOpenCursor(
171 idb_key_range, direction, callbacks, idb_object_store_id_,
172 transaction, &ec);
173 }
174
175 void RendererWebIDBObjectStoreImpl::count(
176 const WebIDBKeyRange& idb_key_range,
177 WebIDBCallbacks* callbacks,
178 const WebIDBTransaction& transaction,
179 WebExceptionCode& ec) {
180 IndexedDBDispatcher* dispatcher =
181 IndexedDBDispatcher::ThreadSpecificInstance();
182 dispatcher->RequestIDBObjectStoreCount(
183 idb_key_range, callbacks, idb_object_store_id_,
184 transaction, &ec);
185 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698