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

Issue 2593503005: Don't abuse LevelDBObserver interface to pass GetAll result. (Closed)

Created:
4 years ago by Marijn Kruisselbrink
Modified:
4 years ago
Reviewers:
michaeln, jam, dcheng
CC:
Aaron Boodman, abarth-chromium, chromium-reviews, darin (slow to review), darin-cc_chromium.org, jam, mlamouri+watch-content_chromium.org, qsr+mojo_chromium.org, viettrungluu+watch_chromium.org, yzshen+watch_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Don't abuse LevelDBObserver interface to pass GetAll result. Instead add a separate (associated) interface just for the purpose of getting this async response. Also bind using a weak pointer to get this async callback to make sure the callback isn't actually called after Reset(). Without this fix (or an equivalent) the renderer would DCHECK in the sanity_check tests, so this also fixes that test to actually give a chance for async callbacks to run and detect issues like this. BUG=586194 Committed: https://crrev.com/a3b1e3d5bcc92b7303fdddcbd8994c66a4134e2a Cr-Commit-Position: refs/heads/master@{#440445}

Patch Set 1 #

Patch Set 2 : modify sanity_check test to give async callbacks a chance to cause problems #

Total comments: 4
Unified diffs Side-by-side diffs Delta from patch set Stats (+107 lines, -39 lines) Patch
M content/browser/leveldb_wrapper_impl.h View 1 chunk +3 lines, -2 lines 0 comments Download
M content/browser/leveldb_wrapper_impl.cc View 2 chunks +10 lines, -9 lines 2 comments Download
M content/browser/leveldb_wrapper_impl_unittest.cc View 6 chunks +42 lines, -3 lines 0 comments Download
M content/common/leveldb_wrapper.mojom View 3 chunks +11 lines, -6 lines 0 comments Download
M content/renderer/dom_storage/local_storage_cached_area.h View 3 chunks +1 line, -2 lines 0 comments Download
M content/renderer/dom_storage/local_storage_cached_area.cc View 5 chunks +39 lines, -16 lines 2 comments Download
M content/test/data/dom_storage/sanity_check.js View 1 1 chunk +1 line, -1 line 0 comments Download

Depends on Patchset:

Messages

Total messages: 22 (13 generated)
Marijn Kruisselbrink
A simpler fix for the dcheck failures this is fixing would of course be to ...
4 years ago (2016-12-21 19:01:09 UTC) #7
jam
lgtm
4 years ago (2016-12-21 21:24:39 UTC) #10
Marijn Kruisselbrink
+dcheng for mojom owners
4 years ago (2016-12-21 21:34:32 UTC) #12
dcheng
LGTM - it feels a bit awkward, but it makes sense why this is needed. ...
4 years ago (2016-12-22 07:21:47 UTC) #13
Marijn Kruisselbrink
https://codereview.chromium.org/2593503005/diff/20001/content/browser/leveldb_wrapper_impl.cc File content/browser/leveldb_wrapper_impl.cc (right): https://codereview.chromium.org/2593503005/diff/20001/content/browser/leveldb_wrapper_impl.cc#newcode224 content/browser/leveldb_wrapper_impl.cc:224: base::Passed(std::move(complete_callback)), callback)); On 2016/12/22 at 07:21:47, dcheng wrote: > ...
4 years ago (2016-12-22 17:12:19 UTC) #15
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2593503005/20001
4 years ago (2016-12-22 17:12:40 UTC) #16
commit-bot: I haz the power
Committed patchset #2 (id:20001)
4 years ago (2016-12-22 17:18:43 UTC) #19
commit-bot: I haz the power
Patchset 2 (id:??) landed as https://crrev.com/a3b1e3d5bcc92b7303fdddcbd8994c66a4134e2a Cr-Commit-Position: refs/heads/master@{#440445}
4 years ago (2016-12-22 17:20:09 UTC) #21
dcheng
4 years ago (2016-12-22 19:08:33 UTC) #22
Message was sent while issue was closed.
On 2016/12/22 17:12:19, Marijn Kruisselbrink wrote:
>
https://codereview.chromium.org/2593503005/diff/20001/content/browser/leveldb...
> File content/browser/leveldb_wrapper_impl.cc (right):
> 
>
https://codereview.chromium.org/2593503005/diff/20001/content/browser/leveldb...
> content/browser/leveldb_wrapper_impl.cc:224:
> base::Passed(std::move(complete_callback)), callback));
> On 2016/12/22 at 07:21:47, dcheng wrote:
> > Nit: base::Passed(&complete_callback)
> 
> I find the std::move version of base::Passed more readable (and of course the
> future with OnceCallback and std::move only would be even better. Did you make
> any more progress on getting mojo bindings to use OnceCallback?)

The argument for using & is for consistency. base::Passed(&x) 6-8x more common
than base::Passed(std::move(x)).

OnceCallback is blocked on resolving https://crbug.com/668014 and figuring out:
- where this helper should live. //base doesn't really want it, but it might end
up there anyway
- if it's there, what's the point of a move-only OnceCallback
- in fact, why even rvalue qualify OnceCallback::Run() at that point

Mostly, these just require someone to sit down and think about the implications.
The actual code changes will be fairly mechanical: the Mojo bindings already
allow you to use OnceCallback if you're feeling brave, in fact.

> 
>
https://codereview.chromium.org/2593503005/diff/20001/content/renderer/dom_st...
> File content/renderer/dom_storage/local_storage_cached_area.cc (right):
> 
>
https://codereview.chromium.org/2593503005/diff/20001/content/renderer/dom_st...
> content/renderer/dom_storage/local_storage_cached_area.cc:46:
> base::WrapUnique(new GetAllCallback(callback)), std::move(request));
> On 2016/12/22 at 07:21:47, dcheng wrote:
> > Nit: base::MakeUnique<GetAllCallback>(callback)
> 
> That would require making the constructor public (which I could do of course,
> but the current code seems just as valid style-wise to me).

Powered by Google App Engine
This is Rietveld 408576698