| 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> |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 namespace autofill { | 27 namespace autofill { |
| 28 | 28 |
| 29 class AutofillDriver; | 29 class AutofillDriver; |
| 30 class AutofillMetrics; | 30 class AutofillMetrics; |
| 31 class FormStructure; | 31 class FormStructure; |
| 32 | 32 |
| 33 // Handles getting and updating Autofill heuristics. | 33 // Handles getting and updating Autofill heuristics. |
| 34 class AutofillDownloadManager : public net::URLFetcherDelegate { | 34 class AutofillDownloadManager : public net::URLFetcherDelegate { |
| 35 public: | 35 public: |
| 36 enum AutofillRequestType { | 36 enum RequestType { REQUEST_QUERY, REQUEST_UPLOAD, }; |
| 37 REQUEST_QUERY, | |
| 38 REQUEST_UPLOAD, | |
| 39 }; | |
| 40 | 37 |
| 41 // An interface used to notify clients of AutofillDownloadManager. | 38 // An interface used to notify clients of AutofillDownloadManager. |
| 42 class Observer { | 39 class Observer { |
| 43 public: | 40 public: |
| 44 // Called when field type predictions are successfully received from the | 41 // Called when field type predictions are successfully received from the |
| 45 // server. |response_xml| contains the server response. | 42 // server. |response_xml| contains the server response. |
| 46 virtual void OnLoadedServerPredictions(const std::string& response_xml) = 0; | 43 virtual void OnLoadedServerPredictions(const std::string& response_xml) = 0; |
| 47 | 44 |
| 48 // These notifications are used to help with testing. | 45 // These notifications are used to help with testing. |
| 49 // Called when heuristic either successfully considered for upload and | 46 // Called when heuristic either successfully considered for upload and |
| 50 // not send or uploaded. | 47 // not send or uploaded. |
| 51 virtual void OnUploadedPossibleFieldTypes() {} | 48 virtual void OnUploadedPossibleFieldTypes() {} |
| 52 // Called when there was an error during the request. | 49 // Called when there was an error during the request. |
| 53 // |form_signature| - the signature of the requesting form. | 50 // |form_signature| - the signature of the requesting form. |
| 54 // |request_type| - type of request that failed. | 51 // |request_type| - type of request that failed. |
| 55 // |http_error| - HTTP error code. | 52 // |http_error| - HTTP error code. |
| 56 virtual void OnServerRequestError(const std::string& form_signature, | 53 virtual void OnServerRequestError(const std::string& form_signature, |
| 57 AutofillRequestType request_type, | 54 RequestType request_type, |
| 58 int http_error) {} | 55 int http_error) {} |
| 59 | 56 |
| 60 protected: | 57 protected: |
| 61 virtual ~Observer() {} | 58 virtual ~Observer() {} |
| 62 }; | 59 }; |
| 63 | 60 |
| 64 // |driver| and |pref_service| must outlive this instance. | 61 // |driver| and |pref_service| must outlive this instance. |
| 65 // |observer| - observer to notify on successful completion or error. | 62 // |observer| - observer to notify on successful completion or error. |
| 66 AutofillDownloadManager(AutofillDriver* driver, | 63 AutofillDownloadManager(AutofillDriver* driver, |
| 67 PrefService* pref_service, | 64 PrefService* pref_service, |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 double positive_upload_rate_; | 160 double positive_upload_rate_; |
| 164 double negative_upload_rate_; | 161 double negative_upload_rate_; |
| 165 | 162 |
| 166 // Needed for unit-test. | 163 // Needed for unit-test. |
| 167 int fetcher_id_for_unittest_; | 164 int fetcher_id_for_unittest_; |
| 168 }; | 165 }; |
| 169 | 166 |
| 170 } // namespace autofill | 167 } // namespace autofill |
| 171 | 168 |
| 172 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_DOWNLOAD_H_ | 169 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_DOWNLOAD_H_ |
| OLD | NEW |