OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_DOWNLOAD_H_ | 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_DOWNLOAD_H_ |
6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_DOWNLOAD_H_ | 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_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/time.h" | 17 #include "base/time/time.h" |
18 #include "components/autofill/core/browser/autofill_type.h" | 18 #include "components/autofill/core/browser/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 PrefService; | |
22 | |
21 namespace content { | 23 namespace content { |
22 class BrowserContext; | 24 class BrowserContext; |
23 } // namespace content | 25 } // namespace content |
24 | 26 |
25 namespace net { | 27 namespace net { |
26 class URLFetcher; | 28 class URLFetcher; |
27 } // namespace net | 29 } // namespace net |
28 | 30 |
29 namespace autofill { | 31 namespace autofill { |
30 | 32 |
(...skipping 24 matching lines...) Expand all Loading... | |
55 // |request_type| - type of request that failed. | 57 // |request_type| - type of request that failed. |
56 // |http_error| - HTTP error code. | 58 // |http_error| - HTTP error code. |
57 virtual void OnServerRequestError(const std::string& form_signature, | 59 virtual void OnServerRequestError(const std::string& form_signature, |
58 AutofillRequestType request_type, | 60 AutofillRequestType request_type, |
59 int http_error) {} | 61 int http_error) {} |
60 | 62 |
61 protected: | 63 protected: |
62 virtual ~Observer() {} | 64 virtual ~Observer() {} |
63 }; | 65 }; |
64 | 66 |
67 // |context| and |pref_service| must outlive this instance. | |
65 // |observer| - observer to notify on successful completion or error. | 68 // |observer| - observer to notify on successful completion or error. |
66 AutofillDownloadManager(content::BrowserContext* context, | 69 AutofillDownloadManager(content::BrowserContext* context, |
70 PrefService* pref_service, | |
67 Observer* observer); | 71 Observer* observer); |
68 virtual ~AutofillDownloadManager(); | 72 virtual ~AutofillDownloadManager(); |
69 | 73 |
70 // Starts a query request to Autofill servers. The observer is called with the | 74 // Starts a query request to Autofill servers. The observer is called with the |
71 // list of the fields of all requested forms. | 75 // list of the fields of all requested forms. |
72 // |forms| - array of forms aggregated in this request. | 76 // |forms| - array of forms aggregated in this request. |
73 bool StartQueryRequest(const std::vector<FormStructure*>& forms, | 77 bool StartQueryRequest(const std::vector<FormStructure*>& forms, |
74 const AutofillMetrics& metric_logger); | 78 const AutofillMetrics& metric_logger); |
75 | 79 |
76 // Starts an upload request for the given |form|, unless throttled by the | 80 // Starts an upload request for the given |form|, unless throttled by the |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
129 // GetNegativeUploadRate() for non-matched. | 133 // GetNegativeUploadRate() for non-matched. |
130 double GetPositiveUploadRate() const; | 134 double GetPositiveUploadRate() const; |
131 double GetNegativeUploadRate() const; | 135 double GetNegativeUploadRate() const; |
132 void SetPositiveUploadRate(double rate); | 136 void SetPositiveUploadRate(double rate); |
133 void SetNegativeUploadRate(double rate); | 137 void SetNegativeUploadRate(double rate); |
134 | 138 |
135 // The pointer value is const, so this can only be set in the | 139 // The pointer value is const, so this can only be set in the |
136 // constructor. Must not be null. | 140 // constructor. Must not be null. |
137 content::BrowserContext* const browser_context_; // WEAK | 141 content::BrowserContext* const browser_context_; // WEAK |
138 | 142 |
143 // The pointer value is const, so this can only be set in the | |
144 // constructor. Must not be null, and must outlive this instance. | |
Ilya Sherman
2013/11/05 00:17:04
nit: No need to document what "const" means -- tha
blundell
2013/11/05 15:26:54
Done.
| |
145 PrefService* const pref_service_; // WEAK | |
146 | |
139 // The observer to notify when server predictions are successfully received. | 147 // The observer to notify when server predictions are successfully received. |
140 // The pointer value is const, so this can only be set in the constructor. | 148 // The pointer value is const, so this can only be set in the constructor. |
141 // Must not be null. | 149 // Must not be null. |
142 AutofillDownloadManager::Observer* const observer_; // WEAK | 150 AutofillDownloadManager::Observer* const observer_; // WEAK |
143 | 151 |
144 // For each requested form for both query and upload we create a separate | 152 // For each requested form for both query and upload we create a separate |
145 // request and save its info. As url fetcher is identified by its address | 153 // request and save its info. As url fetcher is identified by its address |
146 // we use a map between fetchers and info. | 154 // we use a map between fetchers and info. |
147 std::map<net::URLFetcher*, FormRequestData> url_fetchers_; | 155 std::map<net::URLFetcher*, FormRequestData> url_fetchers_; |
148 | 156 |
(...skipping 12 matching lines...) Expand all Loading... | |
161 double positive_upload_rate_; | 169 double positive_upload_rate_; |
162 double negative_upload_rate_; | 170 double negative_upload_rate_; |
163 | 171 |
164 // Needed for unit-test. | 172 // Needed for unit-test. |
165 int fetcher_id_for_unittest_; | 173 int fetcher_id_for_unittest_; |
166 }; | 174 }; |
167 | 175 |
168 } // namespace autofill | 176 } // namespace autofill |
169 | 177 |
170 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_DOWNLOAD_H_ | 178 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_DOWNLOAD_H_ |
OLD | NEW |