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

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

Issue 2828953002: [IndexedDB] Hold referenced to IDB::put blobs in the IDBRequest (Closed)
Patch Set: Created 3 years, 8 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_dispatcher_host.h" 5 #include "content/browser/indexed_db/indexed_db_dispatcher_host.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/guid.h" 9 #include "base/guid.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/process/process.h" 11 #include "base/process/process.h"
12 #include "base/sequenced_task_runner.h" 12 #include "base/sequenced_task_runner.h"
13 #include "base/stl_util.h" 13 #include "base/stl_util.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "content/browser/blob_storage/blob_dispatcher_host.h"
15 #include "content/browser/indexed_db/indexed_db_callbacks.h" 16 #include "content/browser/indexed_db/indexed_db_callbacks.h"
16 #include "content/browser/indexed_db/indexed_db_connection.h" 17 #include "content/browser/indexed_db/indexed_db_connection.h"
17 #include "content/browser/indexed_db/indexed_db_context_impl.h" 18 #include "content/browser/indexed_db/indexed_db_context_impl.h"
18 #include "content/browser/indexed_db/indexed_db_database_callbacks.h" 19 #include "content/browser/indexed_db/indexed_db_database_callbacks.h"
19 #include "content/browser/indexed_db/indexed_db_pending_connection.h" 20 #include "content/browser/indexed_db/indexed_db_pending_connection.h"
20 #include "content/public/browser/browser_thread.h" 21 #include "content/public/browser/browser_thread.h"
21 #include "storage/browser/blob/blob_data_builder.h" 22 #include "storage/browser/blob/blob_data_builder.h"
22 #include "storage/browser/blob/blob_storage_context.h" 23 #include "storage/browser/blob/blob_storage_context.h"
23 #include "storage/browser/database/database_util.h" 24 #include "storage/browser/database/database_util.h"
24 #include "url/origin.h" 25 #include "url/origin.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 DISALLOW_COPY_AND_ASSIGN(IDBThreadHelper); 69 DISALLOW_COPY_AND_ASSIGN(IDBThreadHelper);
69 }; 70 };
70 71
71 IndexedDBDispatcherHost::IndexedDBDispatcherHost( 72 IndexedDBDispatcherHost::IndexedDBDispatcherHost(
72 int ipc_process_id, 73 int ipc_process_id,
73 scoped_refptr<net::URLRequestContextGetter> request_context_getter, 74 scoped_refptr<net::URLRequestContextGetter> request_context_getter,
74 scoped_refptr<IndexedDBContextImpl> indexed_db_context, 75 scoped_refptr<IndexedDBContextImpl> indexed_db_context,
75 scoped_refptr<ChromeBlobStorageContext> blob_storage_context) 76 scoped_refptr<ChromeBlobStorageContext> blob_storage_context)
76 : indexed_db_context_(std::move(indexed_db_context)), 77 : indexed_db_context_(std::move(indexed_db_context)),
77 blob_storage_context_(std::move(blob_storage_context)), 78 blob_storage_context_(std::move(blob_storage_context)),
79 blob_dispatcher_host_(nullptr),
78 idb_runner_(indexed_db_context_->TaskRunner()), 80 idb_runner_(indexed_db_context_->TaskRunner()),
79 ipc_process_id_(ipc_process_id), 81 ipc_process_id_(ipc_process_id),
80 weak_factory_(this) { 82 weak_factory_(this) {
81 // Can be null in unittests. 83 // Can be null in unittests.
82 idb_helper_ = idb_runner_ 84 idb_helper_ = idb_runner_
83 ? new IDBThreadHelper(ipc_process_id_, 85 ? new IDBThreadHelper(ipc_process_id_,
84 std::move(request_context_getter), 86 std::move(request_context_getter),
85 indexed_db_context_) 87 indexed_db_context_)
86 : nullptr; 88 : nullptr;
87 DCHECK(indexed_db_context_.get()); 89 DCHECK(indexed_db_context_.get());
(...skipping 14 matching lines...) Expand all
102 ::indexed_db::mojom::DatabaseAssociatedRequest request) { 104 ::indexed_db::mojom::DatabaseAssociatedRequest request) {
103 database_bindings_.AddBinding(std::move(database), std::move(request)); 105 database_bindings_.AddBinding(std::move(database), std::move(request));
104 } 106 }
105 107
106 void IndexedDBDispatcherHost::AddCursorBinding( 108 void IndexedDBDispatcherHost::AddCursorBinding(
107 std::unique_ptr<::indexed_db::mojom::Cursor> cursor, 109 std::unique_ptr<::indexed_db::mojom::Cursor> cursor,
108 ::indexed_db::mojom::CursorAssociatedRequest request) { 110 ::indexed_db::mojom::CursorAssociatedRequest request) {
109 cursor_bindings_.AddBinding(std::move(cursor), std::move(request)); 111 cursor_bindings_.AddBinding(std::move(cursor), std::move(request));
110 } 112 }
111 113
114 void IndexedDBDispatcherHost::SetBlobDispatcherHost(
115 scoped_refptr<BlobDispatcherHost> host) {
116 blob_dispatcher_host_ = std::move(host);
pwnall 2017/04/21 01:39:22 Would it make sense to DCHECK that the host_ is nu
117 }
118
119 void IndexedDBDispatcherHost::AckBlobRecievedFromIDB(const std::string& uuid) {
120 DCHECK(blob_dispatcher_host_);
121 blob_dispatcher_host_->AckBlobRecievedFromIDB(uuid);
122 }
123
112 std::string IndexedDBDispatcherHost::HoldBlobData( 124 std::string IndexedDBDispatcherHost::HoldBlobData(
113 const IndexedDBBlobInfo& blob_info) { 125 const IndexedDBBlobInfo& blob_info) {
114 DCHECK_CURRENTLY_ON(BrowserThread::IO); 126 DCHECK_CURRENTLY_ON(BrowserThread::IO);
115 std::string uuid = blob_info.uuid(); 127 std::string uuid = blob_info.uuid();
116 storage::BlobStorageContext* context = blob_storage_context_->context(); 128 storage::BlobStorageContext* context = blob_storage_context_->context();
117 std::unique_ptr<storage::BlobDataHandle> blob_data_handle; 129 std::unique_ptr<storage::BlobDataHandle> blob_data_handle;
118 if (uuid.empty()) { 130 if (uuid.empty()) {
119 uuid = base::GenerateGUID(); 131 uuid = base::GenerateGUID();
120 storage::BlobDataBuilder blob_data_builder(uuid); 132 storage::BlobDataBuilder blob_data_builder(uuid);
121 blob_data_builder.set_content_type(base::UTF16ToUTF8(blob_info.type())); 133 blob_data_builder.set_content_type(base::UTF16ToUTF8(blob_info.type()));
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); 289 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread());
278 290
279 base::FilePath indexed_db_path = indexed_db_context_->data_path(); 291 base::FilePath indexed_db_path = indexed_db_context_->data_path();
280 DCHECK(request_context_getter_); 292 DCHECK(request_context_getter_);
281 indexed_db_context_->GetIDBFactory()->DeleteDatabase( 293 indexed_db_context_->GetIDBFactory()->DeleteDatabase(
282 name, request_context_getter_, callbacks, origin, indexed_db_path, 294 name, request_context_getter_, callbacks, origin, indexed_db_path,
283 force_close); 295 force_close);
284 } 296 }
285 297
286 } // namespace content 298 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698