summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autofill/autofill_download.h
diff options
context:
space:
mode:
authorgeorgey@chromium.org <georgey@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-26 01:37:23 +0000
committergeorgey@chromium.org <georgey@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-26 01:37:23 +0000
commitfc8893b93c962a89b1d3ce9a8450b68b0e6e95f3 (patch)
treef3764e23d57726380bf0d5229b6b8f795e18b393 /chrome/browser/autofill/autofill_download.h
parent0ba43cc217485a48137ecf2ce6c1ce54cdc67844 (diff)
downloadchromium_src-fc8893b93c962a89b1d3ce9a8450b68b0e6e95f3.zip
chromium_src-fc8893b93c962a89b1d3ce9a8450b68b0e6e95f3.tar.gz
chromium_src-fc8893b93c962a89b1d3ce9a8450b68b0e6e95f3.tar.bz2
Fix for: Autofill should not ping the server again for the same form
BUG=67039 TEST=unit-tested. Any network sniffer could be used to test that there no subsequent calls to the web for the same form. Review URL: http://codereview.chromium.org/6366014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72585 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autofill/autofill_download.h')
-rw-r--r--chrome/browser/autofill/autofill_download.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/chrome/browser/autofill/autofill_download.h b/chrome/browser/autofill/autofill_download.h
index 8937557..157062c 100644
--- a/chrome/browser/autofill/autofill_download.h
+++ b/chrome/browser/autofill/autofill_download.h
@@ -6,8 +6,10 @@
#define CHROME_BROWSER_AUTOFILL_AUTOFILL_DOWNLOAD_H_
#pragma once
+#include <list>
#include <map>
#include <string>
+#include <vector>
#include "base/scoped_vector.h"
#include "base/time.h"
@@ -96,6 +98,7 @@ class AutoFillDownloadManager : public URLFetcher::Delegate {
friend class AutoFillDownloadTestHelper; // unit-test.
struct FormRequestData;
+ typedef std::list<std::pair<std::string, std::string> > QueryRequestCache;
// Initiates request to AutoFill servers to download/upload heuristics.
// |form_xml| - form structure XML to upload/download.
@@ -106,6 +109,25 @@ class AutoFillDownloadManager : public URLFetcher::Delegate {
bool StartRequest(const std::string& form_xml,
const FormRequestData& request_data);
+ // Each request is page visited. We store last |max_form_cache_size|
+ // request, to avoid going over the wire. Set to 16 in constructor. Warning:
+ // the search is linear (newest first), so do not make the constant very big.
+ void set_max_form_cache_size(size_t max_form_cache_size) {
+ max_form_cache_size_ = max_form_cache_size;
+ }
+
+ // Caches query request. |forms_in_query| is a vector of form signatures in
+ // the query. |query_data| is the successful data returned over the wire.
+ void CacheQueryRequest(const std::vector<std::string>& forms_in_query,
+ const std::string& query_data);
+ // Returns true if query is in the cache, while filling |query_data|, false
+ // otherwise. |forms_in_query| is a vector of form signatures in the query.
+ bool CheckCacheForQueryRequest(const std::vector<std::string>& forms_in_query,
+ std::string* query_data) const;
+ // Concatenates |forms_in_query| into one signature.
+ std::string GetCombinedSignature(
+ const std::vector<std::string>& forms_in_query) const;
+
// URLFetcher::Delegate implementation:
virtual void OnURLFetchComplete(const URLFetcher* source,
const GURL& url,
@@ -123,6 +145,10 @@ class AutoFillDownloadManager : public URLFetcher::Delegate {
std::map<URLFetcher*, FormRequestData> url_fetchers_;
AutoFillDownloadManager::Observer *observer_;
+ // Cached QUERY requests.
+ QueryRequestCache cached_forms_;
+ size_t max_form_cache_size_;
+
// Time when next query/upload requests are allowed. If 50x HTTP received,
// exponential back off is initiated, so this times will be in the future
// for awhile.