diff options
author | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-21 14:00:08 +0000 |
---|---|---|
committer | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-21 14:00:08 +0000 |
commit | b7e3e9b28ba3e3898f7685f9a4540dcf3ebe5d42 (patch) | |
tree | 711823024467cdeed81fc3c352c9da6c6e4c74cb | |
parent | 9b861c5429b756f39dcb5c2f026142aab1b5e218 (diff) | |
download | chromium_src-b7e3e9b28ba3e3898f7685f9a4540dcf3ebe5d42.zip chromium_src-b7e3e9b28ba3e3898f7685f9a4540dcf3ebe5d42.tar.gz chromium_src-b7e3e9b28ba3e3898f7685f9a4540dcf3ebe5d42.tar.bz2 |
Revert r106646 "Don't pass around ScopedVectors(), prefer passing std::vector instead."
It's probably introducing flakiness in browser_tests:DownloadsApiTest.Downloads on Mac only.
BUG=
TEST=
Review URL: http://codereview.chromium.org/8361033
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106714 0039d316-1c4b-4281-b951-d872f2087c98
-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, 34 insertions, 36 deletions
diff --git a/chrome/browser/autofill/autofill_download.cc b/chrome/browser/autofill/autofill_download.cc index 5423752..9c39339f 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 std::vector<FormStructure*>& forms, + const ScopedVector<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 8d430ef..6a52179 100644 --- a/chrome/browser/autofill/autofill_download.h +++ b/chrome/browser/autofill/autofill_download.h @@ -14,6 +14,7 @@ #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" @@ -67,7 +68,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 std::vector<FormStructure*>& forms, + bool StartQueryRequest(const ScopedVector<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 4c72e7d..4e9724b 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.get(), + EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures, 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.get(), + EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures, 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.get(), + EXPECT_FALSE(download_manager_.StartQueryRequest(form_structures, 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.get(), + EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures0, 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.get(), + EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures0, 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.get(), + EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures1, 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.get(), + EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures2, 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.get(), + EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures1, mock_metric_logger)); EXPECT_CALL(mock_metric_logger, LogServerQueryMetric(AutofillMetrics::QUERY_SENT)).Times(1); - EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures2.get(), + EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures2, 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.get(), + EXPECT_TRUE(download_manager_.StartQueryRequest(form_structures0, 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 3fbbc99..fe3d6ba 100644 --- a/chrome/browser/autofill/autofill_manager.cc +++ b/chrome/browser/autofill/autofill_manager.cc @@ -1154,10 +1154,8 @@ 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_.get(), - *metric_logger_); - } + if (!form_structures_.empty() && !disable_download_manager_requests_) + download_manager_.StartQueryRequest(form_structures_, *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 416b36b..397f188 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* form_field = field(i); - ASSERT_TRUE(form_field); - form_field->set_heuristic_type(heuristic_types[i]); - form_field->set_server_type(server_types[i]); + AutofillField* field = (*fields())[i]; + ASSERT_TRUE(field); + field->set_heuristic_type(heuristic_types[i]); + 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 1d5fe4d..d5b8db4 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* form_field = field(i); - ASSERT_TRUE(form_field); - form_field->set_heuristic_type(heuristic_types[i]); - form_field->set_server_type(server_types[i]); + AutofillField* field = (*fields())[i]; + ASSERT_TRUE(field); + field->set_heuristic_type(heuristic_types[i]); + 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 33a2768..d97f108 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 std::vector<FormStructure*>& forms, + const ScopedVector<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 db38b95..225a856 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 std::vector<FormStructure*>& forms, + static bool EncodeQueryRequest(const ScopedVector<FormStructure>& forms, std::vector<std::string>* encoded_signatures, std::string* encoded_xml); @@ -142,6 +142,10 @@ 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 dfb00e6..ec9c6ce 100644 --- a/chrome/browser/autofill/form_structure_unittest.cc +++ b/chrome/browser/autofill/form_structure_unittest.cc @@ -1371,8 +1371,7 @@ TEST(FormStructureTest, EncodeQueryRequest) { "<field signature=\"1917667676\"/><field signature=\"2226358947\"/>" "<field signature=\"747221617\"/><field signature=\"4108155786\"/></form>" "</autofillquery>"; - ASSERT_TRUE(FormStructure::EncodeQueryRequest(forms.get(), - &encoded_signatures, + ASSERT_TRUE(FormStructure::EncodeQueryRequest(forms, &encoded_signatures, &encoded_xml)); ASSERT_EQ(1U, encoded_signatures.size()); EXPECT_EQ(kSignature1, encoded_signatures[0]); @@ -1381,8 +1380,7 @@ 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.get(), - &encoded_signatures, + ASSERT_TRUE(FormStructure::EncodeQueryRequest(forms, &encoded_signatures, &encoded_xml)); ASSERT_EQ(1U, encoded_signatures.size()); EXPECT_EQ(kSignature1, encoded_signatures[0]); @@ -1395,8 +1393,7 @@ TEST(FormStructureTest, EncodeQueryRequest) { } forms.push_back(new FormStructure(form)); - ASSERT_TRUE(FormStructure::EncodeQueryRequest(forms.get(), - &encoded_signatures, + ASSERT_TRUE(FormStructure::EncodeQueryRequest(forms, &encoded_signatures, &encoded_xml)); ASSERT_EQ(2U, encoded_signatures.size()); EXPECT_EQ(kSignature1, encoded_signatures[0]); @@ -1425,8 +1422,7 @@ TEST(FormStructureTest, EncodeQueryRequest) { } forms.push_back(new FormStructure(form)); - ASSERT_TRUE(FormStructure::EncodeQueryRequest(forms.get(), - &encoded_signatures, + ASSERT_TRUE(FormStructure::EncodeQueryRequest(forms, &encoded_signatures, &encoded_xml)); ASSERT_EQ(2U, encoded_signatures.size()); EXPECT_EQ(kSignature1, encoded_signatures[0]); @@ -1436,8 +1432,7 @@ 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.get(), - &encoded_signatures, + EXPECT_FALSE(FormStructure::EncodeQueryRequest(bad_forms, &encoded_signatures, &encoded_xml)); EXPECT_EQ(0U, encoded_signatures.size()); EXPECT_EQ("", encoded_xml); |