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

Side by Side Diff: chrome/browser/api/webdata/web_data_results.h

Issue 10908065: Introduce a couple of abstract bases for WebDataService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Respond to comments Created 8 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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.
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_
OLDNEW
« no previous file with comments | « chrome/browser/api/webdata/autofill_web_data_service.h ('k') | chrome/browser/api/webdata/web_data_service_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698