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

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

Issue 2439863002: Prevent cross-thread refcounting for thread-unsafe IndexedDBCallbacks. (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « content/browser/indexed_db/indexed_db_database_callbacks.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 if (!IsValidOrigin(origin)) { 286 if (!IsValidOrigin(origin)) {
287 mojo::ReportBadMessage(kInvalidOrigin); 287 mojo::ReportBadMessage(kInvalidOrigin);
288 return; 288 return;
289 } 289 }
290 290
291 scoped_refptr<IndexedDBCallbacks> callbacks( 291 scoped_refptr<IndexedDBCallbacks> callbacks(
292 new IndexedDBCallbacks(this, origin, std::move(callbacks_info))); 292 new IndexedDBCallbacks(this, origin, std::move(callbacks_info)));
293 indexed_db_context_->TaskRunner()->PostTask( 293 indexed_db_context_->TaskRunner()->PostTask(
294 FROM_HERE, 294 FROM_HERE,
295 base::Bind(&IndexedDBDispatcherHost::GetDatabaseNamesOnIDBThread, this, 295 base::Bind(&IndexedDBDispatcherHost::GetDatabaseNamesOnIDBThread, this,
296 callbacks, origin)); 296 base::Passed(&callbacks), origin));
297 } 297 }
298 298
299 void IndexedDBDispatcherHost::Open( 299 void IndexedDBDispatcherHost::Open(
300 int32_t worker_thread, 300 int32_t worker_thread,
301 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info, 301 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info,
302 ::indexed_db::mojom::DatabaseCallbacksAssociatedPtrInfo 302 ::indexed_db::mojom::DatabaseCallbacksAssociatedPtrInfo
303 database_callbacks_info, 303 database_callbacks_info,
304 const url::Origin& origin, 304 const url::Origin& origin,
305 const base::string16& name, 305 const base::string16& name,
306 int64_t version, 306 int64_t version,
307 int64_t transaction_id) { 307 int64_t transaction_id) {
308 DCHECK_CURRENTLY_ON(BrowserThread::IO); 308 DCHECK_CURRENTLY_ON(BrowserThread::IO);
309 309
310 if (!IsValidOrigin(origin)) { 310 if (!IsValidOrigin(origin)) {
311 mojo::ReportBadMessage(kInvalidOrigin); 311 mojo::ReportBadMessage(kInvalidOrigin);
312 return; 312 return;
313 } 313 }
314 314
315 scoped_refptr<IndexedDBCallbacks> callbacks( 315 scoped_refptr<IndexedDBCallbacks> callbacks(
316 new IndexedDBCallbacks(this, origin, std::move(callbacks_info))); 316 new IndexedDBCallbacks(this, origin, std::move(callbacks_info)));
317 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks( 317 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks(
318 new IndexedDBDatabaseCallbacks(this, worker_thread, 318 new IndexedDBDatabaseCallbacks(this, worker_thread,
319 std::move(database_callbacks_info))); 319 std::move(database_callbacks_info)));
320 indexed_db_context_->TaskRunner()->PostTask( 320 indexed_db_context_->TaskRunner()->PostTask(
321 FROM_HERE, 321 FROM_HERE,
322 base::Bind(&IndexedDBDispatcherHost::OpenOnIDBThread, this, callbacks, 322 base::Bind(&IndexedDBDispatcherHost::OpenOnIDBThread, this,
323 database_callbacks, origin, name, version, transaction_id)); 323 base::Passed(&callbacks), base::Passed(&database_callbacks),
324 origin, name, version, transaction_id));
324 } 325 }
325 326
326 void IndexedDBDispatcherHost::DeleteDatabase( 327 void IndexedDBDispatcherHost::DeleteDatabase(
327 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info, 328 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info,
328 const url::Origin& origin, 329 const url::Origin& origin,
329 const base::string16& name) { 330 const base::string16& name) {
330 DCHECK_CURRENTLY_ON(BrowserThread::IO); 331 DCHECK_CURRENTLY_ON(BrowserThread::IO);
331 332
332 if (!IsValidOrigin(origin)) { 333 if (!IsValidOrigin(origin)) {
333 mojo::ReportBadMessage(kInvalidOrigin); 334 mojo::ReportBadMessage(kInvalidOrigin);
334 return; 335 return;
335 } 336 }
336 337
337 scoped_refptr<IndexedDBCallbacks> callbacks( 338 scoped_refptr<IndexedDBCallbacks> callbacks(
338 new IndexedDBCallbacks(this, origin, std::move(callbacks_info))); 339 new IndexedDBCallbacks(this, origin, std::move(callbacks_info)));
339 indexed_db_context_->TaskRunner()->PostTask( 340 indexed_db_context_->TaskRunner()->PostTask(
340 FROM_HERE, base::Bind(&IndexedDBDispatcherHost::DeleteDatabaseOnIDBThread, 341 FROM_HERE, base::Bind(&IndexedDBDispatcherHost::DeleteDatabaseOnIDBThread,
341 this, callbacks, origin, name)); 342 this, base::Passed(&callbacks), origin, name));
342 } 343 }
343 344
344 void IndexedDBDispatcherHost::GetDatabaseNamesOnIDBThread( 345 void IndexedDBDispatcherHost::GetDatabaseNamesOnIDBThread(
345 scoped_refptr<IndexedDBCallbacks> callbacks, 346 scoped_refptr<IndexedDBCallbacks> callbacks,
346 const url::Origin& origin) { 347 const url::Origin& origin) {
347 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); 348 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread());
348 349
349 base::FilePath indexed_db_path = indexed_db_context_->data_path(); 350 base::FilePath indexed_db_path = indexed_db_context_->data_path();
350 context()->GetIDBFactory()->GetDatabaseNames( 351 context()->GetIDBFactory()->GetDatabaseNames(
351 callbacks, origin, indexed_db_path, request_context_getter_); 352 callbacks, origin, indexed_db_path, request_context_getter_);
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 DLOG(ERROR) << "Unable to reset prefetch"; 1110 DLOG(ERROR) << "Unable to reset prefetch";
1110 } 1111 }
1111 1112
1112 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( 1113 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed(
1113 int32_t ipc_object_id) { 1114 int32_t ipc_object_id) {
1114 DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread()); 1115 DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread());
1115 parent_->DestroyObject(&map_, ipc_object_id); 1116 parent_->DestroyObject(&map_, ipc_object_id);
1116 } 1117 }
1117 1118
1118 } // namespace content 1119 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_database_callbacks.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698