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

Side by Side Diff: content/child/indexed_db/indexed_db_database_callbacks_impl.cc

Issue 2506443002: Fix data race in IndexedDBDatabaseCallbacksImpl::Abort (Closed)
Patch Set: Created 4 years, 1 month 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 | « no previous file | 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/child/indexed_db/indexed_db_database_callbacks_impl.h" 5 #include "content/child/indexed_db/indexed_db_database_callbacks_impl.h"
6 6
7 #include "content/child/indexed_db/indexed_db_dispatcher.h" 7 #include "content/child/indexed_db/indexed_db_dispatcher.h"
8 #include "content/child/thread_safe_sender.h" 8 #include "content/child/thread_safe_sender.h"
9 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseCal lbacks.h" 9 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseCal lbacks.h"
10 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseErr or.h" 10 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseErr or.h"
11 11
12 using blink::WebIDBDatabaseCallbacks; 12 using blink::WebIDBDatabaseCallbacks;
13 13
14 namespace content { 14 namespace content {
15 15
16 namespace { 16 namespace {
17 17
18 void DeleteDatabaseCallbacks(WebIDBDatabaseCallbacks* callbacks, 18 void DeleteDatabaseCallbacks(WebIDBDatabaseCallbacks* callbacks,
19 ThreadSafeSender* thread_safe_sender) { 19 ThreadSafeSender* thread_safe_sender) {
20 IndexedDBDispatcher* dispatcher = 20 IndexedDBDispatcher* dispatcher =
21 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender); 21 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender);
22 dispatcher->UnregisterMojoOwnedDatabaseCallbacks(callbacks); 22 dispatcher->UnregisterMojoOwnedDatabaseCallbacks(callbacks);
23 delete callbacks; 23 delete callbacks;
24 } 24 }
25 25
26 void BuildErrorAndAbort(WebIDBDatabaseCallbacks* callbacks,
27 int64_t transaction_id,
28 int32_t code,
29 const base::string16& message) {
30 callbacks->onAbort(transaction_id, blink::WebIDBDatabaseError(code, message));
31 }
32
26 } // namespace 33 } // namespace
27 34
28 IndexedDBDatabaseCallbacksImpl::IndexedDBDatabaseCallbacksImpl( 35 IndexedDBDatabaseCallbacksImpl::IndexedDBDatabaseCallbacksImpl(
29 std::unique_ptr<WebIDBDatabaseCallbacks> callbacks, 36 std::unique_ptr<WebIDBDatabaseCallbacks> callbacks,
30 scoped_refptr<ThreadSafeSender> thread_safe_sender) 37 scoped_refptr<ThreadSafeSender> thread_safe_sender)
31 : callback_runner_(base::ThreadTaskRunnerHandle::Get()), 38 : callback_runner_(base::ThreadTaskRunnerHandle::Get()),
32 thread_safe_sender_(thread_safe_sender), 39 thread_safe_sender_(thread_safe_sender),
33 callbacks_(callbacks.release()) { 40 callbacks_(callbacks.release()) {
34 IndexedDBDispatcher* dispatcher = 41 IndexedDBDispatcher* dispatcher =
35 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get()); 42 IndexedDBDispatcher::ThreadSpecificInstance(thread_safe_sender_.get());
(...skipping 16 matching lines...) Expand all
52 int64_t new_version) { 59 int64_t new_version) {
53 callback_runner_->PostTask( 60 callback_runner_->PostTask(
54 FROM_HERE, 61 FROM_HERE,
55 base::Bind(&WebIDBDatabaseCallbacks::onVersionChange, 62 base::Bind(&WebIDBDatabaseCallbacks::onVersionChange,
56 base::Unretained(callbacks_), old_version, new_version)); 63 base::Unretained(callbacks_), old_version, new_version));
57 } 64 }
58 65
59 void IndexedDBDatabaseCallbacksImpl::Abort(int64_t transaction_id, 66 void IndexedDBDatabaseCallbacksImpl::Abort(int64_t transaction_id,
60 int32_t code, 67 int32_t code,
61 const base::string16& message) { 68 const base::string16& message) {
69 // Indirect through BuildErrorAndAbort because it isn't safe to pass a
70 // WebIDBDatabaseError between threads.
62 callback_runner_->PostTask( 71 callback_runner_->PostTask(
63 FROM_HERE, base::Bind(&WebIDBDatabaseCallbacks::onAbort, 72 FROM_HERE, base::Bind(&BuildErrorAndAbort, base::Unretained(callbacks_),
64 base::Unretained(callbacks_), transaction_id, 73 transaction_id, code, message));
65 blink::WebIDBDatabaseError(code, message)));
66 } 74 }
67 75
68 void IndexedDBDatabaseCallbacksImpl::Complete(int64_t transaction_id) { 76 void IndexedDBDatabaseCallbacksImpl::Complete(int64_t transaction_id) {
69 callback_runner_->PostTask( 77 callback_runner_->PostTask(
70 FROM_HERE, base::Bind(&WebIDBDatabaseCallbacks::onComplete, 78 FROM_HERE, base::Bind(&WebIDBDatabaseCallbacks::onComplete,
71 base::Unretained(callbacks_), transaction_id)); 79 base::Unretained(callbacks_), transaction_id));
72 } 80 }
73 81
74 } // namespace content 82 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698