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 | 11 |
11 class WDTypedResult; | 12 class WDTypedResult; |
12 | 13 |
13 // | 14 // |
14 // Result types for WebDataService. | 15 // Result types for WebDataService. |
15 // | 16 // |
16 typedef enum { | 17 typedef enum { |
17 BOOL_RESULT = 1, // WDResult<bool> | 18 BOOL_RESULT = 1, // WDResult<bool> |
18 KEYWORDS_RESULT, // WDResult<WDKeywordsResult> | 19 KEYWORDS_RESULT, // WDResult<WDKeywordsResult> |
19 INT64_RESULT, // WDResult<int64> | 20 INT64_RESULT, // WDResult<int64> |
(...skipping 11 matching lines...) Expand all Loading... |
31 WEB_INTENTS_RESULT, // WDResult<std::vector<WebIntentServiceData>> | 32 WEB_INTENTS_RESULT, // WDResult<std::vector<WebIntentServiceData>> |
32 WEB_INTENTS_DEFAULTS_RESULT, // WDResult<std::vector<DefaultWebIntentService>> | 33 WEB_INTENTS_DEFAULTS_RESULT, // WDResult<std::vector<DefaultWebIntentService>> |
33 } WDResultType; | 34 } WDResultType; |
34 | 35 |
35 | 36 |
36 typedef base::Callback<void(const WDTypedResult*)> DestroyCallback; | 37 typedef base::Callback<void(const WDTypedResult*)> DestroyCallback; |
37 | 38 |
38 // | 39 // |
39 // The top level class for a result. | 40 // The top level class for a result. |
40 // | 41 // |
41 class WDTypedResult { | 42 class WEBDATA_EXPORT WDTypedResult { |
42 public: | 43 public: |
43 virtual ~WDTypedResult() { | 44 virtual ~WDTypedResult() { |
44 } | 45 } |
45 | 46 |
46 // Return the result type. | 47 // Return the result type. |
47 WDResultType GetType() const { | 48 WDResultType GetType() const { |
48 return type_; | 49 return type_; |
49 } | 50 } |
50 | 51 |
51 virtual void Destroy() { | 52 virtual void Destroy() { |
(...skipping 23 matching lines...) Expand all Loading... |
75 T GetValue() const { | 76 T GetValue() const { |
76 return value_; | 77 return value_; |
77 } | 78 } |
78 | 79 |
79 private: | 80 private: |
80 T value_; | 81 T value_; |
81 | 82 |
82 DISALLOW_COPY_AND_ASSIGN(WDResult); | 83 DISALLOW_COPY_AND_ASSIGN(WDResult); |
83 }; | 84 }; |
84 | 85 |
85 template <class T> class WDDestroyableResult : public WDTypedResult { | 86 template <class T> class WDDestroyableResult |
| 87 : public WDTypedResult { |
86 public: | 88 public: |
87 WDDestroyableResult( | 89 WDDestroyableResult( |
88 WDResultType type, | 90 WDResultType type, |
89 const T& v, | 91 const T& v, |
90 const DestroyCallback& callback) | 92 const DestroyCallback& callback) |
91 : WDTypedResult(type), | 93 : WDTypedResult(type), |
92 value_(v), | 94 value_(v), |
93 callback_(callback) { | 95 callback_(callback) { |
94 } | 96 } |
95 | 97 |
(...skipping 29 matching lines...) Expand all Loading... |
125 return &value_; | 127 return &value_; |
126 } | 128 } |
127 | 129 |
128 private: | 130 private: |
129 // mutable to keep GetValue() const. | 131 // mutable to keep GetValue() const. |
130 mutable T value_; | 132 mutable T value_; |
131 DISALLOW_COPY_AND_ASSIGN(WDObjectResult); | 133 DISALLOW_COPY_AND_ASSIGN(WDObjectResult); |
132 }; | 134 }; |
133 | 135 |
134 #endif // COMPONENTS_WEBDATA_COMMON_WEB_DATA_RESULTS_H_ | 136 #endif // COMPONENTS_WEBDATA_COMMON_WEB_DATA_RESULTS_H_ |
OLD | NEW |