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

Unified Diff: chrome/browser/api/webdata/web_data_results.h

Issue 11862010: Fix WebDataRequest ownership gap (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix tsan bug Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/api/webdata/web_data_results.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 7924e3f53f0f76fc91a2690654e452dc9f458b0d..87e13c8d08987c8acc0480b76f33e07acefbbfb6 100644
--- a/chrome/browser/api/webdata/web_data_results.h
+++ b/chrome/browser/api/webdata/web_data_results.h
@@ -40,27 +40,24 @@ typedef base::Callback<void(const WDTypedResult*)> DestroyCallback;
//
class WDTypedResult {
public:
- virtual ~WDTypedResult();
+ virtual ~WDTypedResult() {
+ }
// Return the result type.
WDResultType GetType() const {
return type_;
}
- void Destroy() const {
- if (!callback_.is_null()) {
- callback_.Run(this);
- }
+ virtual void Destroy() {
}
protected:
- explicit WDTypedResult(WDResultType type);
-
- WDTypedResult(WDResultType type, const DestroyCallback& callback);
+ explicit WDTypedResult(WDResultType type)
+ : type_(type) {
+ }
private:
WDResultType type_;
- DestroyCallback callback_;
DISALLOW_COPY_AND_ASSIGN(WDTypedResult);
};
@@ -71,10 +68,6 @@ template <class T> class WDResult : public WDTypedResult {
: WDTypedResult(type), value_(v) {
}
- WDResult(WDResultType type, const DestroyCallback& callback, const T& v)
- : WDTypedResult(type, callback), value_(v) {
- }
-
virtual ~WDResult() {
}
@@ -89,16 +82,45 @@ template <class T> class WDResult : public WDTypedResult {
DISALLOW_COPY_AND_ASSIGN(WDResult);
};
+template <class T> class WDDestroyableResult : public WDTypedResult {
+ public:
+ WDDestroyableResult(
+ WDResultType type,
+ const T& v,
+ const DestroyCallback& callback)
+ : WDTypedResult(type),
+ value_(v),
+ callback_(callback) {
+ }
+
+ virtual ~WDDestroyableResult() {
+ }
+
+
+ virtual void Destroy() OVERRIDE {
+ if (!callback_.is_null()) {
+ callback_.Run(this);
+ }
+ }
+
+ // Return a single value result.
+ T GetValue() const {
+ return value_;
+ }
+
+ private:
+ T value_;
+ DestroyCallback callback_;
+
+ DISALLOW_COPY_AND_ASSIGN(WDDestroyableResult);
+};
+
template <class T> class WDObjectResult : public WDTypedResult {
public:
explicit WDObjectResult(WDResultType type)
: WDTypedResult(type) {
}
- WDObjectResult(WDResultType type, const DestroyCallback& callback)
- : WDTypedResult(type, callback) {
- }
-
T* GetValue() const {
return &value_;
}
« no previous file with comments | « no previous file | chrome/browser/api/webdata/web_data_results.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698