OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 COMPONENTS_WEBDATA_COMMON_WEB_DATA_RESULTS_H_ | 5 #ifndef COMPONENTS_WEBDATA_COMMON_WEB_DATA_RESULTS_H_ |
6 #define COMPONENTS_WEBDATA_COMMON_WEB_DATA_RESULTS_H_ | 6 #define COMPONENTS_WEBDATA_COMMON_WEB_DATA_RESULTS_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "components/webdata/common/webdata_export.h" | 10 #include "components/webdata/common/webdata_export.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 DISALLOW_COPY_AND_ASSIGN(WDTypedResult); | 60 DISALLOW_COPY_AND_ASSIGN(WDTypedResult); |
61 }; | 61 }; |
62 | 62 |
63 // A result containing one specific pointer or literal value. | 63 // A result containing one specific pointer or literal value. |
64 template <class T> class WDResult : public WDTypedResult { | 64 template <class T> class WDResult : public WDTypedResult { |
65 public: | 65 public: |
66 WDResult(WDResultType type, const T& v) | 66 WDResult(WDResultType type, const T& v) |
67 : WDTypedResult(type), value_(v) { | 67 : WDTypedResult(type), value_(v) { |
68 } | 68 } |
69 | 69 |
70 virtual ~WDResult() { | 70 ~WDResult() override { |
71 } | 71 } |
72 | 72 |
73 // Return a single value result. | 73 // Return a single value result. |
74 T GetValue() const { | 74 T GetValue() const { |
75 return value_; | 75 return value_; |
76 } | 76 } |
77 | 77 |
78 private: | 78 private: |
79 T value_; | 79 T value_; |
80 | 80 |
81 DISALLOW_COPY_AND_ASSIGN(WDResult); | 81 DISALLOW_COPY_AND_ASSIGN(WDResult); |
82 }; | 82 }; |
83 | 83 |
84 template <class T> class WDDestroyableResult : public WDResult<T> { | 84 template <class T> class WDDestroyableResult : public WDResult<T> { |
85 public: | 85 public: |
86 WDDestroyableResult( | 86 WDDestroyableResult( |
87 WDResultType type, | 87 WDResultType type, |
88 const T& v, | 88 const T& v, |
89 const DestroyCallback& callback) | 89 const DestroyCallback& callback) |
90 : WDResult<T>(type, v), | 90 : WDResult<T>(type, v), |
91 callback_(callback) { | 91 callback_(callback) { |
92 } | 92 } |
93 | 93 |
94 virtual ~WDDestroyableResult() { | 94 ~WDDestroyableResult() override { |
95 } | 95 } |
96 | 96 |
97 | 97 void Destroy() override { |
98 virtual void Destroy() override { | |
99 if (!callback_.is_null()) { | 98 if (!callback_.is_null()) { |
100 callback_.Run(this); | 99 callback_.Run(this); |
101 } | 100 } |
102 } | 101 } |
103 | 102 |
104 private: | 103 private: |
105 DestroyCallback callback_; | 104 DestroyCallback callback_; |
106 | 105 |
107 DISALLOW_COPY_AND_ASSIGN(WDDestroyableResult); | 106 DISALLOW_COPY_AND_ASSIGN(WDDestroyableResult); |
108 }; | 107 }; |
109 | 108 |
110 #endif // COMPONENTS_WEBDATA_COMMON_WEB_DATA_RESULTS_H_ | 109 #endif // COMPONENTS_WEBDATA_COMMON_WEB_DATA_RESULTS_H_ |
OLD | NEW |