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

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

Issue 2472213003: [IndexedDB] Refactoring to remove ref ptrs and host transaction ids. (Closed)
Patch Set: rebased & working Created 4 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
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/cursor_impl.h" 17 #include "content/browser/indexed_db/cursor_impl.h"
18 #include "content/browser/indexed_db/database_impl.h" 18 #include "content/browser/indexed_db/database_impl.h"
19 #include "content/browser/indexed_db/indexed_db_blob_info.h" 19 #include "content/browser/indexed_db/indexed_db_blob_info.h"
20 #include "content/browser/indexed_db/indexed_db_connection.h" 20 #include "content/browser/indexed_db/indexed_db_connection.h"
21 #include "content/browser/indexed_db/indexed_db_context_impl.h" 21 #include "content/browser/indexed_db/indexed_db_context_impl.h"
22 #include "content/browser/indexed_db/indexed_db_cursor.h" 22 #include "content/browser/indexed_db/indexed_db_cursor.h"
23 #include "content/browser/indexed_db/indexed_db_database_error.h" 23 #include "content/browser/indexed_db/indexed_db_database_error.h"
24 #include "content/browser/indexed_db/indexed_db_return_value.h" 24 #include "content/browser/indexed_db/indexed_db_return_value.h"
25 #include "content/browser/indexed_db/indexed_db_tracing.h" 25 #include "content/browser/indexed_db/indexed_db_tracing.h"
26 #include "content/browser/indexed_db/indexed_db_transaction.h"
26 #include "content/browser/indexed_db/indexed_db_value.h" 27 #include "content/browser/indexed_db/indexed_db_value.h"
27 #include "content/common/indexed_db/indexed_db_constants.h" 28 #include "content/common/indexed_db/indexed_db_constants.h"
28 #include "content/common/indexed_db/indexed_db_metadata.h" 29 #include "content/common/indexed_db/indexed_db_metadata.h"
29 #include "mojo/public/cpp/bindings/strong_associated_binding.h" 30 #include "mojo/public/cpp/bindings/strong_associated_binding.h"
30 #include "storage/browser/blob/blob_storage_context.h" 31 #include "storage/browser/blob/blob_storage_context.h"
31 #include "storage/browser/blob/shareable_file_reference.h" 32 #include "storage/browser/blob/shareable_file_reference.h"
32 #include "storage/browser/quota/quota_manager.h" 33 #include "storage/browser/quota/quota_manager.h"
33 34
34 using indexed_db::mojom::CallbacksAssociatedPtrInfo; 35 using indexed_db::mojom::CallbacksAssociatedPtrInfo;
35 using std::swap; 36 using std::swap;
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 UMA_HISTOGRAM_MEDIUM_TIMES( 209 UMA_HISTOGRAM_MEDIUM_TIMES(
209 "WebCore.IndexedDB.OpenTime.Blocked", 210 "WebCore.IndexedDB.OpenTime.Blocked",
210 base::TimeTicks::Now() - connection_open_start_time_); 211 base::TimeTicks::Now() - connection_open_start_time_);
211 connection_open_start_time_ = base::TimeTicks(); 212 connection_open_start_time_ = base::TimeTicks();
212 } 213 }
213 } 214 }
214 215
215 void IndexedDBCallbacks::OnUpgradeNeeded( 216 void IndexedDBCallbacks::OnUpgradeNeeded(
216 int64_t old_version, 217 int64_t old_version,
217 std::unique_ptr<IndexedDBConnection> connection, 218 std::unique_ptr<IndexedDBConnection> connection,
219 IndexedDBTransaction* transaction,
218 const IndexedDBDatabaseMetadata& metadata, 220 const IndexedDBDatabaseMetadata& metadata,
219 const IndexedDBDataLossInfo& data_loss_info) { 221 const IndexedDBDataLossInfo& data_loss_info) {
220 DCHECK(thread_checker_.CalledOnValidThread()); 222 DCHECK(thread_checker_.CalledOnValidThread());
221 DCHECK(dispatcher_host_); 223 DCHECK(dispatcher_host_);
222 DCHECK(io_helper_); 224 DCHECK(io_helper_);
223 225
224 DCHECK_NE(kNoTransaction, host_transaction_id_); 226 DCHECK_NE(kNoTransaction, host_transaction_id_);
225 DCHECK(!database_sent_); 227 DCHECK(!database_sent_);
226 228
227 data_loss_ = data_loss_info.status; 229 data_loss_ = data_loss_info.status;
228 dispatcher_host_->RegisterTransactionId(host_transaction_id_, origin_);
229 database_sent_ = true; 230 database_sent_ = true;
230 auto database = base::MakeUnique<DatabaseImpl>(std::move(connection), origin_, 231 auto database = base::MakeUnique<DatabaseImpl>(std::move(connection), origin_,
231 dispatcher_host_); 232 dispatcher_host_);
232 233
233 BrowserThread::PostTask( 234 BrowserThread::PostTask(
234 BrowserThread::IO, FROM_HERE, 235 BrowserThread::IO, FROM_HERE,
235 base::Bind(&IOThreadHelper::SendUpgradeNeeded, 236 base::Bind(&IOThreadHelper::SendUpgradeNeeded,
236 base::Unretained(io_helper_.get()), base::Passed(&database), 237 base::Unretained(io_helper_.get()), base::Passed(&database),
237 old_version, data_loss_info.status, data_loss_info.message, 238 old_version, data_loss_info.status, data_loss_info.message,
238 metadata)); 239 metadata));
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 dispatcher_host_ = nullptr; 272 dispatcher_host_ = nullptr;
272 273
273 if (!connection_open_start_time_.is_null()) { 274 if (!connection_open_start_time_.is_null()) {
274 UMA_HISTOGRAM_MEDIUM_TIMES( 275 UMA_HISTOGRAM_MEDIUM_TIMES(
275 "WebCore.IndexedDB.OpenTime.Success", 276 "WebCore.IndexedDB.OpenTime.Success",
276 base::TimeTicks::Now() - connection_open_start_time_); 277 base::TimeTicks::Now() - connection_open_start_time_);
277 connection_open_start_time_ = base::TimeTicks(); 278 connection_open_start_time_ = base::TimeTicks();
278 } 279 }
279 } 280 }
280 281
281 void IndexedDBCallbacks::OnSuccess(scoped_refptr<IndexedDBCursor> cursor, 282 void IndexedDBCallbacks::OnSuccess(std::unique_ptr<IndexedDBCursor> cursor,
282 const IndexedDBKey& key, 283 const IndexedDBKey& key,
283 const IndexedDBKey& primary_key, 284 const IndexedDBKey& primary_key,
284 IndexedDBValue* value) { 285 IndexedDBValue* value) {
285 DCHECK(thread_checker_.CalledOnValidThread()); 286 DCHECK(thread_checker_.CalledOnValidThread());
286 DCHECK(dispatcher_host_); 287 DCHECK(dispatcher_host_);
287 DCHECK(io_helper_); 288 DCHECK(io_helper_);
288 289
289 DCHECK_EQ(kNoTransaction, host_transaction_id_); 290 DCHECK_EQ(kNoTransaction, host_transaction_id_);
290 DCHECK_EQ(blink::WebIDBDataLossNone, data_loss_); 291 DCHECK_EQ(blink::WebIDBDataLossNone, data_loss_);
291 292
292 auto cursor_impl = 293 auto cursor_impl = base::MakeUnique<CursorImpl>(std::move(cursor), origin_,
293 base::MakeUnique<CursorImpl>(cursor, origin_, dispatcher_host_); 294 dispatcher_host_);
294 295
295 ::indexed_db::mojom::ValuePtr mojo_value; 296 ::indexed_db::mojom::ValuePtr mojo_value;
296 std::vector<IndexedDBBlobInfo> blob_info; 297 std::vector<IndexedDBBlobInfo> blob_info;
297 if (value) { 298 if (value) {
298 mojo_value = ConvertValue(value); 299 mojo_value = ConvertValue(value);
299 blob_info.swap(value->blob_info); 300 blob_info.swap(value->blob_info);
300 } 301 }
301 302
302 BrowserThread::PostTask( 303 BrowserThread::PostTask(
303 BrowserThread::IO, FROM_HERE, 304 BrowserThread::IO, FROM_HERE,
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 IDB_TRACE("IndexedDBCallbacks::CreateAllBlobs"); 608 IDB_TRACE("IndexedDBCallbacks::CreateAllBlobs");
608 DCHECK_EQ(blob_info.size(), blob_or_file_info->size()); 609 DCHECK_EQ(blob_info.size(), blob_or_file_info->size());
609 if (!dispatcher_host_->blob_storage_context()) 610 if (!dispatcher_host_->blob_storage_context())
610 return false; 611 return false;
611 for (size_t i = 0; i < blob_info.size(); ++i) 612 for (size_t i = 0; i < blob_info.size(); ++i)
612 (*blob_or_file_info)[i]->uuid = CreateBlobData(blob_info[i]); 613 (*blob_or_file_info)[i]->uuid = CreateBlobData(blob_info[i]);
613 return true; 614 return true;
614 } 615 }
615 616
616 } // namespace content 617 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698