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

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

Issue 10386063: Move URLFetcherDelegate to net/ and split URLFetcher between net/ and content/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync to head, fix win component build Created 8 years, 7 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) 2011 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 #pragma once 7 #pragma once
8 8
9 #include <stddef.h> 9 #include <stddef.h>
10 #include <list> 10 #include <list>
11 #include <map> 11 #include <map>
12 #include <string> 12 #include <string>
13 #include <utility> 13 #include <utility>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/compiler_specific.h" 16 #include "base/compiler_specific.h"
17 #include "base/gtest_prod_util.h" 17 #include "base/gtest_prod_util.h"
18 #include "base/time.h" 18 #include "base/time.h"
19 #include "chrome/browser/autofill/autofill_type.h" 19 #include "chrome/browser/autofill/autofill_type.h"
20 #include "content/public/common/url_fetcher_delegate.h" 20 #include "content/public/common/url_fetcher_delegate.h"
21 21
22 class AutofillMetrics; 22 class AutofillMetrics;
23 class FormStructure; 23 class FormStructure;
24 class Profile; 24 class Profile;
25 25
26 namespace net {
27 class URLFetcher;
28 } // namespace net
29
26 // Handles getting and updating Autofill heuristics. 30 // Handles getting and updating Autofill heuristics.
27 class AutofillDownloadManager : public content::URLFetcherDelegate { 31 class AutofillDownloadManager : public content::URLFetcherDelegate {
28 public: 32 public:
29 enum AutofillRequestType { 33 enum AutofillRequestType {
30 REQUEST_QUERY, 34 REQUEST_QUERY,
31 REQUEST_UPLOAD, 35 REQUEST_UPLOAD,
32 }; 36 };
33 37
34 // An interface used to notify clients of AutofillDownloadManager. 38 // An interface used to notify clients of AutofillDownloadManager.
35 class Observer { 39 class Observer {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 const std::string& query_data); 108 const std::string& query_data);
105 // Returns true if query is in the cache, while filling |query_data|, false 109 // Returns true if query is in the cache, while filling |query_data|, false
106 // otherwise. |forms_in_query| is a vector of form signatures in the query. 110 // otherwise. |forms_in_query| is a vector of form signatures in the query.
107 bool CheckCacheForQueryRequest(const std::vector<std::string>& forms_in_query, 111 bool CheckCacheForQueryRequest(const std::vector<std::string>& forms_in_query,
108 std::string* query_data) const; 112 std::string* query_data) const;
109 // Concatenates |forms_in_query| into one signature. 113 // Concatenates |forms_in_query| into one signature.
110 std::string GetCombinedSignature( 114 std::string GetCombinedSignature(
111 const std::vector<std::string>& forms_in_query) const; 115 const std::vector<std::string>& forms_in_query) const;
112 116
113 // content::URLFetcherDelegate implementation: 117 // content::URLFetcherDelegate implementation:
114 virtual void OnURLFetchComplete(const content::URLFetcher* source) OVERRIDE; 118 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
115 119
116 // Probability of the form upload. Between 0 (no upload) and 1 (upload all). 120 // Probability of the form upload. Between 0 (no upload) and 1 (upload all).
117 // GetPositiveUploadRate() is for matched forms, 121 // GetPositiveUploadRate() is for matched forms,
118 // GetNegativeUploadRate() for non-matched. 122 // GetNegativeUploadRate() for non-matched.
119 double GetPositiveUploadRate() const; 123 double GetPositiveUploadRate() const;
120 double GetNegativeUploadRate() const; 124 double GetNegativeUploadRate() const;
121 void SetPositiveUploadRate(double rate); 125 void SetPositiveUploadRate(double rate);
122 void SetNegativeUploadRate(double rate); 126 void SetNegativeUploadRate(double rate);
123 127
124 // Profile for preference storage. The pointer value is const, so this can 128 // Profile for preference storage. The pointer value is const, so this can
125 // only be set in the constructor. Must not be null. 129 // only be set in the constructor. Must not be null.
126 Profile* const profile_; // WEAK 130 Profile* const profile_; // WEAK
127 // The observer to notify when server predictions are successfully received. 131 // The observer to notify when server predictions are successfully received.
128 // The pointer value is const, so this can only be set in the constructor. 132 // The pointer value is const, so this can only be set in the constructor.
129 // Must not be null. 133 // Must not be null.
130 AutofillDownloadManager::Observer* const observer_; // WEAK 134 AutofillDownloadManager::Observer* const observer_; // WEAK
131 135
132 // For each requested form for both query and upload we create a separate 136 // For each requested form for both query and upload we create a separate
133 // request and save its info. As url fetcher is identified by its address 137 // request and save its info. As url fetcher is identified by its address
134 // we use a map between fetchers and info. 138 // we use a map between fetchers and info.
135 std::map<content::URLFetcher*, FormRequestData> url_fetchers_; 139 std::map<net::URLFetcher*, FormRequestData> url_fetchers_;
136 140
137 // Cached QUERY requests. 141 // Cached QUERY requests.
138 QueryRequestCache cached_forms_; 142 QueryRequestCache cached_forms_;
139 size_t max_form_cache_size_; 143 size_t max_form_cache_size_;
140 144
141 // Time when next query/upload requests are allowed. If 50x HTTP received, 145 // Time when next query/upload requests are allowed. If 50x HTTP received,
142 // exponential back off is initiated, so this times will be in the future 146 // exponential back off is initiated, so this times will be in the future
143 // for awhile. 147 // for awhile.
144 base::Time next_query_request_; 148 base::Time next_query_request_;
145 base::Time next_upload_request_; 149 base::Time next_upload_request_;
146 150
147 // |positive_upload_rate_| is for matched forms, 151 // |positive_upload_rate_| is for matched forms,
148 // |negative_upload_rate_| for non matched. 152 // |negative_upload_rate_| for non matched.
149 double positive_upload_rate_; 153 double positive_upload_rate_;
150 double negative_upload_rate_; 154 double negative_upload_rate_;
151 155
152 // Needed for unit-test. 156 // Needed for unit-test.
153 int fetcher_id_for_unittest_; 157 int fetcher_id_for_unittest_;
154 }; 158 };
155 159
156 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_DOWNLOAD_H_ 160 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_DOWNLOAD_H_
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/search_provider.cc ('k') | chrome/browser/autofill/autofill_download.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698