summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorisherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-15 07:00:36 +0000
committerisherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-15 07:00:36 +0000
commit76b6d1d53ed9d8e6392b914f7759a5f80daaa9d5 (patch)
tree1858a65bdbfddba9a4a83135899d312fcaf06869 /chrome
parentdc7b094a338c6c521f918f478e993f0f74bbea0d (diff)
downloadchromium_src-76b6d1d53ed9d8e6392b914f7759a5f80daaa9d5.zip
chromium_src-76b6d1d53ed9d8e6392b914f7759a5f80daaa9d5.tar.gz
chromium_src-76b6d1d53ed9d8e6392b914f7759a5f80daaa9d5.tar.bz2
Clean up AutofillDownloadManager; don't use "heuristics" to refer to non-client predictions.
BUG=none TEST=none Review URL: http://codereview.chromium.org/7173002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@89143 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/autofill/autofill_download.cc32
-rw-r--r--chrome/browser/autofill/autofill_download.h42
-rw-r--r--chrome/browser/autofill/autofill_download_unittest.cc9
-rw-r--r--chrome/browser/autofill/autofill_manager.cc11
-rw-r--r--chrome/browser/autofill/autofill_manager.h6
-rw-r--r--chrome/browser/autofill/form_structure.cc3
6 files changed, 49 insertions, 54 deletions
diff --git a/chrome/browser/autofill/autofill_download.cc b/chrome/browser/autofill/autofill_download.cc
index 546379e5..4b66009 100644
--- a/chrome/browser/autofill/autofill_download.cc
+++ b/chrome/browser/autofill/autofill_download.cc
@@ -22,13 +22,13 @@
#include "net/http/http_response_headers.h"
#include "third_party/libjingle/source/talk/xmllite/xmlparser.h"
-#define AUTO_FILL_QUERY_SERVER_REQUEST_URL \
- "http://toolbarqueries.clients.google.com:80/tbproxy/af/query"
-#define AUTO_FILL_UPLOAD_SERVER_REQUEST_URL \
- "http://toolbarqueries.clients.google.com:80/tbproxy/af/upload"
-#define AUTO_FILL_QUERY_SERVER_NAME_START_IN_HEADER "GFE/"
-
namespace {
+const char kAutofillQueryServerRequestUrl[] =
+ "http://toolbarqueries.clients.google.com:80/tbproxy/af/query";
+const char kAutofillUploadServerRequestUrl[] =
+ "http://toolbarqueries.clients.google.com:80/tbproxy/af/upload";
+const char kAutofillQueryServerNameStartInHeader[] = "GFE/";
+
const size_t kMaxFormCacheSize = 16;
};
@@ -62,7 +62,7 @@ AutofillDownloadManager::~AutofillDownloadManager() {
}
void AutofillDownloadManager::SetObserver(
- AutofillDownloadManager::Observer *observer) {
+ AutofillDownloadManager::Observer* observer) {
if (observer) {
DCHECK(!observer_);
observer_ = observer;
@@ -93,7 +93,7 @@ bool AutofillDownloadManager::StartQueryRequest(
VLOG(1) << "AutofillDownloadManager: query request has been retrieved from"
<< "the cache";
if (observer_)
- observer_->OnLoadedAutofillHeuristics(query_data);
+ observer_->OnLoadedServerPredictions(query_data);
return true;
}
@@ -196,9 +196,9 @@ bool AutofillDownloadManager::StartRequest(
return false;
std::string request_url;
if (request_data.request_type == AutofillDownloadManager::REQUEST_QUERY)
- request_url = AUTO_FILL_QUERY_SERVER_REQUEST_URL;
+ request_url = kAutofillQueryServerRequestUrl;
else
- request_url = AUTO_FILL_UPLOAD_SERVER_REQUEST_URL;
+ request_url = kAutofillUploadServerRequestUrl;
// Id is ignored for regular chrome, in unit test id's for fake fetcher
// factory will be 0, 1, 2, ...
@@ -299,7 +299,7 @@ void AutofillDownloadManager::OnURLFetchComplete(
if (!source->response_headers()->EnumerateHeader(NULL, "server",
&server_header) ||
StartsWithASCII(server_header.c_str(),
- AUTO_FILL_QUERY_SERVER_NAME_START_IN_HEADER,
+ kAutofillQueryServerNameStartInHeader,
false) != 0)
break;
// Bad gateway was received from Autofill servers. Fall through to back
@@ -322,9 +322,9 @@ void AutofillDownloadManager::OnURLFetchComplete(
LOG(WARNING) << "AutofillDownloadManager: " << type_of_request
<< " request has failed with response " << response_code;
if (observer_) {
- observer_->OnHeuristicsRequestError(it->second.form_signatures[0],
- it->second.request_type,
- response_code);
+ observer_->OnServerRequestError(it->second.form_signatures[0],
+ it->second.request_type,
+ response_code);
}
} else {
VLOG(1) << "AutofillDownloadManager: " << type_of_request
@@ -332,7 +332,7 @@ void AutofillDownloadManager::OnURLFetchComplete(
if (it->second.request_type == AutofillDownloadManager::REQUEST_QUERY) {
CacheQueryRequest(it->second.form_signatures, data);
if (observer_)
- observer_->OnLoadedAutofillHeuristics(data);
+ observer_->OnLoadedServerPredictions(data);
} else {
double new_positive_upload_rate = 0;
double new_negative_upload_rate = 0;
@@ -346,7 +346,7 @@ void AutofillDownloadManager::OnURLFetchComplete(
}
if (observer_)
- observer_->OnUploadedAutofillHeuristics(it->second.form_signatures[0]);
+ observer_->OnUploadedPossibleFieldTypes();
}
}
delete it->first;
diff --git a/chrome/browser/autofill/autofill_download.h b/chrome/browser/autofill/autofill_download.h
index f25dc09..fdb18b5 100644
--- a/chrome/browser/autofill/autofill_download.h
+++ b/chrome/browser/autofill/autofill_download.h
@@ -13,6 +13,7 @@
#include <utility>
#include <vector>
+#include "base/gtest_prod_util.h"
#include "base/memory/scoped_vector.h"
#include "base/time.h"
#include "chrome/browser/autofill/autofill_type.h"
@@ -39,22 +40,20 @@ class AutofillDownloadManager : public URLFetcher::Delegate {
// Notifications are *not* guaranteed to be called.
class Observer {
public:
- // Called when field types are successfully received from the server.
- // |heuristic_xml| - server response.
- virtual void OnLoadedAutofillHeuristics(
- const std::string& heuristic_xml) = 0;
+ // Called when field type predictions are successfully received from the
+ // server.
+ // |response_xml| - server response.
+ virtual void OnLoadedServerPredictions(const std::string& response_xml) = 0;
// Called when heuristic either successfully considered for upload and
// not send or uploaded.
- // |form_signature| - the signature of the requesting form.
- virtual void OnUploadedAutofillHeuristics(
- const std::string& form_signature) = 0;
+ virtual void OnUploadedPossibleFieldTypes() = 0;
// Called when there was an error during the request.
// |form_signature| - the signature of the requesting form.
// |request_type| - type of request that failed.
// |http_error| - HTTP error code.
- virtual void OnHeuristicsRequestError(const std::string& form_signature,
- AutofillRequestType request_type,
- int http_error) = 0;
+ virtual void OnServerRequestError(const std::string& form_signature,
+ AutofillRequestType request_type,
+ int http_error) = 0;
protected:
virtual ~Observer() {}
};
@@ -64,7 +63,7 @@ class AutofillDownloadManager : public URLFetcher::Delegate {
virtual ~AutofillDownloadManager();
// |observer| - observer to notify on successful completion or error.
- void SetObserver(AutofillDownloadManager::Observer *observer);
+ void SetObserver(AutofillDownloadManager::Observer* observer);
// Starts a query request to Autofill servers. The observer is called with the
// list of the fields of all requested forms.
@@ -91,20 +90,9 @@ class AutofillDownloadManager : public URLFetcher::Delegate {
bool CancelRequest(const std::string& form_signature,
AutofillRequestType request_type);
- // Probability of the form upload. Between 0 (no upload) and 1 (upload all).
- // GetPositiveUploadRate() is for matched forms,
- // GetNegativeUploadRate() for non matched.
- double GetPositiveUploadRate() const;
- double GetNegativeUploadRate() const;
- // These functions called very rarely outside of the unit-tests. With current
- // percentages, they would be called once per 100 auto-fillable forms filled
- // and submitted by user. The order of magnitude would remain similar in the
- // future.
- void SetPositiveUploadRate(double rate);
- void SetNegativeUploadRate(double rate);
-
private:
friend class AutofillDownloadTestHelper; // unit-test.
+ FRIEND_TEST_ALL_PREFIXES(AutofillDownloadTest, QueryAndUploadTest);
struct FormRequestData;
typedef std::list<std::pair<std::string, std::string> > QueryRequestCache;
@@ -145,6 +133,14 @@ class AutofillDownloadManager : public URLFetcher::Delegate {
const net::ResponseCookies& cookies,
const std::string& data);
+ // Probability of the form upload. Between 0 (no upload) and 1 (upload all).
+ // GetPositiveUploadRate() is for matched forms,
+ // GetNegativeUploadRate() for non-matched.
+ double GetPositiveUploadRate() const;
+ double GetNegativeUploadRate() const;
+ void SetPositiveUploadRate(double rate);
+ void SetNegativeUploadRate(double rate);
+
// Profile for preference storage.
Profile* profile_;
diff --git a/chrome/browser/autofill/autofill_download_unittest.cc b/chrome/browser/autofill/autofill_download_unittest.cc
index c616249..f62383f0 100644
--- a/chrome/browser/autofill/autofill_download_unittest.cc
+++ b/chrome/browser/autofill/autofill_download_unittest.cc
@@ -68,19 +68,18 @@ class AutofillDownloadTestHelper : public AutofillDownloadManager::Observer {
}
// AutofillDownloadManager::Observer overridables:
- virtual void OnLoadedAutofillHeuristics(
- const std::string& heuristic_xml) {
+ virtual void OnLoadedServerPredictions(const std::string& response_xml) {
ResponseData response;
- response.response = heuristic_xml;
+ response.response = response_xml;
response.type_of_response = QUERY_SUCCESSFULL;
responses_.push_back(response);
};
- virtual void OnUploadedAutofillHeuristics(const std::string& form_signature) {
+ virtual void OnUploadedPossibleFieldTypes() {
ResponseData response;
response.type_of_response = UPLOAD_SUCCESSFULL;
responses_.push_back(response);
}
- virtual void OnHeuristicsRequestError(
+ virtual void OnServerRequestError(
const std::string& form_signature,
AutofillDownloadManager::AutofillRequestType request_type,
int http_error) {
diff --git a/chrome/browser/autofill/autofill_manager.cc b/chrome/browser/autofill/autofill_manager.cc
index 2c0d965..82620bc 100644
--- a/chrome/browser/autofill/autofill_manager.cc
+++ b/chrome/browser/autofill/autofill_manager.cc
@@ -624,18 +624,17 @@ void AutofillManager::OnDidShowAutofillSuggestions() {
NotificationService::NoDetails());
}
-void AutofillManager::OnLoadedAutofillHeuristics(
- const std::string& heuristic_xml) {
- FormStructure::ParseQueryResponse(heuristic_xml,
+void AutofillManager::OnLoadedServerPredictions(
+ const std::string& response_xml) {
+ FormStructure::ParseQueryResponse(response_xml,
form_structures_.get(),
*metric_logger_);
}
-void AutofillManager::OnUploadedAutofillHeuristics(
- const std::string& form_signature) {
+void AutofillManager::OnUploadedPossibleFieldTypes() {
}
-void AutofillManager::OnHeuristicsRequestError(
+void AutofillManager::OnServerRequestError(
const std::string& form_signature,
AutofillDownloadManager::AutofillRequestType request_type,
int http_error) {
diff --git a/chrome/browser/autofill/autofill_manager.h b/chrome/browser/autofill/autofill_manager.h
index 0e45519..34eae0b 100644
--- a/chrome/browser/autofill/autofill_manager.h
+++ b/chrome/browser/autofill/autofill_manager.h
@@ -63,9 +63,9 @@ class AutofillManager : public TabContentsObserver,
virtual bool OnMessageReceived(const IPC::Message& message);
// AutofillDownloadManager::Observer implementation:
- virtual void OnLoadedAutofillHeuristics(const std::string& heuristic_xml);
- virtual void OnUploadedAutofillHeuristics(const std::string& form_signature);
- virtual void OnHeuristicsRequestError(
+ virtual void OnLoadedServerPredictions(const std::string& response_xml);
+ virtual void OnUploadedPossibleFieldTypes();
+ virtual void OnServerRequestError(
const std::string& form_signature,
AutofillDownloadManager::AutofillRequestType request_type,
int http_error);
diff --git a/chrome/browser/autofill/form_structure.cc b/chrome/browser/autofill/form_structure.cc
index 9d15c12..8a804a5 100644
--- a/chrome/browser/autofill/form_structure.cc
+++ b/chrome/browser/autofill/form_structure.cc
@@ -185,7 +185,8 @@ bool FormStructure::EncodeUploadRequest(
}
// static
-bool FormStructure::EncodeQueryRequest(const ScopedVector<FormStructure>& forms,
+bool FormStructure::EncodeQueryRequest(
+ const ScopedVector<FormStructure>& forms,
std::vector<std::string>* encoded_signatures,
std::string* encoded_xml) {
DCHECK(encoded_signatures);