summaryrefslogtreecommitdiffstats
path: root/components/webdata/common/web_data_results.h
diff options
context:
space:
mode:
authorcaitkp@chromium.org <caitkp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-03 21:24:08 +0000
committercaitkp@chromium.org <caitkp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-03 21:24:08 +0000
commit06d5484194e4c725e0a4cfe81f60afe48e1297f3 (patch)
tree76be643d7a47b2b8da4c080e9973b18d538dab81 /components/webdata/common/web_data_results.h
parent5a5f3c86ecd6421d48f0c9cafd820d170feedd6c (diff)
downloadchromium_src-06d5484194e4c725e0a4cfe81f60afe48e1297f3.zip
chromium_src-06d5484194e4c725e0a4cfe81f60afe48e1297f3.tar.gz
chromium_src-06d5484194e4c725e0a4cfe81f60afe48e1297f3.tar.bz2
Move c/b/webdata/code which does not depend on chrome/ to components/webdata/
Specifically: Moving to components/webdata/autofill: c/b/api/webdata/autofill_web_data.h c/b/webdata/autofill_change.(cc|h) c/b/webdata/autofill_entry.(cc|h) c/b/webdata/autofill_table.(cc|h) c/b/webdata/autofill_web_data_service.(cc|h) moving to components/webdata/common: c/b/api/webdata/web_data_service_base c/b/api/webdata/web_data_service_consumer c/b/api/webdata/web_data_results c/b/webdata/web_data_request_manager c/b/webdata/web_data_service_base c/b/webdata/web_data_service_test_util c/b/webdata/web_database c/b/webdata/web_database_service c/b/webdata/web_database_table c/b/webdata/webdata_constants No change in how Webdata is built (it is still part of chrome_browser). All source files were moved using //tools/git/move_source_file.py, which updates includes of moved files, sorts include order, and updates header guards. The only manual bits of this change were: - Update .gypi files - Update DEPS files TBR=ben@chromium.org TEST=compiles! BUG=181277 Review URL: https://chromiumcodereview.appspot.com/13392014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@192161 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components/webdata/common/web_data_results.h')
-rw-r--r--components/webdata/common/web_data_results.h134
1 files changed, 134 insertions, 0 deletions
diff --git a/components/webdata/common/web_data_results.h b/components/webdata/common/web_data_results.h
new file mode 100644
index 0000000..9b27a3e
--- /dev/null
+++ b/components/webdata/common/web_data_results.h
@@ -0,0 +1,134 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_WEBDATA_COMMON_WEB_DATA_RESULTS_H_
+#define COMPONENTS_WEBDATA_COMMON_WEB_DATA_RESULTS_H_
+
+#include "base/basictypes.h"
+#include "base/callback.h"
+
+class WDTypedResult;
+
+//
+// Result types for WebDataService.
+//
+typedef enum {
+ BOOL_RESULT = 1, // WDResult<bool>
+ KEYWORDS_RESULT, // WDResult<WDKeywordsResult>
+ INT64_RESULT, // WDResult<int64>
+#if defined(OS_WIN)
+ PASSWORD_IE7_RESULT, // WDResult<IE7PasswordInfo>
+#endif
+ WEB_APP_IMAGES, // WDResult<WDAppImagesResult>
+ TOKEN_RESULT, // WDResult<std::vector<std::string>>
+ AUTOFILL_VALUE_RESULT, // WDResult<std::vector<string16>>
+ AUTOFILL_CHANGES, // WDResult<std::vector<AutofillChange>>
+ AUTOFILL_PROFILE_RESULT, // WDResult<AutofillProfile>
+ AUTOFILL_PROFILES_RESULT, // WDResult<std::vector<AutofillProfile*>>
+ AUTOFILL_CREDITCARD_RESULT, // WDResult<CreditCard>
+ AUTOFILL_CREDITCARDS_RESULT, // WDResult<std::vector<CreditCard*>>
+ WEB_INTENTS_RESULT, // WDResult<std::vector<WebIntentServiceData>>
+ WEB_INTENTS_DEFAULTS_RESULT, // WDResult<std::vector<DefaultWebIntentService>>
+} WDResultType;
+
+
+typedef base::Callback<void(const WDTypedResult*)> DestroyCallback;
+
+//
+// The top level class for a result.
+//
+class WDTypedResult {
+ public:
+ virtual ~WDTypedResult() {
+ }
+
+ // Return the result type.
+ WDResultType GetType() const {
+ return type_;
+ }
+
+ virtual void Destroy() {
+ }
+
+ protected:
+ explicit WDTypedResult(WDResultType type)
+ : type_(type) {
+ }
+
+ private:
+ WDResultType type_;
+ DISALLOW_COPY_AND_ASSIGN(WDTypedResult);
+};
+
+// A result containing one specific pointer or literal value.
+template <class T> class WDResult : public WDTypedResult {
+ public:
+ WDResult(WDResultType type, const T& v)
+ : WDTypedResult(type), value_(v) {
+ }
+
+ virtual ~WDResult() {
+ }
+
+ // Return a single value result.
+ T GetValue() const {
+ return value_;
+ }
+
+ private:
+ T value_;
+
+ 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) {
+ }
+
+ T* GetValue() const {
+ return &value_;
+ }
+
+ private:
+ // mutable to keep GetValue() const.
+ mutable T value_;
+ DISALLOW_COPY_AND_ASSIGN(WDObjectResult);
+};
+
+#endif // COMPONENTS_WEBDATA_COMMON_WEB_DATA_RESULTS_H_