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

Side by Side Diff: chrome/browser/autofill/autofill_download.h

Issue 10919066: Use BrowserContext as key in API. Switch Autofill to use BC in place of Profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to parent 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_AUTOFILL_AUTOFILL_DOWNLOAD_H_ 5 #ifndef CHROME_BROWSER_AUTOFILL_AUTOFILL_DOWNLOAD_H_
6 #define CHROME_BROWSER_AUTOFILL_AUTOFILL_DOWNLOAD_H_ 6 #define CHROME_BROWSER_AUTOFILL_AUTOFILL_DOWNLOAD_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <list> 9 #include <list>
10 #include <map> 10 #include <map>
11 #include <string> 11 #include <string>
12 #include <utility> 12 #include <utility>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
16 #include "base/gtest_prod_util.h" 16 #include "base/gtest_prod_util.h"
17 #include "base/time.h" 17 #include "base/time.h"
18 #include "chrome/browser/autofill/autofill_type.h" 18 #include "chrome/browser/autofill/autofill_type.h"
19 #include "net/url_request/url_fetcher_delegate.h" 19 #include "net/url_request/url_fetcher_delegate.h"
20 20
21 class AutofillMetrics; 21 class AutofillMetrics;
22 class FormStructure; 22 class FormStructure;
23 class Profile; 23
24 namespace content {
25 class BrowserContext;
26 } // namespace content
24 27
25 namespace net { 28 namespace net {
26 class URLFetcher; 29 class URLFetcher;
27 } // namespace net 30 } // namespace net
28 31
29 // Handles getting and updating Autofill heuristics. 32 // Handles getting and updating Autofill heuristics.
30 class AutofillDownloadManager : public net::URLFetcherDelegate { 33 class AutofillDownloadManager : public net::URLFetcherDelegate {
31 public: 34 public:
32 enum AutofillRequestType { 35 enum AutofillRequestType {
33 REQUEST_QUERY, 36 REQUEST_QUERY,
(...skipping 17 matching lines...) Expand all
51 // |http_error| - HTTP error code. 54 // |http_error| - HTTP error code.
52 virtual void OnServerRequestError(const std::string& form_signature, 55 virtual void OnServerRequestError(const std::string& form_signature,
53 AutofillRequestType request_type, 56 AutofillRequestType request_type,
54 int http_error) {} 57 int http_error) {}
55 58
56 protected: 59 protected:
57 virtual ~Observer() {} 60 virtual ~Observer() {}
58 }; 61 };
59 62
60 // |observer| - observer to notify on successful completion or error. 63 // |observer| - observer to notify on successful completion or error.
61 AutofillDownloadManager(Profile* profile, Observer* observer); 64 AutofillDownloadManager(content::BrowserContext* context,
65 Observer* observer);
62 virtual ~AutofillDownloadManager(); 66 virtual ~AutofillDownloadManager();
63 67
64 // Starts a query request to Autofill servers. The observer is called with the 68 // Starts a query request to Autofill servers. The observer is called with the
65 // list of the fields of all requested forms. 69 // list of the fields of all requested forms.
66 // |forms| - array of forms aggregated in this request. 70 // |forms| - array of forms aggregated in this request.
67 bool StartQueryRequest(const std::vector<FormStructure*>& forms, 71 bool StartQueryRequest(const std::vector<FormStructure*>& forms,
68 const AutofillMetrics& metric_logger); 72 const AutofillMetrics& metric_logger);
69 73
70 // Starts an upload request for the given |form|, unless throttled by the 74 // Starts an upload request for the given |form|, unless throttled by the
71 // server. The probability of the request going over the wire is 75 // server. The probability of the request going over the wire is
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; 121 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
118 122
119 // Probability of the form upload. Between 0 (no upload) and 1 (upload all). 123 // Probability of the form upload. Between 0 (no upload) and 1 (upload all).
120 // GetPositiveUploadRate() is for matched forms, 124 // GetPositiveUploadRate() is for matched forms,
121 // GetNegativeUploadRate() for non-matched. 125 // GetNegativeUploadRate() for non-matched.
122 double GetPositiveUploadRate() const; 126 double GetPositiveUploadRate() const;
123 double GetNegativeUploadRate() const; 127 double GetNegativeUploadRate() const;
124 void SetPositiveUploadRate(double rate); 128 void SetPositiveUploadRate(double rate);
125 void SetNegativeUploadRate(double rate); 129 void SetNegativeUploadRate(double rate);
126 130
127 // Profile for preference storage. The pointer value is const, so this can 131 // The pointer value is const, so this can only be set in the
128 // only be set in the constructor. Must not be null. 132 // constructor. Must not be null.
129 Profile* const profile_; // WEAK 133 content::BrowserContext* const browser_context_; // WEAK
134
130 // The observer to notify when server predictions are successfully received. 135 // The observer to notify when server predictions are successfully received.
131 // The pointer value is const, so this can only be set in the constructor. 136 // The pointer value is const, so this can only be set in the constructor.
132 // Must not be null. 137 // Must not be null.
133 AutofillDownloadManager::Observer* const observer_; // WEAK 138 AutofillDownloadManager::Observer* const observer_; // WEAK
134 139
135 // For each requested form for both query and upload we create a separate 140 // For each requested form for both query and upload we create a separate
136 // request and save its info. As url fetcher is identified by its address 141 // request and save its info. As url fetcher is identified by its address
137 // we use a map between fetchers and info. 142 // we use a map between fetchers and info.
138 std::map<net::URLFetcher*, FormRequestData> url_fetchers_; 143 std::map<net::URLFetcher*, FormRequestData> url_fetchers_;
139 144
(...skipping 10 matching lines...) Expand all
150 // |positive_upload_rate_| is for matched forms, 155 // |positive_upload_rate_| is for matched forms,
151 // |negative_upload_rate_| for non matched. 156 // |negative_upload_rate_| for non matched.
152 double positive_upload_rate_; 157 double positive_upload_rate_;
153 double negative_upload_rate_; 158 double negative_upload_rate_;
154 159
155 // Needed for unit-test. 160 // Needed for unit-test.
156 int fetcher_id_for_unittest_; 161 int fetcher_id_for_unittest_;
157 }; 162 };
158 163
159 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_DOWNLOAD_H_ 164 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_DOWNLOAD_H_
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_common_test.cc ('k') | chrome/browser/autofill/autofill_download.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698