Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_API_WEBDATA_WEB_DATA_RESULTS_H_ | |
| 6 #define CHROME_BROWSER_API_WEBDATA_WEB_DATA_RESULTS_H_ | |
| 7 | |
| 8 #include "base/basictypes.h" | |
| 9 | |
| 10 // | |
| 11 // Result types for WebDataService. | |
|
dhollowa
2012/09/07 16:10:40
Not for this CL, but it strikes me this should rea
| |
| 12 // | |
| 13 typedef enum { | |
| 14 BOOL_RESULT = 1, // WDResult<bool> | |
| 15 KEYWORDS_RESULT, // WDResult<WDKeywordsResult> | |
| 16 INT64_RESULT, // WDResult<int64> | |
| 17 #if defined(OS_WIN) | |
| 18 PASSWORD_IE7_RESULT, // WDResult<IE7PasswordInfo> | |
| 19 #endif | |
| 20 WEB_APP_IMAGES, // WDResult<WDAppImagesResult> | |
| 21 TOKEN_RESULT, // WDResult<std::vector<std::string>> | |
| 22 AUTOFILL_VALUE_RESULT, // WDResult<std::vector<string16>> | |
| 23 AUTOFILL_CHANGES, // WDResult<std::vector<AutofillChange>> | |
| 24 AUTOFILL_PROFILE_RESULT, // WDResult<AutofillProfile> | |
| 25 AUTOFILL_PROFILES_RESULT, // WDResult<std::vector<AutofillProfile*>> | |
| 26 AUTOFILL_CREDITCARD_RESULT, // WDResult<CreditCard> | |
| 27 AUTOFILL_CREDITCARDS_RESULT, // WDResult<std::vector<CreditCard*>> | |
| 28 WEB_INTENTS_RESULT, // WDResult<std::vector<WebIntentServiceData>> | |
| 29 WEB_INTENTS_DEFAULTS_RESULT, // WDResult<std::vector<DefaultWebIntentService>> | |
| 30 } WDResultType; | |
| 31 | |
| 32 // | |
| 33 // The top level class for a result. | |
| 34 // | |
| 35 class WDTypedResult { | |
| 36 public: | |
| 37 virtual ~WDTypedResult() {} | |
| 38 | |
| 39 // Return the result type. | |
| 40 WDResultType GetType() const { | |
| 41 return type_; | |
| 42 } | |
| 43 | |
| 44 protected: | |
| 45 explicit WDTypedResult(WDResultType type) : type_(type) { | |
| 46 } | |
| 47 | |
| 48 private: | |
| 49 WDResultType type_; | |
| 50 DISALLOW_COPY_AND_ASSIGN(WDTypedResult); | |
| 51 }; | |
| 52 | |
| 53 // A result containing one specific pointer or literal value. | |
| 54 template <class T> class WDResult : public WDTypedResult { | |
| 55 public: | |
| 56 | |
| 57 WDResult(WDResultType type, const T& v) : WDTypedResult(type), value_(v) { | |
| 58 } | |
| 59 | |
| 60 virtual ~WDResult() { | |
| 61 } | |
| 62 | |
| 63 // Return a single value result. | |
| 64 T GetValue() const { | |
| 65 return value_; | |
| 66 } | |
| 67 | |
| 68 private: | |
| 69 T value_; | |
| 70 | |
| 71 DISALLOW_COPY_AND_ASSIGN(WDResult); | |
| 72 }; | |
| 73 | |
| 74 template <class T> class WDObjectResult : public WDTypedResult { | |
| 75 public: | |
| 76 explicit WDObjectResult(WDResultType type) : WDTypedResult(type) { | |
| 77 } | |
| 78 | |
| 79 T* GetValue() const { | |
| 80 return &value_; | |
| 81 } | |
| 82 | |
| 83 private: | |
| 84 // mutable to keep GetValue() const. | |
| 85 mutable T value_; | |
| 86 DISALLOW_COPY_AND_ASSIGN(WDObjectResult); | |
| 87 }; | |
| 88 | |
| 89 #endif // CHROME_BROWSER_API_WEBDATA_WEB_DATA_RESULTS_H_ | |
| OLD | NEW |