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

Issue 623633002: scoped_refptr: support opaque pointed-to classes via extern template (Closed)

Created:
6 years, 2 months ago by mdempsky
Modified:
6 years, 2 months ago
CC:
chromium-reviews, erikwright+watch_chromium.org, gavinp+memory_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Project:
chromium
Visibility:
Public.

Description

scoped_refptr: support opaque pointed-to classes via extern template The C++ spec says the compiler may instantiate inline template function definitions (e.g., member functions defined inline within a templated class, even without an explicit "inline" keyword) even if there's an "extern template class Foo<Bar>;" declaration. In the case of scoped_refptr, if we merely have a forward declaration for a class like "class Opaque;", then "extern template class scoped_refptr<Opaque>;" will still cause compiler errors because of scoped_refptr's inline member functions that try to call AddRef() and Release(). To solve this, this CL introduces static helper methods that are defined out-of-line to provide access to the AddRef() and Release() methods. BUG=414363 Committed: https://crrev.com/3d16d9f6566c5fc82eb23ab7b09217a59fb0957b Cr-Commit-Position: refs/heads/master@{#298991}

Patch Set 1 #

Total comments: 5

Patch Set 2 : Add test case #

Patch Set 3 : Fix header guard #

Unified diffs Side-by-side diffs Delta from patch set Stats (+99 lines, -6 lines) Patch
M base/base.gyp View 1 1 chunk +2 lines, -0 lines 0 comments Download
M base/memory/ref_counted.h View 1 2 3 chunks +24 lines, -6 lines 0 comments Download
M base/memory/ref_counted_unittest.cc View 1 2 chunks +12 lines, -0 lines 0 comments Download
M base/test/BUILD.gn View 1 1 chunk +2 lines, -0 lines 0 comments Download
A base/test/opaque_ref_counted.h View 1 2 1 chunk +24 lines, -0 lines 0 comments Download
A base/test/opaque_ref_counted.cc View 1 1 chunk +35 lines, -0 lines 0 comments Download

Messages

Total messages: 19 (3 generated)
mdempsky
6 years, 2 months ago (2014-10-02 02:53:21 UTC) #2
willchan no longer on Chromium
302=>Dana
6 years, 2 months ago (2014-10-03 00:19:24 UTC) #4
mdempsky
On 2014/10/03 00:19:24, willchan OOO until 03-22-15 wrote: > 302=>Dana danakj: PTAL. This is a ...
6 years, 2 months ago (2014-10-03 18:19:51 UTC) #5
Jeffrey Yasskin
Ick, but LGTM.
6 years, 2 months ago (2014-10-03 20:29:25 UTC) #6
danakj
https://codereview.chromium.org/623633002/diff/1/base/memory/ref_counted.h File base/memory/ref_counted.h (right): https://codereview.chromium.org/623633002/diff/1/base/memory/ref_counted.h#newcode370 base/memory/ref_counted.h:370: // Otherwise the compiler will complain that Opaque is ...
6 years, 2 months ago (2014-10-09 00:06:58 UTC) #7
mdempsky
https://codereview.chromium.org/623633002/diff/1/base/memory/ref_counted.h File base/memory/ref_counted.h (right): https://codereview.chromium.org/623633002/diff/1/base/memory/ref_counted.h#newcode370 base/memory/ref_counted.h:370: // Otherwise the compiler will complain that Opaque is ...
6 years, 2 months ago (2014-10-09 00:21:33 UTC) #8
danakj
https://codereview.chromium.org/623633002/diff/1/base/memory/ref_counted.h File base/memory/ref_counted.h (right): https://codereview.chromium.org/623633002/diff/1/base/memory/ref_counted.h#newcode370 base/memory/ref_counted.h:370: // Otherwise the compiler will complain that Opaque is ...
6 years, 2 months ago (2014-10-09 00:31:48 UTC) #9
mdempsky
https://codereview.chromium.org/623633002/diff/1/base/memory/ref_counted.h File base/memory/ref_counted.h (right): https://codereview.chromium.org/623633002/diff/1/base/memory/ref_counted.h#newcode370 base/memory/ref_counted.h:370: // Otherwise the compiler will complain that Opaque is ...
6 years, 2 months ago (2014-10-09 00:52:48 UTC) #10
danakj
OK. It'd be extern template class Opaque; though, not extern template class scoped_refptr<Opaque>;? On Oct ...
6 years, 2 months ago (2014-10-09 01:03:20 UTC) #11
mdempsky
On 2014/10/09 01:03:20, danakj wrote: > OK. It'd be extern template class Opaque; though, not ...
6 years, 2 months ago (2014-10-09 03:55:57 UTC) #12
danakj
Ah, it's the scoped_refptr<T>::AddRef that becomes non-inline, right. I was thinking it was the T::AddRef ...
6 years, 2 months ago (2014-10-09 16:56:21 UTC) #13
mdempsky
On 2014/10/09 16:56:21, danakj wrote: > This LG if it doesn't change the code we ...
6 years, 2 months ago (2014-10-09 19:46:02 UTC) #14
danakj
LGTM thanks!
6 years, 2 months ago (2014-10-09 20:10:18 UTC) #15
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/623633002/60001
6 years, 2 months ago (2014-10-09 20:16:28 UTC) #17
commit-bot: I haz the power
Committed patchset #3 (id:60001)
6 years, 2 months ago (2014-10-09 22:17:16 UTC) #18
commit-bot: I haz the power
6 years, 2 months ago (2014-10-09 22:17:55 UTC) #19
Message was sent while issue was closed.
Patchset 3 (id:??) landed as
https://crrev.com/3d16d9f6566c5fc82eb23ab7b09217a59fb0957b
Cr-Commit-Position: refs/heads/master@{#298991}

Powered by Google App Engine
This is Rietveld 408576698