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

Issue 189613002: Add ScopedGeneric. (Closed)

Created:
6 years, 9 months ago by brettw
Modified:
6 years, 9 months ago
Reviewers:
ajwong, viettrungluu, awong
CC:
chromium-reviews, erikwright+watch_chromium.org
Visibility:
Public.

Description

Add ScopedGeneric. This is intended to be used in a typedef for declaring various types of scoped resources, like ScopedFD or ScopedGDIObject. It attempts to be like scoped_ptr but without pointer semantics. Currently the scoped objects are either custom one-offs that don't support move semantics and have subtly varying behavior, or they use a pointer like ScopedFD which is a memory stomp waiting to happen (since you must keep the int* alive longer than the scoper so it can be dereferenced and closed). R=ajwong@chromium.org, viettrungluu@chromium.org, ajwong Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=256596

Patch Set 1 #

Patch Set 2 : #

Patch Set 3 : header guard #

Patch Set 4 : removed bool #

Total comments: 5

Patch Set 5 : Trung's comments addressed #

Total comments: 3

Patch Set 6 : merge #

Patch Set 7 : rename #

Total comments: 1

Patch Set 8 : #

Patch Set 9 : #

Unified diffs Side-by-side diffs Delta from patch set Stats (+330 lines, -0 lines) Patch
M base/BUILD.gn View 1 2 3 4 5 6 1 chunk +1 line, -0 lines 0 comments Download
M base/base.gyp View 1 2 3 4 5 6 1 chunk +1 line, -0 lines 0 comments Download
M base/base.gypi View 1 2 3 4 5 6 1 chunk +1 line, -0 lines 0 comments Download
A base/scoped_generic.h View 1 2 3 4 5 6 7 8 1 chunk +174 lines, -0 lines 0 comments Download
A base/scoped_generic_unittest.cc View 1 2 3 4 5 6 1 chunk +153 lines, -0 lines 0 comments Download

Messages

Total messages: 20 (0 generated)
brettw
6 years, 9 months ago (2014-03-07 00:24:32 UTC) #1
brettw
Minor variations to consider: - Moving T to traits rather than having two template args. ...
6 years, 9 months ago (2014-03-07 00:56:55 UTC) #2
brettw
See https://codereview.chromium.org/191673003/ for an example of using it.
6 years, 9 months ago (2014-03-08 00:54:17 UTC) #3
brettw
I'm now leaning toward making it look more like: template<typename T, T null_value, typename Deleter> ...
6 years, 9 months ago (2014-03-08 00:56:54 UTC) #4
ajwong
I think I'm going to need some more baby-step walk through to understand why the ...
6 years, 9 months ago (2014-03-08 02:28:20 UTC) #5
viettrungluu
I wrote this elsewhere, but it deserves to be said here: https://codereview.chromium.org/191673003/diff/1/base/memory/discardable_memory_allocator_android.cc#newcode70 base/memory/discardable_memory_allocator_android.cc:70: if (!fd) ...
6 years, 9 months ago (2014-03-08 03:07:46 UTC) #6
brettw
Maybe removing the ability to say !fd is a good idea, I'll do that. There ...
6 years, 9 months ago (2014-03-08 23:05:47 UTC) #7
brettw
I removed the Testable stuff and added an is_valid() call.
6 years, 9 months ago (2014-03-10 17:18:24 UTC) #8
viettrungluu
LGTM w/nits, but wait for Albert to look at this. https://codereview.chromium.org/189613002/diff/60001/base/scoped_nullable_generic.h File base/scoped_nullable_generic.h (right): https://codereview.chromium.org/189613002/diff/60001/base/scoped_nullable_generic.h#newcode20 ...
6 years, 9 months ago (2014-03-10 17:35:55 UTC) #9
brettw
New snap up with Trung's comments addressed.
6 years, 9 months ago (2014-03-10 17:40:09 UTC) #10
awong
Overall, I have to say I'm uncomfortable with this class. It cuts/pastes a large portion ...
6 years, 9 months ago (2014-03-11 02:01:43 UTC) #11
awong
That being said, the implementation looks roughly right. On 2014/03/11 02:01:43, awong wrote: > Overall, ...
6 years, 9 months ago (2014-03-11 02:02:01 UTC) #12
brettw
https://codereview.chromium.org/189613002/diff/80001/base/scoped_nullable_generic.h File base/scoped_nullable_generic.h (right): https://codereview.chromium.org/189613002/diff/80001/base/scoped_nullable_generic.h#newcode25 base/scoped_nullable_generic.h:25: // of the scoper (which is easy to mess ...
6 years, 9 months ago (2014-03-11 05:38:06 UTC) #13
viettrungluu
On 2014/03/11 05:38:06, brettw wrote: > https://codereview.chromium.org/189613002/diff/80001/base/scoped_nullable_generic.h > File base/scoped_nullable_generic.h (right): > > https://codereview.chromium.org/189613002/diff/80001/base/scoped_nullable_generic.h#newcode25 > ...
6 years, 9 months ago (2014-03-11 16:15:41 UTC) #14
awong
On 2014/03/11 16:15:41, viettrungluu wrote: > On 2014/03/11 05:38:06, brettw wrote: > > > https://codereview.chromium.org/189613002/diff/80001/base/scoped_nullable_generic.h ...
6 years, 9 months ago (2014-03-11 19:57:01 UTC) #15
brettw
If your AlbertFile example was typical, I think your example of small wrapper classes would ...
6 years, 9 months ago (2014-03-11 22:30:39 UTC) #16
awong
LGTM/wits On 2014/03/11 22:30:39, brettw wrote: > If your AlbertFile example was typical, I think ...
6 years, 9 months ago (2014-03-11 22:59:06 UTC) #17
brettw
As per offline discussion with awong, renamed to ScopedGeneric and renamed NullValid to InvalidValue
6 years, 9 months ago (2014-03-11 23:37:29 UTC) #18
awong
still LGTM + 1 nit https://codereview.chromium.org/189613002/diff/120001/base/scoped_generic.h File base/scoped_generic.h (right): https://codereview.chromium.org/189613002/diff/120001/base/scoped_generic.h#newcode18 base/scoped_generic.h:18: // object has some ...
6 years, 9 months ago (2014-03-11 23:40:48 UTC) #19
brettw
6 years, 9 months ago (2014-03-12 19:22:20 UTC) #20
Message was sent while issue was closed.
Committed patchset #9 manually as r256596 (presubmit successful).

Powered by Google App Engine
This is Rietveld 408576698