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