diff options
author | isherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-21 23:08:28 +0000 |
---|---|---|
committer | isherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-21 23:08:28 +0000 |
commit | ddf907ca0b39204d32a26829ed482a0ebcba2af9 (patch) | |
tree | fecd452bf07ba5e8c6a34fa51fef964aeb9b8a94 /chrome/browser/autofill | |
parent | 2893ededb911116f029f600facca08ef60941db3 (diff) | |
download | chromium_src-ddf907ca0b39204d32a26829ed482a0ebcba2af9.zip chromium_src-ddf907ca0b39204d32a26829ed482a0ebcba2af9.tar.gz chromium_src-ddf907ca0b39204d32a26829ed482a0ebcba2af9.tar.bz2 |
Don't pass around ScopedVectors(), prefer passing std::vector instead.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/8229033
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106803 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autofill')
-rw-r--r-- | chrome/browser/autofill/autofill_download.cc | 2 | ||||
-rw-r--r-- | chrome/browser/autofill/autofill_download.h | 3 | ||||
-rw-r--r-- | chrome/browser/autofill/autofill_download_unittest.cc | 20 | ||||
-rw-r--r-- | chrome/browser/autofill/autofill_manager.cc | 6 | ||||
-rw-r--r-- | chrome/browser/autofill/autofill_manager_unittest.cc | 8 | ||||
-rw-r--r-- | chrome/browser/autofill/autofill_metrics_unittest.cc | 8 | ||||
-rw-r--r-- | chrome/browser/autofill/form_structure.cc | 2 | ||||
-rw-r--r-- | chrome/browser/autofill/form_structure.h | 6 | ||||
-rw-r--r-- | chrome/browser/autofill/form_structure_unittest.cc | 15 |
9 files changed, 36 insertions, 34 deletions
diff --git a/chrome/browser/autofill/autofill_download.cc b/chrome/browser/autofill/autofill_download.cc index 9c39339f..5423752 100644 --- a/chrome/browser/autofill/autofill_download.cc +++ b/chrome/browser/autofill/autofill_download.cc @@ -72,7 +72,7 @@ void AutofillDownloadManager::SetObserver( } bool AutofillDownloadManager::StartQueryRequest( - const ScopedVector<FormStructure>& forms, + const std::vector<FormStructure*>& forms, const AutofillMetrics& metric_logger) { if (next_query_request_ > base::Time::Now()) { // We are in back-off mode: do not do the request. diff --git a/chrome/browser/autofill/autofill_download.h b/chrome/browser/autofill/autofill_download.h index 6a52179..8d430ef 100644 --- a/chrome/browser/autofill/autofill_download.h +++ b/chrome/browser/autofill/autofill_download.h @@ -14,7 +14,6 @@ #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" #include "content/common/net/url_fetcher.h" @@ -68,7 +67,7 @@ class AutofillDownloadManager : public URLFetcher::Delegate { // Starts a query request to Autofill servers. The observer is called with the // list of the fields of all requested forms. // |forms| - array of forms aggregated in this request. - bool StartQueryRequest(const ScopedVector<FormStructure>& forms, + bool StartQueryRequest(const std::vector<FormStructure*>& forms, const AutofillMetrics& metric_logger); // Starts an upload request for the given |form|, unless throttled by the diff --git a/chrome/browser/autofill/autofill_download_unittest.cc b/chrome/browser/autofill/autofill_download_unittest.cc index 4e9724b..4c72e7d 100644 --- a/chrome/browser/autofill/autofill_download_unittest.cc +++ b/chrome/browser/autofill/autofill_download_unittest.cc @@ -216,7 +216,7 @@ TEST_F(AutofillDownloadTest, QueryAndUploadTest) { MockAutofillMetrics mock_metric_logger; EXPECT_CALL(mock_metric_logger, LogServerQueryMetric(AutofillMetrics::QUERY_SENT)).Times(1); - EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures, + EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures.get(), mock_metric_logger)); // Set upload to 100% so requests happen. download_manager_.SetPositiveUploadRate(1.0); @@ -308,7 +308,7 @@ TEST_F(AutofillDownloadTest, QueryAndUploadTest) { // Request with id 3. EXPECT_CALL(mock_metric_logger, LogServerQueryMetric(AutofillMetrics::QUERY_SENT)).Times(1); - EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures, + EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures.get(), mock_metric_logger)); fetcher = factory.GetFetcherByID(3); ASSERT_TRUE(fetcher); @@ -326,7 +326,7 @@ TEST_F(AutofillDownloadTest, QueryAndUploadTest) { // Query requests should be ignored for the next 10 seconds. EXPECT_CALL(mock_metric_logger, LogServerQueryMetric(AutofillMetrics::QUERY_SENT)).Times(0); - EXPECT_FALSE(download_manager_.StartQueryRequest(form_structures, + EXPECT_FALSE(download_manager_.StartQueryRequest(form_structures.get(), mock_metric_logger)); fetcher = factory.GetFetcherByID(4); EXPECT_EQ(NULL, fetcher); @@ -425,7 +425,7 @@ TEST_F(AutofillDownloadTest, CacheQueryTest) { MockAutofillMetrics mock_metric_logger; EXPECT_CALL(mock_metric_logger, LogServerQueryMetric(AutofillMetrics::QUERY_SENT)).Times(1); - EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures0, + EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures0.get(), mock_metric_logger)); // No responses yet EXPECT_EQ(static_cast<size_t>(0), responses_.size()); @@ -441,7 +441,7 @@ TEST_F(AutofillDownloadTest, CacheQueryTest) { // No actual request - should be a cache hit. EXPECT_CALL(mock_metric_logger, LogServerQueryMetric(AutofillMetrics::QUERY_SENT)).Times(1); - EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures0, + EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures0.get(), mock_metric_logger)); // Data is available immediately from cache - no over-the-wire trip. ASSERT_EQ(static_cast<size_t>(1), responses_.size()); @@ -451,7 +451,7 @@ TEST_F(AutofillDownloadTest, CacheQueryTest) { // Request with id 1. EXPECT_CALL(mock_metric_logger, LogServerQueryMetric(AutofillMetrics::QUERY_SENT)).Times(1); - EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures1, + EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures1.get(), mock_metric_logger)); // No responses yet EXPECT_EQ(static_cast<size_t>(0), responses_.size()); @@ -467,7 +467,7 @@ TEST_F(AutofillDownloadTest, CacheQueryTest) { // Request with id 2. EXPECT_CALL(mock_metric_logger, LogServerQueryMetric(AutofillMetrics::QUERY_SENT)).Times(1); - EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures2, + EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures2.get(), mock_metric_logger)); fetcher = factory.GetFetcherByID(2); @@ -481,12 +481,12 @@ TEST_F(AutofillDownloadTest, CacheQueryTest) { // No actual requests - should be a cache hit. EXPECT_CALL(mock_metric_logger, LogServerQueryMetric(AutofillMetrics::QUERY_SENT)).Times(1); - EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures1, + EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures1.get(), mock_metric_logger)); EXPECT_CALL(mock_metric_logger, LogServerQueryMetric(AutofillMetrics::QUERY_SENT)).Times(1); - EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures2, + EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures2.get(), mock_metric_logger)); ASSERT_EQ(static_cast<size_t>(2), responses_.size()); @@ -498,7 +498,7 @@ TEST_F(AutofillDownloadTest, CacheQueryTest) { // Request with id 3. EXPECT_CALL(mock_metric_logger, LogServerQueryMetric(AutofillMetrics::QUERY_SENT)).Times(1); - EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures0, + EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures0.get(), mock_metric_logger)); // No responses yet EXPECT_EQ(static_cast<size_t>(0), responses_.size()); diff --git a/chrome/browser/autofill/autofill_manager.cc b/chrome/browser/autofill/autofill_manager.cc index fe3d6ba..3fbbc99 100644 --- a/chrome/browser/autofill/autofill_manager.cc +++ b/chrome/browser/autofill/autofill_manager.cc @@ -1154,8 +1154,10 @@ void AutofillManager::ParseForms(const std::vector<FormData>& forms) { } // If none of the forms were parsed, no use querying the server. - if (!form_structures_.empty() && !disable_download_manager_requests_) - download_manager_.StartQueryRequest(form_structures_, *metric_logger_); + if (!form_structures_.empty() && !disable_download_manager_requests_) { + download_manager_.StartQueryRequest(form_structures_.get(), + *metric_logger_); + } for (std::vector<FormStructure*>::const_iterator iter = non_queryable_forms.begin(); diff --git a/chrome/browser/autofill/autofill_manager_unittest.cc b/chrome/browser/autofill/autofill_manager_unittest.cc index 397f188..416b36b 100644 --- a/chrome/browser/autofill/autofill_manager_unittest.cc +++ b/chrome/browser/autofill/autofill_manager_unittest.cc @@ -586,10 +586,10 @@ class TestFormStructure : public FormStructure { ASSERT_EQ(field_count(), server_types.size()); for (size_t i = 0; i < field_count(); ++i) { - AutofillField* field = (*fields())[i]; - ASSERT_TRUE(field); - field->set_heuristic_type(heuristic_types[i]); - field->set_server_type(server_types[i]); + AutofillField* form_field = field(i); + ASSERT_TRUE(form_field); + form_field->set_heuristic_type(heuristic_types[i]); + form_field->set_server_type(server_types[i]); } UpdateAutofillCount(); diff --git a/chrome/browser/autofill/autofill_metrics_unittest.cc b/chrome/browser/autofill/autofill_metrics_unittest.cc index d5b8db4..1d5fe4d 100644 --- a/chrome/browser/autofill/autofill_metrics_unittest.cc +++ b/chrome/browser/autofill/autofill_metrics_unittest.cc @@ -152,10 +152,10 @@ class TestFormStructure : public FormStructure { ASSERT_EQ(field_count(), server_types.size()); for (size_t i = 0; i < field_count(); ++i) { - AutofillField* field = (*fields())[i]; - ASSERT_TRUE(field); - field->set_heuristic_type(heuristic_types[i]); - field->set_server_type(server_types[i]); + AutofillField* form_field = field(i); + ASSERT_TRUE(form_field); + form_field->set_heuristic_type(heuristic_types[i]); + form_field->set_server_type(server_types[i]); } UpdateAutofillCount(); diff --git a/chrome/browser/autofill/form_structure.cc b/chrome/browser/autofill/form_structure.cc index d97f108..33a2768 100644 --- a/chrome/browser/autofill/form_structure.cc +++ b/chrome/browser/autofill/form_structure.cc @@ -349,7 +349,7 @@ bool FormStructure::EncodeUploadRequest( // static bool FormStructure::EncodeQueryRequest( - const ScopedVector<FormStructure>& forms, + const std::vector<FormStructure*>& forms, std::vector<std::string>* encoded_signatures, std::string* encoded_xml) { DCHECK(encoded_signatures); diff --git a/chrome/browser/autofill/form_structure.h b/chrome/browser/autofill/form_structure.h index 225a856..db38b95 100644 --- a/chrome/browser/autofill/form_structure.h +++ b/chrome/browser/autofill/form_structure.h @@ -64,7 +64,7 @@ class FormStructure { // with 2, 4, and 3 fields. The returned XML would have type info for 9 // fields, first two of which would be for the first form, next 4 for the // second, and the rest is for the third. - static bool EncodeQueryRequest(const ScopedVector<FormStructure>& forms, + static bool EncodeQueryRequest(const std::vector<FormStructure*>& forms, std::vector<std::string>* encoded_signatures, std::string* encoded_xml); @@ -142,10 +142,6 @@ class FormStructure { bool operator==(const webkit_glue::FormData& form) const; bool operator!=(const webkit_glue::FormData& form) const; - protected: - // For tests. - ScopedVector<AutofillField>* fields() { return &fields_; } - private: friend class FormStructureTest; FRIEND_TEST_ALL_PREFIXES(AutofillDownloadTest, QueryAndUploadTest); diff --git a/chrome/browser/autofill/form_structure_unittest.cc b/chrome/browser/autofill/form_structure_unittest.cc index ec9c6ce..dfb00e6 100644 --- a/chrome/browser/autofill/form_structure_unittest.cc +++ b/chrome/browser/autofill/form_structure_unittest.cc @@ -1371,7 +1371,8 @@ TEST(FormStructureTest, EncodeQueryRequest) { "<field signature=\"1917667676\"/><field signature=\"2226358947\"/>" "<field signature=\"747221617\"/><field signature=\"4108155786\"/></form>" "</autofillquery>"; - ASSERT_TRUE(FormStructure::EncodeQueryRequest(forms, &encoded_signatures, + ASSERT_TRUE(FormStructure::EncodeQueryRequest(forms.get(), + &encoded_signatures, &encoded_xml)); ASSERT_EQ(1U, encoded_signatures.size()); EXPECT_EQ(kSignature1, encoded_signatures[0]); @@ -1380,7 +1381,8 @@ TEST(FormStructureTest, EncodeQueryRequest) { // Add the same form, only one will be encoded, so EncodeQueryRequest() should // return the same data. forms.push_back(new FormStructure(form)); - ASSERT_TRUE(FormStructure::EncodeQueryRequest(forms, &encoded_signatures, + ASSERT_TRUE(FormStructure::EncodeQueryRequest(forms.get(), + &encoded_signatures, &encoded_xml)); ASSERT_EQ(1U, encoded_signatures.size()); EXPECT_EQ(kSignature1, encoded_signatures[0]); @@ -1393,7 +1395,8 @@ TEST(FormStructureTest, EncodeQueryRequest) { } forms.push_back(new FormStructure(form)); - ASSERT_TRUE(FormStructure::EncodeQueryRequest(forms, &encoded_signatures, + ASSERT_TRUE(FormStructure::EncodeQueryRequest(forms.get(), + &encoded_signatures, &encoded_xml)); ASSERT_EQ(2U, encoded_signatures.size()); EXPECT_EQ(kSignature1, encoded_signatures[0]); @@ -1422,7 +1425,8 @@ TEST(FormStructureTest, EncodeQueryRequest) { } forms.push_back(new FormStructure(form)); - ASSERT_TRUE(FormStructure::EncodeQueryRequest(forms, &encoded_signatures, + ASSERT_TRUE(FormStructure::EncodeQueryRequest(forms.get(), + &encoded_signatures, &encoded_xml)); ASSERT_EQ(2U, encoded_signatures.size()); EXPECT_EQ(kSignature1, encoded_signatures[0]); @@ -1432,7 +1436,8 @@ TEST(FormStructureTest, EncodeQueryRequest) { // Check that we fail if there are only bad form(s). ScopedVector<FormStructure> bad_forms; bad_forms.push_back(new FormStructure(form)); - EXPECT_FALSE(FormStructure::EncodeQueryRequest(bad_forms, &encoded_signatures, + EXPECT_FALSE(FormStructure::EncodeQueryRequest(bad_forms.get(), + &encoded_signatures, &encoded_xml)); EXPECT_EQ(0U, encoded_signatures.size()); EXPECT_EQ("", encoded_xml); |