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

Side by Side Diff: content/browser/indexed_db/indexed_db_callbacks.cc

Issue 2320213004: Port IndexedDB open() and database callbacks to Mojo. (Closed)
Patch Set: Make DatabaseClient an associated interface. Created 4 years, 3 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/browser/indexed_db/indexed_db_callbacks.h" 5 #include "content/browser/indexed_db/indexed_db_callbacks.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/metrics/histogram_macros.h" 12 #include "base/metrics/histogram_macros.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "content/browser/child_process_security_policy_impl.h" 15 #include "content/browser/child_process_security_policy_impl.h"
16 #include "content/browser/fileapi/fileapi_message_filter.h" 16 #include "content/browser/fileapi/fileapi_message_filter.h"
17 #include "content/browser/indexed_db/indexed_db_blob_info.h" 17 #include "content/browser/indexed_db/indexed_db_blob_info.h"
18 #include "content/browser/indexed_db/indexed_db_connection.h" 18 #include "content/browser/indexed_db/indexed_db_connection.h"
19 #include "content/browser/indexed_db/indexed_db_context_impl.h" 19 #include "content/browser/indexed_db/indexed_db_context_impl.h"
20 #include "content/browser/indexed_db/indexed_db_cursor.h" 20 #include "content/browser/indexed_db/indexed_db_cursor.h"
21 #include "content/browser/indexed_db/indexed_db_database_callbacks.h" 21 #include "content/browser/indexed_db/indexed_db_database_callbacks.h"
22 #include "content/browser/indexed_db/indexed_db_database_error.h"
23 #include "content/browser/indexed_db/indexed_db_metadata.h" 22 #include "content/browser/indexed_db/indexed_db_metadata.h"
24 #include "content/browser/indexed_db/indexed_db_return_value.h" 23 #include "content/browser/indexed_db/indexed_db_return_value.h"
25 #include "content/browser/indexed_db/indexed_db_tracing.h" 24 #include "content/browser/indexed_db/indexed_db_tracing.h"
26 #include "content/browser/indexed_db/indexed_db_value.h" 25 #include "content/browser/indexed_db/indexed_db_value.h"
27 #include "content/common/indexed_db/indexed_db_constants.h" 26 #include "content/common/indexed_db/indexed_db_constants.h"
28 #include "content/common/indexed_db/indexed_db_messages.h" 27 #include "content/common/indexed_db/indexed_db_messages.h"
29 #include "storage/browser/blob/blob_storage_context.h" 28 #include "storage/browser/blob/blob_storage_context.h"
30 #include "storage/browser/blob/shareable_file_reference.h" 29 #include "storage/browser/blob/shareable_file_reference.h"
31 #include "storage/browser/quota/quota_manager.h" 30 #include "storage/browser/quota/quota_manager.h"
32 31
33 using storage::ShareableFileReference; 32 using storage::ShareableFileReference;
34 33
35 namespace content { 34 namespace content {
36 35
37 namespace { 36 namespace {
38 const int32_t kNoCursor = -1; 37 const int32_t kNoCursor = -1;
39 const int32_t kNoDatabaseCallbacks = -1;
40 const int64_t kNoTransaction = -1; 38 const int64_t kNoTransaction = -1;
41 } 39 }
42 40
43 IndexedDBCallbacks::IndexedDBCallbacks(IndexedDBDispatcherHost* dispatcher_host, 41 IndexedDBCallbacks::IndexedDBCallbacks(IndexedDBDispatcherHost* dispatcher_host,
44 int32_t ipc_thread_id, 42 int32_t ipc_thread_id,
45 int32_t ipc_callbacks_id) 43 int32_t ipc_callbacks_id)
46 : dispatcher_host_(dispatcher_host), 44 : dispatcher_host_(dispatcher_host),
47 ipc_callbacks_id_(ipc_callbacks_id), 45 ipc_callbacks_id_(ipc_callbacks_id),
48 ipc_thread_id_(ipc_thread_id), 46 ipc_thread_id_(ipc_thread_id),
49 ipc_cursor_id_(kNoCursor), 47 ipc_cursor_id_(kNoCursor),
50 host_transaction_id_(kNoTransaction), 48 host_transaction_id_(kNoTransaction),
51 ipc_database_id_(kNoDatabase), 49 ipc_database_id_(kNoDatabase),
52 ipc_database_callbacks_id_(kNoDatabaseCallbacks),
53 data_loss_(blink::WebIDBDataLossNone), 50 data_loss_(blink::WebIDBDataLossNone),
54 sent_blocked_(false) {} 51 sent_blocked_(false) {}
55 52
56 IndexedDBCallbacks::IndexedDBCallbacks(IndexedDBDispatcherHost* dispatcher_host, 53 IndexedDBCallbacks::IndexedDBCallbacks(IndexedDBDispatcherHost* dispatcher_host,
57 int32_t ipc_thread_id, 54 int32_t ipc_thread_id,
58 int32_t ipc_callbacks_id, 55 int32_t ipc_callbacks_id,
59 int32_t ipc_cursor_id) 56 int32_t ipc_cursor_id)
60 : dispatcher_host_(dispatcher_host), 57 : dispatcher_host_(dispatcher_host),
61 ipc_callbacks_id_(ipc_callbacks_id), 58 ipc_callbacks_id_(ipc_callbacks_id),
62 ipc_thread_id_(ipc_thread_id), 59 ipc_thread_id_(ipc_thread_id),
63 ipc_cursor_id_(ipc_cursor_id), 60 ipc_cursor_id_(ipc_cursor_id),
64 host_transaction_id_(kNoTransaction), 61 host_transaction_id_(kNoTransaction),
65 ipc_database_id_(kNoDatabase), 62 ipc_database_id_(kNoDatabase),
66 ipc_database_callbacks_id_(kNoDatabaseCallbacks),
67 data_loss_(blink::WebIDBDataLossNone), 63 data_loss_(blink::WebIDBDataLossNone),
68 sent_blocked_(false) {} 64 sent_blocked_(false) {}
69 65
70 IndexedDBCallbacks::IndexedDBCallbacks(IndexedDBDispatcherHost* dispatcher_host, 66 IndexedDBCallbacks::IndexedDBCallbacks(IndexedDBDispatcherHost* dispatcher_host,
71 int32_t ipc_thread_id, 67 int32_t ipc_thread_id,
72 int32_t ipc_callbacks_id, 68 int32_t ipc_callbacks_id,
73 int32_t ipc_database_callbacks_id,
74 int64_t host_transaction_id, 69 int64_t host_transaction_id,
75 const url::Origin& origin) 70 const url::Origin& origin)
76 : dispatcher_host_(dispatcher_host), 71 : dispatcher_host_(dispatcher_host),
77 ipc_callbacks_id_(ipc_callbacks_id), 72 ipc_callbacks_id_(ipc_callbacks_id),
78 ipc_thread_id_(ipc_thread_id), 73 ipc_thread_id_(ipc_thread_id),
79 ipc_cursor_id_(kNoCursor), 74 ipc_cursor_id_(kNoCursor),
80 host_transaction_id_(host_transaction_id), 75 host_transaction_id_(host_transaction_id),
81 origin_(origin), 76 origin_(origin),
82 ipc_database_id_(kNoDatabase), 77 ipc_database_id_(kNoDatabase),
83 ipc_database_callbacks_id_(ipc_database_callbacks_id),
84 data_loss_(blink::WebIDBDataLossNone), 78 data_loss_(blink::WebIDBDataLossNone),
85 sent_blocked_(false) {} 79 sent_blocked_(false) {}
86 80
87 IndexedDBCallbacks::~IndexedDBCallbacks() {} 81 IndexedDBCallbacks::~IndexedDBCallbacks() {}
88 82
89 void IndexedDBCallbacks::OnError(const IndexedDBDatabaseError& error) { 83 void IndexedDBCallbacks::OnError(const IndexedDBDatabaseError& error) {
90 DCHECK(dispatcher_host_.get()); 84 DCHECK(dispatcher_host_.get());
91 85
92 dispatcher_host_->Send(new IndexedDBMsg_CallbacksError( 86 dispatcher_host_->Send(new IndexedDBMsg_CallbacksError(
93 ipc_thread_id_, ipc_callbacks_id_, error.code(), error.message())); 87 ipc_thread_id_, ipc_callbacks_id_, error.code(), error.message()));
94 dispatcher_host_ = NULL; 88 dispatcher_host_ = NULL;
95 89
96 if (!connection_open_start_time_.is_null()) { 90 if (!connection_open_start_time_.is_null()) {
97 UMA_HISTOGRAM_MEDIUM_TIMES( 91 UMA_HISTOGRAM_MEDIUM_TIMES(
98 "WebCore.IndexedDB.OpenTime.Error", 92 "WebCore.IndexedDB.OpenTime.Error",
99 base::TimeTicks::Now() - connection_open_start_time_); 93 base::TimeTicks::Now() - connection_open_start_time_);
100 connection_open_start_time_ = base::TimeTicks(); 94 connection_open_start_time_ = base::TimeTicks();
101 } 95 }
102 } 96 }
103 97
104 void IndexedDBCallbacks::OnSuccess(const std::vector<base::string16>& value) { 98 void IndexedDBCallbacks::OnSuccess(const std::vector<base::string16>& value) {
105 DCHECK(dispatcher_host_.get()); 99 DCHECK(dispatcher_host_.get());
106 100
107 DCHECK_EQ(kNoCursor, ipc_cursor_id_); 101 DCHECK_EQ(kNoCursor, ipc_cursor_id_);
108 DCHECK_EQ(kNoTransaction, host_transaction_id_); 102 DCHECK_EQ(kNoTransaction, host_transaction_id_);
109 DCHECK_EQ(kNoDatabase, ipc_database_id_); 103 DCHECK_EQ(kNoDatabase, ipc_database_id_);
110 DCHECK_EQ(kNoDatabaseCallbacks, ipc_database_callbacks_id_);
111 DCHECK_EQ(blink::WebIDBDataLossNone, data_loss_); 104 DCHECK_EQ(blink::WebIDBDataLossNone, data_loss_);
112 105
113 std::vector<base::string16> list; 106 std::vector<base::string16> list;
114 for (unsigned i = 0; i < value.size(); ++i) 107 for (unsigned i = 0; i < value.size(); ++i)
115 list.push_back(value[i]); 108 list.push_back(value[i]);
116 109
117 dispatcher_host_->Send(new IndexedDBMsg_CallbacksSuccessStringList( 110 dispatcher_host_->Send(new IndexedDBMsg_CallbacksSuccessStringList(
118 ipc_thread_id_, ipc_callbacks_id_, list)); 111 ipc_thread_id_, ipc_callbacks_id_, list));
119 dispatcher_host_ = NULL; 112 dispatcher_host_ = NULL;
120 } 113 }
121 114
122 void IndexedDBCallbacks::OnBlocked(int64_t existing_version) { 115 void IndexedDBCallbacks::OnBlocked(int64_t existing_version) {
123 DCHECK(dispatcher_host_.get()); 116 DCHECK(dispatcher_host_.get());
124 117
125 DCHECK_EQ(kNoCursor, ipc_cursor_id_); 118 DCHECK_EQ(kNoCursor, ipc_cursor_id_);
126 // No transaction/db callbacks for DeleteDatabase.
127 DCHECK_EQ(kNoTransaction == host_transaction_id_,
128 kNoDatabaseCallbacks == ipc_database_callbacks_id_);
129 DCHECK_EQ(kNoDatabase, ipc_database_id_); 119 DCHECK_EQ(kNoDatabase, ipc_database_id_);
130 120
131 if (sent_blocked_) 121 if (sent_blocked_)
132 return; 122 return;
133 123
134 sent_blocked_ = true; 124 sent_blocked_ = true;
135 dispatcher_host_->Send(new IndexedDBMsg_CallbacksIntBlocked( 125 dispatcher_host_->Send(new IndexedDBMsg_CallbacksIntBlocked(
136 ipc_thread_id_, ipc_callbacks_id_, existing_version)); 126 ipc_thread_id_, ipc_callbacks_id_, existing_version));
137 127
138 if (!connection_open_start_time_.is_null()) { 128 if (!connection_open_start_time_.is_null()) {
139 UMA_HISTOGRAM_MEDIUM_TIMES( 129 UMA_HISTOGRAM_MEDIUM_TIMES(
140 "WebCore.IndexedDB.OpenTime.Blocked", 130 "WebCore.IndexedDB.OpenTime.Blocked",
141 base::TimeTicks::Now() - connection_open_start_time_); 131 base::TimeTicks::Now() - connection_open_start_time_);
142 connection_open_start_time_ = base::TimeTicks(); 132 connection_open_start_time_ = base::TimeTicks();
143 } 133 }
144 } 134 }
145 135
146 void IndexedDBCallbacks::OnUpgradeNeeded( 136 void IndexedDBCallbacks::OnUpgradeNeeded(
147 int64_t old_version, 137 int64_t old_version,
148 std::unique_ptr<IndexedDBConnection> connection, 138 std::unique_ptr<IndexedDBConnection> connection,
149 const IndexedDBDatabaseMetadata& metadata, 139 const IndexedDBDatabaseMetadata& metadata,
150 const IndexedDBDataLossInfo& data_loss_info) { 140 const IndexedDBDataLossInfo& data_loss_info) {
151 DCHECK(dispatcher_host_.get()); 141 DCHECK(dispatcher_host_.get());
152 142
153 DCHECK_EQ(kNoCursor, ipc_cursor_id_); 143 DCHECK_EQ(kNoCursor, ipc_cursor_id_);
154 DCHECK_NE(kNoTransaction, host_transaction_id_); 144 DCHECK_NE(kNoTransaction, host_transaction_id_);
155 DCHECK_EQ(kNoDatabase, ipc_database_id_); 145 DCHECK_EQ(kNoDatabase, ipc_database_id_);
156 DCHECK_NE(kNoDatabaseCallbacks, ipc_database_callbacks_id_);
157 146
158 data_loss_ = data_loss_info.status; 147 data_loss_ = data_loss_info.status;
159 dispatcher_host_->RegisterTransactionId(host_transaction_id_, origin_); 148 dispatcher_host_->RegisterTransactionId(host_transaction_id_, origin_);
160 int32_t ipc_database_id = 149 int32_t ipc_database_id =
161 dispatcher_host_->Add(connection.release(), ipc_thread_id_, origin_); 150 dispatcher_host_->Add(connection.release(), ipc_thread_id_, origin_);
162 if (ipc_database_id < 0) 151 if (ipc_database_id < 0)
163 return; 152 return;
164 ipc_database_id_ = ipc_database_id; 153 ipc_database_id_ = ipc_database_id;
165 IndexedDBMsg_CallbacksUpgradeNeeded_Params params; 154 IndexedDBMsg_CallbacksUpgradeNeeded_Params params;
166 params.ipc_thread_id = ipc_thread_id_; 155 params.ipc_thread_id = ipc_thread_id_;
167 params.ipc_callbacks_id = ipc_callbacks_id_; 156 params.ipc_callbacks_id = ipc_callbacks_id_;
168 params.ipc_database_id = ipc_database_id; 157 params.ipc_database_id = ipc_database_id;
169 params.ipc_database_callbacks_id = ipc_database_callbacks_id_;
170 params.old_version = old_version; 158 params.old_version = old_version;
171 params.idb_metadata = IndexedDBDispatcherHost::ConvertMetadata(metadata); 159 params.idb_metadata = IndexedDBDispatcherHost::ConvertMetadata(metadata);
172 params.data_loss = data_loss_info.status; 160 params.data_loss = data_loss_info.status;
173 params.data_loss_message = data_loss_info.message; 161 params.data_loss_message = data_loss_info.message;
174 dispatcher_host_->Send(new IndexedDBMsg_CallbacksUpgradeNeeded(params)); 162 dispatcher_host_->Send(new IndexedDBMsg_CallbacksUpgradeNeeded(params));
175 163
176 if (!connection_open_start_time_.is_null()) { 164 if (!connection_open_start_time_.is_null()) {
177 UMA_HISTOGRAM_MEDIUM_TIMES( 165 UMA_HISTOGRAM_MEDIUM_TIMES(
178 "WebCore.IndexedDB.OpenTime.UpgradeNeeded", 166 "WebCore.IndexedDB.OpenTime.UpgradeNeeded",
179 base::TimeTicks::Now() - connection_open_start_time_); 167 base::TimeTicks::Now() - connection_open_start_time_);
180 connection_open_start_time_ = base::TimeTicks(); 168 connection_open_start_time_ = base::TimeTicks();
181 } 169 }
182 } 170 }
183 171
184 void IndexedDBCallbacks::OnSuccess( 172 void IndexedDBCallbacks::OnSuccess(
185 std::unique_ptr<IndexedDBConnection> connection, 173 std::unique_ptr<IndexedDBConnection> connection,
186 const IndexedDBDatabaseMetadata& metadata) { 174 const IndexedDBDatabaseMetadata& metadata) {
187 DCHECK(dispatcher_host_.get()); 175 DCHECK(dispatcher_host_.get());
188 176
189 DCHECK_EQ(kNoCursor, ipc_cursor_id_); 177 DCHECK_EQ(kNoCursor, ipc_cursor_id_);
190 DCHECK_NE(kNoTransaction, host_transaction_id_); 178 DCHECK_NE(kNoTransaction, host_transaction_id_);
191 DCHECK_NE(ipc_database_id_ == kNoDatabase, !connection); 179 DCHECK_NE(ipc_database_id_ == kNoDatabase, !connection);
192 DCHECK_NE(kNoDatabaseCallbacks, ipc_database_callbacks_id_);
193 180
194 scoped_refptr<IndexedDBCallbacks> self(this); 181 scoped_refptr<IndexedDBCallbacks> self(this);
195 182
196 int32_t ipc_object_id = kNoDatabase; 183 int32_t ipc_object_id = kNoDatabase;
197 // Only register if the connection was not previously sent in OnUpgradeNeeded. 184 // Only register if the connection was not previously sent in OnUpgradeNeeded.
198 if (ipc_database_id_ == kNoDatabase) { 185 if (ipc_database_id_ == kNoDatabase) {
199 ipc_object_id = 186 ipc_object_id =
200 dispatcher_host_->Add(connection.release(), ipc_thread_id_, origin_); 187 dispatcher_host_->Add(connection.release(), ipc_thread_id_, origin_);
201 } 188 }
202 189
203 dispatcher_host_->Send(new IndexedDBMsg_CallbacksSuccessIDBDatabase( 190 dispatcher_host_->Send(new IndexedDBMsg_CallbacksSuccessIDBDatabase(
204 ipc_thread_id_, 191 ipc_thread_id_,
205 ipc_callbacks_id_, 192 ipc_callbacks_id_,
206 ipc_database_callbacks_id_,
207 ipc_object_id, 193 ipc_object_id,
208 IndexedDBDispatcherHost::ConvertMetadata(metadata))); 194 IndexedDBDispatcherHost::ConvertMetadata(metadata)));
209 dispatcher_host_ = NULL; 195 dispatcher_host_ = NULL;
210 196
211 if (!connection_open_start_time_.is_null()) { 197 if (!connection_open_start_time_.is_null()) {
212 UMA_HISTOGRAM_MEDIUM_TIMES( 198 UMA_HISTOGRAM_MEDIUM_TIMES(
213 "WebCore.IndexedDB.OpenTime.Success", 199 "WebCore.IndexedDB.OpenTime.Success",
214 base::TimeTicks::Now() - connection_open_start_time_); 200 base::TimeTicks::Now() - connection_open_start_time_);
215 connection_open_start_time_ = base::TimeTicks(); 201 connection_open_start_time_ = base::TimeTicks();
216 } 202 }
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 319
334 void IndexedDBCallbacks::OnSuccess(scoped_refptr<IndexedDBCursor> cursor, 320 void IndexedDBCallbacks::OnSuccess(scoped_refptr<IndexedDBCursor> cursor,
335 const IndexedDBKey& key, 321 const IndexedDBKey& key,
336 const IndexedDBKey& primary_key, 322 const IndexedDBKey& primary_key,
337 IndexedDBValue* value) { 323 IndexedDBValue* value) {
338 DCHECK(dispatcher_host_.get()); 324 DCHECK(dispatcher_host_.get());
339 325
340 DCHECK_EQ(kNoCursor, ipc_cursor_id_); 326 DCHECK_EQ(kNoCursor, ipc_cursor_id_);
341 DCHECK_EQ(kNoTransaction, host_transaction_id_); 327 DCHECK_EQ(kNoTransaction, host_transaction_id_);
342 DCHECK_EQ(kNoDatabase, ipc_database_id_); 328 DCHECK_EQ(kNoDatabase, ipc_database_id_);
343 DCHECK_EQ(kNoDatabaseCallbacks, ipc_database_callbacks_id_);
344 DCHECK_EQ(blink::WebIDBDataLossNone, data_loss_); 329 DCHECK_EQ(blink::WebIDBDataLossNone, data_loss_);
345 330
346 int32_t ipc_object_id = dispatcher_host_->Add(cursor.get()); 331 int32_t ipc_object_id = dispatcher_host_->Add(cursor.get());
347 std::unique_ptr<IndexedDBMsg_CallbacksSuccessIDBCursor_Params> params( 332 std::unique_ptr<IndexedDBMsg_CallbacksSuccessIDBCursor_Params> params(
348 new IndexedDBMsg_CallbacksSuccessIDBCursor_Params()); 333 new IndexedDBMsg_CallbacksSuccessIDBCursor_Params());
349 params->ipc_thread_id = ipc_thread_id_; 334 params->ipc_thread_id = ipc_thread_id_;
350 params->ipc_callbacks_id = ipc_callbacks_id_; 335 params->ipc_callbacks_id = ipc_callbacks_id_;
351 params->ipc_cursor_id = ipc_object_id; 336 params->ipc_cursor_id = ipc_object_id;
352 params->key = key; 337 params->key = key;
353 params->primary_key = primary_key; 338 params->primary_key = primary_key;
(...skipping 18 matching lines...) Expand all
372 } 357 }
373 358
374 void IndexedDBCallbacks::OnSuccess(const IndexedDBKey& key, 359 void IndexedDBCallbacks::OnSuccess(const IndexedDBKey& key,
375 const IndexedDBKey& primary_key, 360 const IndexedDBKey& primary_key,
376 IndexedDBValue* value) { 361 IndexedDBValue* value) {
377 DCHECK(dispatcher_host_.get()); 362 DCHECK(dispatcher_host_.get());
378 363
379 DCHECK_NE(kNoCursor, ipc_cursor_id_); 364 DCHECK_NE(kNoCursor, ipc_cursor_id_);
380 DCHECK_EQ(kNoTransaction, host_transaction_id_); 365 DCHECK_EQ(kNoTransaction, host_transaction_id_);
381 DCHECK_EQ(kNoDatabase, ipc_database_id_); 366 DCHECK_EQ(kNoDatabase, ipc_database_id_);
382 DCHECK_EQ(kNoDatabaseCallbacks, ipc_database_callbacks_id_);
383 DCHECK_EQ(blink::WebIDBDataLossNone, data_loss_); 367 DCHECK_EQ(blink::WebIDBDataLossNone, data_loss_);
384 368
385 IndexedDBCursor* idb_cursor = 369 IndexedDBCursor* idb_cursor =
386 dispatcher_host_->GetCursorFromId(ipc_cursor_id_); 370 dispatcher_host_->GetCursorFromId(ipc_cursor_id_);
387 371
388 DCHECK(idb_cursor); 372 DCHECK(idb_cursor);
389 if (!idb_cursor) 373 if (!idb_cursor)
390 return; 374 return;
391 375
392 std::unique_ptr<IndexedDBMsg_CallbacksSuccessCursorContinue_Params> params( 376 std::unique_ptr<IndexedDBMsg_CallbacksSuccessCursorContinue_Params> params(
(...skipping 30 matching lines...) Expand all
423 const std::vector<IndexedDBKey>& primary_keys, 407 const std::vector<IndexedDBKey>& primary_keys,
424 std::vector<IndexedDBValue>* values) { 408 std::vector<IndexedDBValue>* values) {
425 DCHECK_EQ(keys.size(), primary_keys.size()); 409 DCHECK_EQ(keys.size(), primary_keys.size());
426 DCHECK_EQ(keys.size(), values->size()); 410 DCHECK_EQ(keys.size(), values->size());
427 411
428 DCHECK(dispatcher_host_.get()); 412 DCHECK(dispatcher_host_.get());
429 413
430 DCHECK_NE(kNoCursor, ipc_cursor_id_); 414 DCHECK_NE(kNoCursor, ipc_cursor_id_);
431 DCHECK_EQ(kNoTransaction, host_transaction_id_); 415 DCHECK_EQ(kNoTransaction, host_transaction_id_);
432 DCHECK_EQ(kNoDatabase, ipc_database_id_); 416 DCHECK_EQ(kNoDatabase, ipc_database_id_);
433 DCHECK_EQ(kNoDatabaseCallbacks, ipc_database_callbacks_id_);
434 DCHECK_EQ(blink::WebIDBDataLossNone, data_loss_); 417 DCHECK_EQ(blink::WebIDBDataLossNone, data_loss_);
435 418
436 std::vector<IndexedDBKey> msg_keys; 419 std::vector<IndexedDBKey> msg_keys;
437 std::vector<IndexedDBKey> msg_primary_keys; 420 std::vector<IndexedDBKey> msg_primary_keys;
438 421
439 for (size_t i = 0; i < keys.size(); ++i) { 422 for (size_t i = 0; i < keys.size(); ++i) {
440 msg_keys.push_back(keys[i]); 423 msg_keys.push_back(keys[i]);
441 msg_primary_keys.push_back(primary_keys[i]); 424 msg_primary_keys.push_back(primary_keys[i]);
442 } 425 }
443 426
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 void IndexedDBCallbacks::OnSuccess(IndexedDBReturnValue* value) { 464 void IndexedDBCallbacks::OnSuccess(IndexedDBReturnValue* value) {
482 DCHECK(dispatcher_host_.get()); 465 DCHECK(dispatcher_host_.get());
483 466
484 if (value && value->primary_key.IsValid()) { 467 if (value && value->primary_key.IsValid()) {
485 DCHECK_EQ(kNoCursor, ipc_cursor_id_); 468 DCHECK_EQ(kNoCursor, ipc_cursor_id_);
486 } else { 469 } else {
487 DCHECK(kNoCursor == ipc_cursor_id_ || value == NULL); 470 DCHECK(kNoCursor == ipc_cursor_id_ || value == NULL);
488 } 471 }
489 DCHECK_EQ(kNoTransaction, host_transaction_id_); 472 DCHECK_EQ(kNoTransaction, host_transaction_id_);
490 DCHECK_EQ(kNoDatabase, ipc_database_id_); 473 DCHECK_EQ(kNoDatabase, ipc_database_id_);
491 DCHECK_EQ(kNoDatabaseCallbacks, ipc_database_callbacks_id_);
492 DCHECK_EQ(blink::WebIDBDataLossNone, data_loss_); 474 DCHECK_EQ(blink::WebIDBDataLossNone, data_loss_);
493 475
494 std::unique_ptr<IndexedDBMsg_CallbacksSuccessValue_Params> params( 476 std::unique_ptr<IndexedDBMsg_CallbacksSuccessValue_Params> params(
495 new IndexedDBMsg_CallbacksSuccessValue_Params()); 477 new IndexedDBMsg_CallbacksSuccessValue_Params());
496 params->ipc_thread_id = ipc_thread_id_; 478 params->ipc_thread_id = ipc_thread_id_;
497 params->ipc_callbacks_id = ipc_callbacks_id_; 479 params->ipc_callbacks_id = ipc_callbacks_id_;
498 if (value && value->primary_key.IsValid()) { 480 if (value && value->primary_key.IsValid()) {
499 params->value.primary_key = value->primary_key; 481 params->value.primary_key = value->primary_key;
500 params->value.key_path = value->key_path; 482 params->value.key_path = value->key_path;
501 } 483 }
(...skipping 15 matching lines...) Expand all
517 dispatcher_host_ = NULL; 499 dispatcher_host_ = NULL;
518 } 500 }
519 501
520 void IndexedDBCallbacks::OnSuccessArray( 502 void IndexedDBCallbacks::OnSuccessArray(
521 std::vector<IndexedDBReturnValue>* values, 503 std::vector<IndexedDBReturnValue>* values,
522 const IndexedDBKeyPath& key_path) { 504 const IndexedDBKeyPath& key_path) {
523 DCHECK(dispatcher_host_.get()); 505 DCHECK(dispatcher_host_.get());
524 506
525 DCHECK_EQ(kNoTransaction, host_transaction_id_); 507 DCHECK_EQ(kNoTransaction, host_transaction_id_);
526 DCHECK_EQ(kNoDatabase, ipc_database_id_); 508 DCHECK_EQ(kNoDatabase, ipc_database_id_);
527 DCHECK_EQ(kNoDatabaseCallbacks, ipc_database_callbacks_id_);
528 DCHECK_EQ(blink::WebIDBDataLossNone, data_loss_); 509 DCHECK_EQ(blink::WebIDBDataLossNone, data_loss_);
529 510
530 std::unique_ptr<IndexedDBMsg_CallbacksSuccessArray_Params> params( 511 std::unique_ptr<IndexedDBMsg_CallbacksSuccessArray_Params> params(
531 new IndexedDBMsg_CallbacksSuccessArray_Params()); 512 new IndexedDBMsg_CallbacksSuccessArray_Params());
532 params->ipc_thread_id = ipc_thread_id_; 513 params->ipc_thread_id = ipc_thread_id_;
533 params->ipc_callbacks_id = ipc_callbacks_id_; 514 params->ipc_callbacks_id = ipc_callbacks_id_;
534 params->values.resize(values->size()); 515 params->values.resize(values->size());
535 516
536 bool found_blob_info = false; 517 bool found_blob_info = false;
537 for (size_t i = 0; i < values->size(); ++i) { 518 for (size_t i = 0; i < values->size(); ++i) {
(...skipping 23 matching lines...) Expand all
561 } 542 }
562 dispatcher_host_ = NULL; 543 dispatcher_host_ = NULL;
563 } 544 }
564 545
565 void IndexedDBCallbacks::OnSuccess(const IndexedDBKey& value) { 546 void IndexedDBCallbacks::OnSuccess(const IndexedDBKey& value) {
566 DCHECK(dispatcher_host_.get()); 547 DCHECK(dispatcher_host_.get());
567 548
568 DCHECK_EQ(kNoCursor, ipc_cursor_id_); 549 DCHECK_EQ(kNoCursor, ipc_cursor_id_);
569 DCHECK_EQ(kNoTransaction, host_transaction_id_); 550 DCHECK_EQ(kNoTransaction, host_transaction_id_);
570 DCHECK_EQ(kNoDatabase, ipc_database_id_); 551 DCHECK_EQ(kNoDatabase, ipc_database_id_);
571 DCHECK_EQ(kNoDatabaseCallbacks, ipc_database_callbacks_id_);
572 DCHECK_EQ(blink::WebIDBDataLossNone, data_loss_); 552 DCHECK_EQ(blink::WebIDBDataLossNone, data_loss_);
573 553
574 dispatcher_host_->Send(new IndexedDBMsg_CallbacksSuccessIndexedDBKey( 554 dispatcher_host_->Send(new IndexedDBMsg_CallbacksSuccessIndexedDBKey(
575 ipc_thread_id_, ipc_callbacks_id_, value)); 555 ipc_thread_id_, ipc_callbacks_id_, value));
576 dispatcher_host_ = NULL; 556 dispatcher_host_ = NULL;
577 } 557 }
578 558
579 void IndexedDBCallbacks::OnSuccess(int64_t value) { 559 void IndexedDBCallbacks::OnSuccess(int64_t value) {
580 DCHECK(dispatcher_host_.get()); 560 DCHECK(dispatcher_host_.get());
581 561
582 DCHECK_EQ(kNoCursor, ipc_cursor_id_); 562 DCHECK_EQ(kNoCursor, ipc_cursor_id_);
583 DCHECK_EQ(kNoTransaction, host_transaction_id_); 563 DCHECK_EQ(kNoTransaction, host_transaction_id_);
584 DCHECK_EQ(kNoDatabase, ipc_database_id_); 564 DCHECK_EQ(kNoDatabase, ipc_database_id_);
585 DCHECK_EQ(kNoDatabaseCallbacks, ipc_database_callbacks_id_);
586 DCHECK_EQ(blink::WebIDBDataLossNone, data_loss_); 565 DCHECK_EQ(blink::WebIDBDataLossNone, data_loss_);
587 566
588 dispatcher_host_->Send(new IndexedDBMsg_CallbacksSuccessInteger( 567 dispatcher_host_->Send(new IndexedDBMsg_CallbacksSuccessInteger(
589 ipc_thread_id_, ipc_callbacks_id_, value)); 568 ipc_thread_id_, ipc_callbacks_id_, value));
590 dispatcher_host_ = NULL; 569 dispatcher_host_ = NULL;
591 } 570 }
592 571
593 void IndexedDBCallbacks::OnSuccess() { 572 void IndexedDBCallbacks::OnSuccess() {
594 DCHECK(dispatcher_host_.get()); 573 DCHECK(dispatcher_host_.get());
595 574
596 DCHECK_EQ(kNoCursor, ipc_cursor_id_); 575 DCHECK_EQ(kNoCursor, ipc_cursor_id_);
597 DCHECK_EQ(kNoTransaction, host_transaction_id_); 576 DCHECK_EQ(kNoTransaction, host_transaction_id_);
598 DCHECK_EQ(kNoDatabase, ipc_database_id_); 577 DCHECK_EQ(kNoDatabase, ipc_database_id_);
599 DCHECK_EQ(kNoDatabaseCallbacks, ipc_database_callbacks_id_);
600 DCHECK_EQ(blink::WebIDBDataLossNone, data_loss_); 578 DCHECK_EQ(blink::WebIDBDataLossNone, data_loss_);
601 579
602 dispatcher_host_->Send(new IndexedDBMsg_CallbacksSuccessUndefined( 580 dispatcher_host_->Send(new IndexedDBMsg_CallbacksSuccessUndefined(
603 ipc_thread_id_, ipc_callbacks_id_)); 581 ipc_thread_id_, ipc_callbacks_id_));
604 dispatcher_host_ = NULL; 582 dispatcher_host_ = NULL;
605 } 583 }
606 584
607 void IndexedDBCallbacks::SetConnectionOpenStartTime( 585 void IndexedDBCallbacks::SetConnectionOpenStartTime(
608 const base::TimeTicks& start_time) { 586 const base::TimeTicks& start_time) {
609 connection_open_start_time_ = start_time; 587 connection_open_start_time_ = start_time;
610 } 588 }
611 589
612 } // namespace content 590 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_callbacks.h ('k') | content/browser/indexed_db/indexed_db_cursor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698