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

Side by Side Diff: Source/bindings/core/v8/Nullable.h

Issue 365653002: Oilpan: move 2D Canvas and WebGL objects to the heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased + Nullable<traceable-value> workaround Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef Nullable_h 5 #ifndef Nullable_h
6 #define Nullable_h 6 #define Nullable_h
7 7
8 #include "platform/heap/Handle.h"
8 #include "wtf/Assertions.h" 9 #include "wtf/Assertions.h"
9 10
10 namespace WebCore { 11 namespace WebCore {
11 12
12 template <typename T> 13 template <typename T>
13 class Nullable { 14 class Nullable {
15 DISALLOW_ALLOCATION();
14 public: 16 public:
15 Nullable() 17 Nullable()
16 : m_value() 18 : m_value()
17 , m_isNull(true) { } 19 , m_isNull(true) { }
18 20
19 Nullable(const T& value) 21 Nullable(const T& value)
20 : m_value(value) 22 : m_value(value)
21 , m_isNull(false) { } 23 , m_isNull(false) { }
22 24
23 Nullable(const Nullable& other) 25 Nullable(const Nullable& other)
(...skipping 10 matching lines...) Expand all
34 T get() const { ASSERT(!m_isNull); return m_value; } 36 T get() const { ASSERT(!m_isNull); return m_value; }
35 bool isNull() const { return m_isNull; } 37 bool isNull() const { return m_isNull; }
36 38
37 operator bool() const { return !m_isNull && m_value; } 39 operator bool() const { return !m_isNull && m_value; }
38 40
39 bool operator==(const Nullable& other) const 41 bool operator==(const Nullable& other) const
40 { 42 {
41 return (m_isNull && other.m_isNull) || (!m_isNull && !other.m_isNull && m_value == other.m_value); 43 return (m_isNull && other.m_isNull) || (!m_isNull && !other.m_isNull && m_value == other.m_value);
42 } 44 }
43 45
46 void trace(Visitor*)
47 {
48 // FIXME: candidate for EnableIf<> and NeedsTracing<>, somehow ?
sof 2014/07/12 07:22:09 When rebasing past r177935's addition of Nullable<
49 (void)m_value;
50 }
51
44 private: 52 private:
45 T m_value; 53 T m_value;
46 bool m_isNull; 54 bool m_isNull;
47 }; 55 };
48 56
49 } // namespace WebCore 57 } // namespace WebCore
50 58
51 #endif // Nullable_h 59 #endif // Nullable_h
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/Dictionary.cpp ('k') | Source/bindings/core/v8/custom/V8CanvasRenderingContext2DCustom.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698