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

Issue 1855483004: [iOS/OS X] Allow base::scoped_nsobject<> to be used when ARC is enabled. (Closed)

Created:
4 years, 8 months ago by sdefresne
Modified:
4 years, 6 months ago
CC:
cbentzel+watch_chromium.org, chromium-reviews, stkhapugin, rohitrao (ping after 24h)
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

[iOS/OS X] Allow base::scoped_nsobject<> to be used when ARC is enabled. Add annotations (http://clang-analyzer.llvm.org/annotations.html) to prevent clang from mucking with the objects reference count while generating base::scoped_nsobject<> code when Automatic Reference Counting (a.k.a. ARC) is enabled. Use static function to perform explicit reference counting without causing compilation errors when the file is included from a source file with ARC enabled. When using ARC, base::scoped_nsobject<> constructor and reset() method have a different signature that does not allow passing the policy and default to base::scoped_policy::RETAIN (this cause no visible change as ARC insert a call to release). The ns_consumed annotation is supposed to inform ARC not to insert that call, but does not work (see upstream issue https://llvm.org/bugs/show_bug.cgi?id=27887). Design document: https://docs.google.com/document/d/1dEZ-pdHP6Q32yffHtrQjeUDGAD1MuPGaGOrMfdi1ihk/edit# BUG=599992 Committed: https://crrev.com/fd625125b8a6a3aceaf09993a5f74cfe5368b17f Cr-Commit-Position: refs/heads/master@{#400132}

Patch Set 1 #

Patch Set 2 : Revert changes to build/config/compiler/BUILD.gn #

Total comments: 8

Patch Set 3 : Use ns_consumed #

Patch Set 4 : Use macro to override default policy #

Patch Set 5 : Remove explicit and undef DEFAULT_OWNERSHIP_POLICY #

Patch Set 6 : Fix compilation on iOS #

Patch Set 7 : Enable bind_objc_block_arc.mm tests #

Patch Set 8 : Fix components build #

Patch Set 9 : Remove macro and instead provide different constructor/reset implementation #

Patch Set 10 : Remove macro and instead provide different constructor/reset implementation #

Patch Set 11 : Fix unit tests && rebase #

Patch Set 12 : Add missing copy constructor from scoped_nsobject<subclass> to scoped_nsobject<class> #

Unified diffs Side-by-side diffs Delta from patch set Stats (+433 lines, -39 lines) Patch
M base/BUILD.gn View 1 2 3 4 5 6 7 8 9 10 5 chunks +25 lines, -0 lines 0 comments Download
M base/base.gyp View 1 2 3 4 5 6 7 8 9 10 2 chunks +32 lines, -0 lines 0 comments Download
M base/base.gypi View 1 2 3 4 5 6 7 8 9 10 2 chunks +2 lines, -0 lines 0 comments Download
M base/mac/bind_objc_block.h View 1 2 3 4 1 chunk +5 lines, -2 lines 0 comments Download
M base/mac/bind_objc_block_unittest.mm View 1 2 3 4 5 6 1 chunk +8 lines, -0 lines 0 comments Download
A + base/mac/bind_objc_block_unittest_arc.mm View 1 2 3 4 5 6 7 8 9 10 5 chunks +17 lines, -7 lines 0 comments Download
M base/mac/scoped_block.h View 1 2 3 4 3 chunks +15 lines, -2 lines 0 comments Download
M base/mac/scoped_nsobject.h View 1 2 3 4 5 6 7 8 9 10 11 4 chunks +150 lines, -9 lines 0 comments Download
A base/mac/scoped_nsobject.mm View 1 chunk +23 lines, -0 lines 0 comments Download
M base/mac/scoped_nsobject_unittest.mm View 1 2 3 1 chunk +8 lines, -0 lines 0 comments Download
A base/mac/scoped_nsobject_unittest_arc.mm View 1 2 3 4 5 6 7 8 9 10 1 chunk +137 lines, -0 lines 0 comments Download
M base/mac/scoped_typeref.h View 1 2 3 4 5 6 7 8 4 chunks +11 lines, -19 lines 0 comments Download

Messages

Total messages: 29 (12 generated)
sdefresne
I've only tested this on iOS, so it may break on the bots, but could ...
4 years, 8 months ago (2016-04-01 21:23:09 UTC) #2
sdefresne
+stkhapugin: FYI
4 years, 8 months ago (2016-04-04 01:57:04 UTC) #4
sdefresne
+rohitrao: FYI
4 years, 8 months ago (2016-04-04 01:57:28 UTC) #5
Nico
The code looks like it might work. I think this could benefit from a design ...
4 years, 8 months ago (2016-04-04 17:53:45 UTC) #6
Mark Mentovai
I echo Nico’s comments. https://codereview.chromium.org/1855483004/diff/20001/base/mac/scoped_block.h File base/mac/scoped_block.h (right): https://codereview.chromium.org/1855483004/diff/20001/base/mac/scoped_block.h#newcode17 base/mac/scoped_block.h:17: id ScopedBlockTraitsRetain(id block); Blocks are ...
4 years, 8 months ago (2016-04-05 00:09:15 UTC) #7
sdefresne
Mark/Nico: Could you take a look at the latest patchset that uses the workaround for ...
4 years, 6 months ago (2016-06-09 08:45:09 UTC) #10
sdefresne
Ping?
4 years, 6 months ago (2016-06-10 17:07:47 UTC) #11
Mark Mentovai
I think that this looks fine now. Nico had asked for a design doc, do ...
4 years, 6 months ago (2016-06-10 20:14:22 UTC) #12
Nico
I'm not surprisingly in favor of fixing the compiler instead. but if Mark likes this ...
4 years, 6 months ago (2016-06-10 20:18:39 UTC) #13
sdefresne
On 2016/06/10 20:14:22, Mark Mentovai wrote: > I think that this looks fine now. > ...
4 years, 6 months ago (2016-06-14 17:47:13 UTC) #15
Mark Mentovai
I am in favor of fixing the compiler too. In fact, it’s my preference. Nico, ...
4 years, 6 months ago (2016-06-14 18:17:31 UTC) #16
Nico
On 2016/06/14 18:17:31, Mark Mentovai wrote: > I am in favor of fixing the compiler ...
4 years, 6 months ago (2016-06-14 18:29:35 UTC) #17
sdefresne
On 2016/06/14 18:29:35, Nico (traveling...slow) wrote: > On 2016/06/14 18:17:31, Mark Mentovai wrote: > > ...
4 years, 6 months ago (2016-06-16 10:46:26 UTC) #21
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1855483004/260001
4 years, 6 months ago (2016-06-16 11:47:35 UTC) #24
commit-bot: I haz the power
Committed patchset #12 (id:260001)
4 years, 6 months ago (2016-06-16 11:51:25 UTC) #26
commit-bot: I haz the power
CQ bit was unchecked
4 years, 6 months ago (2016-06-16 11:51:30 UTC) #27
commit-bot: I haz the power
4 years, 6 months ago (2016-06-16 11:53:01 UTC) #29
Message was sent while issue was closed.
Patchset 12 (id:??) landed as
https://crrev.com/fd625125b8a6a3aceaf09993a5f74cfe5368b17f
Cr-Commit-Position: refs/heads/master@{#400132}

Powered by Google App Engine
This is Rietveld 408576698