| OLD | NEW | 
|   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 "platform/heap/Handle.h" | 
|   9 #include "wtf/Assertions.h" |   9 #include "wtf/Assertions.h" | 
|  10  |  10  | 
| (...skipping 15 matching lines...) Expand all  Loading... | 
|  26         : m_value(other.m_value) |  26         : m_value(other.m_value) | 
|  27         , m_isNull(other.m_isNull) { } |  27         , m_isNull(other.m_isNull) { } | 
|  28  |  28  | 
|  29     Nullable& operator=(const Nullable& other) |  29     Nullable& operator=(const Nullable& other) | 
|  30     { |  30     { | 
|  31         m_value = other.m_value; |  31         m_value = other.m_value; | 
|  32         m_isNull = other.m_isNull; |  32         m_isNull = other.m_isNull; | 
|  33         return *this; |  33         return *this; | 
|  34     } |  34     } | 
|  35  |  35  | 
 |  36     void set(const T& value) | 
 |  37     { | 
 |  38         m_value = value; | 
 |  39         m_isNull = false; | 
 |  40     } | 
|  36     const T& get() const { ASSERT(!m_isNull); return m_value; } |  41     const T& get() const { ASSERT(!m_isNull); return m_value; } | 
 |  42     T& get() { ASSERT(!m_isNull); return m_value; } | 
|  37     bool isNull() const { return m_isNull; } |  43     bool isNull() const { return m_isNull; } | 
|  38  |  44  | 
|  39     operator bool() const { return !m_isNull && m_value; } |  | 
|  40  |  | 
|  41     bool operator==(const Nullable& other) const |  45     bool operator==(const Nullable& other) const | 
|  42     { |  46     { | 
|  43         return (m_isNull && other.m_isNull) || (!m_isNull && !other.m_isNull && 
    m_value == other.m_value); |  47         return (m_isNull && other.m_isNull) || (!m_isNull && !other.m_isNull && 
    m_value == other.m_value); | 
|  44     } |  48     } | 
|  45  |  49  | 
|  46     void trace(Visitor* visitor) |  50     void trace(Visitor* visitor) | 
|  47     { |  51     { | 
|  48         TraceIfNeeded<T>::trace(visitor, &m_value); |  52         TraceIfNeeded<T>::trace(visitor, &m_value); | 
|  49     } |  53     } | 
|  50  |  54  | 
|  51 private: |  55 private: | 
|  52     T m_value; |  56     T m_value; | 
|  53     bool m_isNull; |  57     bool m_isNull; | 
|  54 }; |  58 }; | 
|  55  |  59  | 
|  56 } // namespace blink |  60 } // namespace blink | 
|  57  |  61  | 
|  58 #endif // Nullable_h |  62 #endif // Nullable_h | 
| OLD | NEW |