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

Issue 794273002: Introduce SafeBrowsingDatabase::ThreadSafeStateManager. (Closed)

Created:
6 years ago by gab
Modified:
5 years, 12 months ago
Reviewers:
mattm
CC:
chromium-reviews, grt+watch_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@a6_dedup_sideeffectfreeWLcode
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Introduce SafeBrowsingDatabase::ThreadSafeStateManager. This enforces thread-safety by design via transactions for any implementation code accessing shared SafeBrowsingDatabase members. Previously this was enforced by assuming everybody would make proper usage of |lookup_lock_| but this was deemed insufficient as programming mistakes proved easy to make twice. One of the subtleties of this transactional model (which made the previous ad-hoc locking even harder to prove (and keep) correct) is that only the main database thread is allowed to modify this state, allowing for unlocked reads on the main thread which are important to avoid contention when flushing to disk. BUG=440517 Committed: https://crrev.com/b2f71d56ad092f81ac20f5fc72a12098866cad50 Cr-Commit-Position: refs/heads/master@{#309611}

Patch Set 1 : #

Total comments: 17

Patch Set 2 : bring main-thread-checks back #

Patch Set 3 : merge #

Patch Set 4 : const ReadTransactions/mutable cache #

Patch Set 5 : Move helpers/Augment WriteTransaction's functionality, reducing exposure of ThreadSafeStateManager'… #

Patch Set 6 : private constructors w/ friend #

Patch Set 7 : inline even more transactions #

Total comments: 6

Patch Set 8 : fix memory management #

Unified diffs Side-by-side diffs Delta from patch set Stats (+462 lines, -237 lines) Patch
M chrome/browser/safe_browsing/safe_browsing_database.h View 1 2 3 4 5 6 9 chunks +123 lines, -58 lines 0 comments Download
M chrome/browser/safe_browsing/safe_browsing_database.cc View 1 2 3 4 5 6 7 33 chunks +326 lines, -171 lines 0 comments Download
M chrome/browser/safe_browsing/safe_browsing_database_unittest.cc View 1 6 chunks +13 lines, -8 lines 0 comments Download

Messages

Total messages: 20 (7 generated)
gab
Matt, here's the thread-safety-by-design I've been talking about, please take a look. This is based ...
6 years ago (2014-12-11 19:39:20 UTC) #3
gab
Whoops, actually adding Matt, see below :-)! On 2014/12/11 19:39:20, gab wrote: > Matt, here's ...
6 years ago (2014-12-11 19:40:09 UTC) #5
mattm
https://codereview.chromium.org/794273002/diff/40001/chrome/browser/safe_browsing/safe_browsing_database.cc File chrome/browser/safe_browsing/safe_browsing_database.cc (left): https://codereview.chromium.org/794273002/diff/40001/chrome/browser/safe_browsing/safe_browsing_database.cc#oldcode760 chrome/browser/safe_browsing/safe_browsing_database.cc:760: DCHECK(thread_checker_.CalledOnValidThread()); Why are all these removed? https://codereview.chromium.org/794273002/diff/40001/chrome/browser/safe_browsing/safe_browsing_database.cc File chrome/browser/safe_browsing/safe_browsing_database.cc ...
6 years ago (2014-12-12 23:20:31 UTC) #6
gab
Some tweaks, but mostly replies with some questions below. Thanks once again! Gab https://codereview.chromium.org/794273002/diff/40001/chrome/browser/safe_browsing/safe_browsing_database.cc File ...
6 years ago (2014-12-15 23:02:30 UTC) #8
gab
@mattm: ping :-) Hey Matt, could you please take a look at the replies/questions below ...
6 years ago (2014-12-18 21:19:48 UTC) #10
mattm
https://codereview.chromium.org/794273002/diff/40001/chrome/browser/safe_browsing/safe_browsing_database.cc File chrome/browser/safe_browsing/safe_browsing_database.cc (right): https://codereview.chromium.org/794273002/diff/40001/chrome/browser/safe_browsing/safe_browsing_database.cc#newcode475 chrome/browser/safe_browsing/safe_browsing_database.cc:475: ReadTransaction(ThreadSafeStateManager* outer, On 2014/12/15 23:02:30, gab wrote: > On ...
6 years ago (2014-12-23 02:09:45 UTC) #11
gab
Hey Matt, responded below and made a couple of tweaks to improve the overall design. ...
5 years, 12 months ago (2014-12-23 21:39:54 UTC) #13
mattm
https://codereview.chromium.org/794273002/diff/40001/chrome/browser/safe_browsing/safe_browsing_database.cc File chrome/browser/safe_browsing/safe_browsing_database.cc (right): https://codereview.chromium.org/794273002/diff/40001/chrome/browser/safe_browsing/safe_browsing_database.cc#newcode475 chrome/browser/safe_browsing/safe_browsing_database.cc:475: ReadTransaction(ThreadSafeStateManager* outer, On 2014/12/23 21:39:54, gab wrote: > On ...
5 years, 12 months ago (2014-12-24 00:29:54 UTC) #14
gab
Oops, memory management mistakes fixed, good catch! Thanks, Gab https://codereview.chromium.org/794273002/diff/220001/chrome/browser/safe_browsing/safe_browsing_database.cc File chrome/browser/safe_browsing/safe_browsing_database.cc (right): https://codereview.chromium.org/794273002/diff/220001/chrome/browser/safe_browsing/safe_browsing_database.cc#newcode543 chrome/browser/safe_browsing/safe_browsing_database.cc:543: ...
5 years, 12 months ago (2014-12-24 01:28:58 UTC) #15
mattm
lgtm, thanks for taking this on!
5 years, 12 months ago (2014-12-24 02:27:50 UTC) #16
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/794273002/240001
5 years, 12 months ago (2014-12-24 02:58:37 UTC) #18
commit-bot: I haz the power
Committed patchset #8 (id:240001)
5 years, 12 months ago (2014-12-24 03:54:10 UTC) #19
commit-bot: I haz the power
5 years, 12 months ago (2014-12-24 03:54:55 UTC) #20
Message was sent while issue was closed.
Patchset 8 (id:??) landed as
https://crrev.com/b2f71d56ad092f81ac20f5fc72a12098866cad50
Cr-Commit-Position: refs/heads/master@{#309611}

Powered by Google App Engine
This is Rietveld 408576698