Reduce visibility of methods in AutofillManager and AutofillDownload.
Also remove some obsolete code and simplify some of the code's expectations.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/8351027
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107680 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/autofill/autofill_download.h b/chrome/browser/autofill/autofill_download.h
index ce5aa95..6144b90 100644
--- a/chrome/browser/autofill/autofill_download.h
+++ b/chrome/browser/autofill/autofill_download.h
@@ -37,33 +37,31 @@
};
// An interface used to notify clients of AutofillDownloadManager.
- // Notifications are *not* guaranteed to be called.
class Observer {
public:
// Called when field type predictions are successfully received from the
- // server.
- // |response_xml| - server response.
+ // server. |response_xml| contains the server response.
virtual void OnLoadedServerPredictions(const std::string& response_xml) = 0;
+
+ // These notifications are used to help with testing.
// Called when heuristic either successfully considered for upload and
// not send or uploaded.
- virtual void OnUploadedPossibleFieldTypes() = 0;
+ virtual void OnUploadedPossibleFieldTypes() {}
// 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 OnServerRequestError(const std::string& form_signature,
AutofillRequestType request_type,
- int http_error) = 0;
+ int http_error) {}
+
protected:
virtual ~Observer() {}
};
- // |profile| can be NULL in unit-tests only.
- explicit AutofillDownloadManager(Profile* profile);
- virtual ~AutofillDownloadManager();
-
// |observer| - observer to notify on successful completion or error.
- void SetObserver(AutofillDownloadManager::Observer* observer);
+ AutofillDownloadManager(Profile* profile, Observer* observer);
+ virtual ~AutofillDownloadManager();
// Starts a query request to Autofill servers. The observer is called with the
// list of the fields of all requested forms.
@@ -82,14 +80,6 @@
bool form_was_autofilled,
const FieldTypeSet& available_field_types);
- // Cancels pending request.
- // |form_signature| - signature of the form being cancelled. Warning:
- // for query request if more than one form sent in the request, all other
- // forms will be cancelled as well.
- // |request_type| - type of the request.
- bool CancelRequest(const std::string& form_signature,
- AutofillRequestType request_type);
-
private:
friend class AutofillDownloadTest;
FRIEND_TEST_ALL_PREFIXES(AutofillDownloadTest, QueryAndUploadTest);
@@ -136,14 +126,18 @@
void SetPositiveUploadRate(double rate);
void SetNegativeUploadRate(double rate);
- // Profile for preference storage.
- Profile* profile_;
+ // Profile for preference storage. The pointer value is const, so this can
+ // only be set in the constructor. Must not be null.
+ Profile* const profile_; // WEAK
+ // The observer to notify when server predictions are successfully received.
+ // The pointer value is const, so this can only be set in the constructor.
+ // Must not be null.
+ AutofillDownloadManager::Observer* const observer_; // WEAK
// For each requested form for both query and upload we create a separate
// request and save its info. As url fetcher is identified by its address
// we use a map between fetchers and info.
std::map<content::URLFetcher*, FormRequestData> url_fetchers_;
- AutofillDownloadManager::Observer *observer_;
// Cached QUERY requests.
QueryRequestCache cached_forms_;