Index: chrome/browser/api/webdata/web_data_results.h |
diff --git a/chrome/browser/api/webdata/web_data_results.h b/chrome/browser/api/webdata/web_data_results.h |
index 6d2d5b8c34ccf62f4c335d93000aef13db952c32..6732dee5339a42fe262d3f4b160e72c49282e1fb 100644 |
--- a/chrome/browser/api/webdata/web_data_results.h |
+++ b/chrome/browser/api/webdata/web_data_results.h |
@@ -6,6 +6,9 @@ |
#define CHROME_BROWSER_API_WEBDATA_WEB_DATA_RESULTS_H_ |
#include "base/basictypes.h" |
+#include "base/callback.h" |
+ |
+class WDTypedResult; |
// |
// Result types for WebDataService. |
@@ -29,6 +32,9 @@ typedef enum { |
WEB_INTENTS_DEFAULTS_RESULT, // WDResult<std::vector<DefaultWebIntentService>> |
} WDResultType; |
+ |
+typedef base::Callback<void(const WDTypedResult*)> DestroyCallback; |
+ |
// |
// The top level class for a result. |
// |
@@ -41,20 +47,38 @@ class WDTypedResult { |
return type_; |
} |
+ void Destroy() const { |
+ if (!callback_.is_null()) { |
+ callback_.Run(this); |
+ } |
+ } |
+ |
protected: |
- explicit WDTypedResult(WDResultType type) : type_(type) { |
+ explicit WDTypedResult(WDResultType type) |
+ : type_(type), |
+ callback_(DestroyCallback()) { |
+ } |
+ |
+ WDTypedResult(WDResultType type, const DestroyCallback& callback) |
+ : type_(type), |
+ callback_(callback) { |
} |
private: |
WDResultType type_; |
+ DestroyCallback callback_; |
DISALLOW_COPY_AND_ASSIGN(WDTypedResult); |
}; |
// A result containing one specific pointer or literal value. |
template <class T> class WDResult : public WDTypedResult { |
public: |
+ explicit WDResult(WDResultType type, const T& v) |
dhollowa
2013/01/07 21:27:13
nit: omit "explicit", only needed for single-param
Cait (Slow)
2013/01/07 22:43:32
Done.
|
+ : WDTypedResult(type), value_(v) { |
+ } |
- WDResult(WDResultType type, const T& v) : WDTypedResult(type), value_(v) { |
+ WDResult(WDResultType type, const DestroyCallback& callback, const T& v) |
+ : WDTypedResult(type, callback), value_(v) { |
} |
virtual ~WDResult() { |
@@ -73,7 +97,12 @@ template <class T> class WDResult : public WDTypedResult { |
template <class T> class WDObjectResult : public WDTypedResult { |
public: |
- explicit WDObjectResult(WDResultType type) : WDTypedResult(type) { |
+ explicit WDObjectResult(WDResultType type) |
+ : WDTypedResult(type) { |
+ } |
+ |
+ WDObjectResult(WDResultType type, const DestroyCallback& callback) |
+ : WDTypedResult(type, callback) { |
} |
T* GetValue() const { |