--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
If we have base::Optional<T> on both sides of the content / Blink boundary, does that mean that we can use base::Optional<T> members in Web* classes?
Should we?
modules/ can't depend on wtf/ for types exposed to content, so that leaves us with another wrapper in platform/.
I do wonder what the benefit of all these wrappings is, if the semantics of all of them is going to be identical.
Hi blink-dev,
base::Optional<T> just landed in Chromium [1] and I think we should use
this opportunity to deprecate Nullable [2] and WTF::Optional [3] in
favour of the base/ type.
The dependency of base::Optional<T> are very simple:
- base/logging.h (which is already used in Blink)
- base/memory/aligned_memory.h (not directly included in Blink but
base/memory/ is heavily used)
WDYT?
On Tue, Apr 19, 2016 at 10:29 PM, Mounir Lamouri <mou...@lamouri.fr> wrote:Hi blink-dev,
base::Optional<T> just landed in Chromium [1] and I think we should use
this opportunity to deprecate Nullable [2] and WTF::Optional [3] in
favour of the base/ type.
The dependency of base::Optional<T> are very simple:
- base/logging.h (which is already used in Blink)
- base/memory/aligned_memory.h (not directly included in Blink but
base/memory/ is heavily used)
WDYT?I'm okay with replacing WTF::Optional with base::Optional, but core/ and modules/ can't directly use base/ according to our current policy. So you'll need to add a small shim in WTF.
Late followup, because I just now got to try it:
I tried submitting a CL that had public/platform/WebMediaStreamTrack.h depend on base/optional.hI got an error saying "Illegal include.... because of -base from third_party's include rules".So *something* is forbidding the include. I'm not sure what.
On Thu, May 19, 2016 at 5:28 AM, 'Harald Alvestrand' via blink-dev <blin...@chromium.org> wrote:Late followup, because I just now got to try it:
I tried submitting a CL that had public/platform/WebMediaStreamTrack.h depend on base/optional.hI got an error saying "Illegal include.... because of -base from third_party's include rules".So *something* is forbidding the include. I'm not sure what.You can use wtf/Optional which is a type alias to the base one with some oilpan checks, or add base/optional.h to the platform/DEPS.
On Thu, May 19, 2016 at 4:11 PM, Dana Jansens <dan...@chromium.org> wrote:On Thu, May 19, 2016 at 5:28 AM, 'Harald Alvestrand' via blink-dev <blin...@chromium.org> wrote:Late followup, because I just now got to try it:
I tried submitting a CL that had public/platform/WebMediaStreamTrack.h depend on base/optional.hI got an error saying "Illegal include.... because of -base from third_party's include rules".So *something* is forbidding the include. I'm not sure what.You can use wtf/Optional which is a type alias to the base one with some oilpan checks, or add base/optional.h to the platform/DEPS.Do we allow wtf in public/platform/ now?
On Thu, May 19, 2016 at 2:02 PM, Jeremy Roman <jbr...@chromium.org> wrote:On Thu, May 19, 2016 at 4:11 PM, Dana Jansens <dan...@chromium.org> wrote:On Thu, May 19, 2016 at 5:28 AM, 'Harald Alvestrand' via blink-dev <blin...@chromium.org> wrote:Late followup, because I just now got to try it:
I tried submitting a CL that had public/platform/WebMediaStreamTrack.h depend on base/optional.hI got an error saying "Illegal include.... because of -base from third_party's include rules".So *something* is forbidding the include. I'm not sure what.You can use wtf/Optional which is a type alias to the base one with some oilpan checks, or add base/optional.h to the platform/DEPS.Do we allow wtf in public/platform/ now?I guess it depends if the code in question is in an INSIDE_BLINK block or not for that directory. There's 2 roads forward anyhow, one of them should be appropriate for any given place in the codebase.
Boolean + variable:<type> m_x;bool m_has_x : 1;void setX(<type> x) {m_has_x = true;m_x = true;}<type> getX() {return m_x;}void clearX() {m_has_x = false;}Optional:base::Optional<type> x;That's 12 lines of code as opposed to 1 line.In addition:- No chance of the coder getting fancy with getter and setter names - it's always x=base::Optional<type>(value) and value=*x.- Full set of operations by default (generated classes seem to omit the clearer)- No chance of coder getting fancy with side effects on the getter and setter (if they want that, they shouldn't be using optional).- Well known (by now) idiom for the operations, used by other parts of the codebase.Yes, packing of optional (when implemented as bool + variable) is pretty bad. If there is a solution to that, and it can be written into optional, it will catch all usages, not just the ones we code packing for (one of the standard arguments for using standard constructs rather than inventing our own).
Could/should we mitigate misuse of base::Optional<> with types like pointers, which already have a sensible "not set" value by providing template specializations for them that prevent them compiling?
If we can do better than the stl with storage optimizations or better asserts than we don't need to replace base::Optional with std one. This isn't any different from wtf, base threading, atomics, time, etc. If we can do better than the stl, then we should.