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

Issue 2721553002: Make web_app::ShortcutInfo RefCountedThreadSafe (1) (Closed)

Created:
3 years, 9 months ago by tzik
Modified:
3 years, 9 months ago
Reviewers:
tapted, Matt Giuca
CC:
chromium-reviews, tfarina, mac-reviews_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Make web_app::ShortcutInfo RefCountedThreadSafe This is another approach of http://crrev.com/2703283005/. Either this or another is enough to fix the issue. web_app::ShortcutInfo used in cr/b/web_applications needs to be destroyed on UI thread, because it has a reference to a ImageStorage via gfx::ImageFamily. Since gfx::internal::ImageStorage has a non-thread-safe ref count, created on UI thread, and shared by others on UI thread, it needs on UI thread too on destruction. BUG=688072

Patch Set 1 #

Patch Set 2 : +#include #

Patch Set 3 : mac fix #

Patch Set 4 : another mac fix #

Patch Set 5 : win fix #

Patch Set 6 : TestBrowserThreadBundle for mac test fix #

Total comments: 3

Patch Set 7 : +comment #

Unified diffs Side-by-side diffs Delta from patch set Stats (+100 lines, -95 lines) Patch
M chrome/browser/apps/app_shim/app_shim_interactive_uitest_mac.mm View 1 2 3 2 chunks +2 lines, -2 lines 0 comments Download
M chrome/browser/ui/cocoa/create_application_shortcut_cocoa.mm View 1 2 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/ui/views/create_application_shortcut_view.h View 2 chunks +2 lines, -2 lines 0 comments Download
M chrome/browser/ui/views/create_application_shortcut_view.cc View 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/web_applications/update_shortcut_worker_win.h View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/web_applications/web_app.h View 1 2 3 4 5 6 7 chunks +25 lines, -17 lines 0 comments Download
M chrome/browser/web_applications/web_app.cc View 9 chunks +14 lines, -14 lines 0 comments Download
M chrome/browser/web_applications/web_app_chromeos.cc View 1 chunk +6 lines, -7 lines 0 comments Download
M chrome/browser/web_applications/web_app_linux.cc View 3 chunks +6 lines, -7 lines 0 comments Download
M chrome/browser/web_applications/web_app_mac.h View 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/web_applications/web_app_mac.mm View 12 chunks +23 lines, -26 lines 0 comments Download
M chrome/browser/web_applications/web_app_mac_unittest.mm View 1 2 3 4 5 3 chunks +6 lines, -3 lines 0 comments Download
M chrome/browser/web_applications/web_app_unittest.cc View 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/web_applications/web_app_win.h View 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/web_applications/web_app_win.cc View 1 2 3 4 5 7 chunks +10 lines, -11 lines 0 comments Download

Dependent Patchsets:

Messages

Total messages: 34 (26 generated)
tzik
3 years, 9 months ago (2017-02-28 07:00:38 UTC) #20
tapted
I like this one :). So lgtm. I see this approach as giving a better ...
3 years, 9 months ago (2017-02-28 23:30:06 UTC) #24
tzik
https://codereview.chromium.org/2721553002/diff/100001/chrome/browser/web_applications/web_app.h File chrome/browser/web_applications/web_app.h (right): https://codereview.chromium.org/2721553002/diff/100001/chrome/browser/web_applications/web_app.h#newcode71 chrome/browser/web_applications/web_app.h:71: // despite ImageFamily having a non-thread-safe reference count. On ...
3 years, 9 months ago (2017-03-01 05:31:34 UTC) #27
tzik
https://codereview.chromium.org/2721553002/diff/100001/chrome/browser/web_applications/web_app.h File chrome/browser/web_applications/web_app.h (right): https://codereview.chromium.org/2721553002/diff/100001/chrome/browser/web_applications/web_app.h#newcode71 chrome/browser/web_applications/web_app.h:71: // despite ImageFamily having a non-thread-safe reference count. On ...
3 years, 9 months ago (2017-03-01 05:32:30 UTC) #28
Matt Giuca
Hi, sorry I didn't get back on this earlier in the day. As I wrote ...
3 years, 9 months ago (2017-03-01 08:52:49 UTC) #31
tapted
On 2017/03/01 08:52:49, Matt Giuca wrote: > Hi, sorry I didn't get back on this ...
3 years, 9 months ago (2017-03-01 10:18:07 UTC) #32
tapted
On 2017/03/01 10:18:07, tapted wrote: > On 2017/03/01 08:52:49, Matt Giuca wrote: > > If ...
3 years, 9 months ago (2017-03-01 10:35:35 UTC) #33
Matt Giuca
3 years, 9 months ago (2017-03-01 23:40:54 UTC) #34
On 2017/03/01 10:18:07, tapted wrote:
> On 2017/03/01 08:52:49, Matt Giuca wrote:
> > Hi, sorry I didn't get back on this earlier in the day.
> > 
> > As I wrote on https://codereview.chromium.org/2703283005/, I think the
> > single-ownership model is much neater. Not sure what Trent means about
"giving
> a
> > better guarantee
> > that the same mistake isn't simply made again in future"
> >  -- that CL sets up an
> > architecture where it's always deleted on the UI thread.
> 
> Architecting a set of functions that happen to do a thing isn't the same as
> having
> a type that enforces that that thing must be done when using that type.
> 
> It's unfortunate that we don't have a non-refcounted wrapper that enforces the
> same thing as content::BrowserThread::DeleteOnUIThread. refcounts are a
> tradeoff, but
> not a significant one IMO this isn't high-performance code.
> Also base::BindStateBase is refcounted. Every call to
> base::Bind is effectively adding a refcount around a ShortcutInfo anyway.
> 
> Without DeleteOnUIThread it's still easy to accidentally pass a ShortcutInfo
to
> another thread and have it deleted there. Remembering that you need to
architect
> your functions in a particular way is an unnecessary burden.
> 
> > If you wanted to, you
> > could also add a thread checker to the ShortcutInfo destructor.
> 
> That won't help. The risk is that it *might* get deleted on the wrong thread
> subject to some unpredictable data races that may or may not happen.
> 
> > 
> > Whereas this one just papers over the ownership by having it managed at
> runtime
> > -- very hard to reason about.
> 
> I am an ObjC developer so maybe I have been desensitised to refcounting :p

Heh maybe. The objection to refcounting is not performance. It's that every time
I see refcounted code (i.e., gfx::Image, cough cough), I have no idea under what
conditions (if any) it will be deleted, or on what thread. RefCountedThreadSafe
means we don't really have to reason about what thread something gets deleted
on, but that just means we know less about what's going on. (I tried making
gfx::Image RefCountedThreadSafe and rsesek said "no, instead make sure they are
treated thread-safely".) C++ gives us the tools to reason about ownership and
refcounting and we should use them where possible.

Powered by Google App Engine
This is Rietveld 408576698