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