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

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

Issue 6366014: Fix for: Autofill should not ping the server again for the same form... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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) 2011 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 <list>
9 #include <map> 10 #include <map>
10 #include <string> 11 #include <string>
12 #include <vector>
11 13
12 #include "base/scoped_vector.h" 14 #include "base/scoped_vector.h"
13 #include "base/time.h" 15 #include "base/time.h"
14 #include "chrome/browser/autofill/autofill_profile.h" 16 #include "chrome/browser/autofill/autofill_profile.h"
15 #include "chrome/browser/autofill/field_types.h" 17 #include "chrome/browser/autofill/field_types.h"
16 #include "chrome/browser/autofill/form_structure.h" 18 #include "chrome/browser/autofill/form_structure.h"
17 #include "chrome/common/net/url_fetcher.h" 19 #include "chrome/common/net/url_fetcher.h"
18 20
19 class AutoFillMetrics; 21 class AutoFillMetrics;
20 class Profile; 22 class Profile;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 101
100 // Initiates request to AutoFill servers to download/upload heuristics. 102 // Initiates request to AutoFill servers to download/upload heuristics.
101 // |form_xml| - form structure XML to upload/download. 103 // |form_xml| - form structure XML to upload/download.
102 // |request_data| - form signature hash(es) and indicator if it was a query. 104 // |request_data| - form signature hash(es) and indicator if it was a query.
103 // |request_data.query| - if true the data is queried and observer notified 105 // |request_data.query| - if true the data is queried and observer notified
104 // with new data, if available. If false heuristic data is uploaded to our 106 // with new data, if available. If false heuristic data is uploaded to our
105 // servers. 107 // servers.
106 bool StartRequest(const std::string& form_xml, 108 bool StartRequest(const std::string& form_xml,
107 const FormRequestData& request_data); 109 const FormRequestData& request_data);
108 110
111 // Each request is page visited. We store last |number_of_forms_to_cache|
112 // request, to avoid going over the wire. Set to 16 in constructor. Warning:
113 // the search is linear (newest first), so do not make the constant very big.
114 void set_number_of_forms_to_cache(size_t number_of_forms_to_cache) {
115 number_of_forms_to_cache_ = number_of_forms_to_cache;
116 }
117
118 // Caches query request. |forms_in_query| is a vector of form signatures in
119 // the query. |query_data| is the successfull data returned over the wire.
120 void CacheQueryRequest(std::vector<std::string> const& forms_in_query,
dhollowa 2011/01/25 23:33:02 |const| in front of argument type please. And els
GeorgeY 2011/01/25 23:51:30 Done.
121 std::string const& query_data);
122 // Returns true if query is in the cache, while filling |query_data|, false
123 // otherwise. |forms_in_query| is a vector of form signatures in the query.
124 bool CheckCacheForQueryRequest(std::vector<std::string> const& forms_in_query,
125 std::string* query_data) const;
126 // Concatenates |forms_in_query| into one signature.
127 std::string GetCombinedSignature(
128 std::vector<std::string> const& forms_in_query) const;
129
109 // URLFetcher::Delegate implementation: 130 // URLFetcher::Delegate implementation:
110 virtual void OnURLFetchComplete(const URLFetcher* source, 131 virtual void OnURLFetchComplete(const URLFetcher* source,
111 const GURL& url, 132 const GURL& url,
112 const net::URLRequestStatus& status, 133 const net::URLRequestStatus& status,
113 int response_code, 134 int response_code,
114 const ResponseCookies& cookies, 135 const ResponseCookies& cookies,
115 const std::string& data); 136 const std::string& data);
116 137
117 // Profile for preference storage. 138 // Profile for preference storage.
118 Profile* profile_; 139 Profile* profile_;
119 140
120 // For each requested form for both query and upload we create a separate 141 // For each requested form for both query and upload we create a separate
121 // request and save its info. As url fetcher is identified by its address 142 // request and save its info. As url fetcher is identified by its address
122 // we use a map between fetchers and info. 143 // we use a map between fetchers and info.
123 std::map<URLFetcher*, FormRequestData> url_fetchers_; 144 std::map<URLFetcher*, FormRequestData> url_fetchers_;
124 AutoFillDownloadManager::Observer *observer_; 145 AutoFillDownloadManager::Observer *observer_;
125 146
147 // Cached QUERY requests.
148 std::list<std::pair<std::string, std::string> > cached_forms_;
dhollowa 2011/01/25 23:33:02 Add a typedef for the cache type. It'll make iter
GeorgeY 2011/01/25 23:51:30 Sure, but as this used only in these two functions
149 size_t number_of_forms_to_cache_;
dhollowa 2011/01/25 23:33:02 This seems a bit verbose. How about |form_cache_s
GeorgeY 2011/01/25 23:51:30 Done.
150
126 // Time when next query/upload requests are allowed. If 50x HTTP received, 151 // Time when next query/upload requests are allowed. If 50x HTTP received,
127 // exponential back off is initiated, so this times will be in the future 152 // exponential back off is initiated, so this times will be in the future
128 // for awhile. 153 // for awhile.
129 base::Time next_query_request_; 154 base::Time next_query_request_;
130 base::Time next_upload_request_; 155 base::Time next_upload_request_;
131 156
132 // |positive_upload_rate_| is for matched forms, 157 // |positive_upload_rate_| is for matched forms,
133 // |negative_upload_rate_| for non matched. 158 // |negative_upload_rate_| for non matched.
134 double positive_upload_rate_; 159 double positive_upload_rate_;
135 double negative_upload_rate_; 160 double negative_upload_rate_;
136 161
137 // Needed for unit-test. 162 // Needed for unit-test.
138 int fetcher_id_for_unittest_; 163 int fetcher_id_for_unittest_;
139 bool is_testing_; 164 bool is_testing_;
140 }; 165 };
141 166
142 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_DOWNLOAD_H_ 167 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_DOWNLOAD_H_
143 168
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/autofill/autofill_download.cc » ('j') | chrome/browser/autofill/autofill_download.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698