Commit c2e2160d authored by hirono@chromium.org's avatar hirono@chromium.org

Revert "Improve the no-op reconcilor so that it doesn't "hang" after the first...

Revert "Improve the no-op reconcilor so that it doesn't "hang" after the first execution, but instead successfully completes the reconciliation." (https://codereview.chromium.org/309843002/)

The original CL causes crashes about 20 secs after launching the linux build of chromeos.

This reverts commit 660a4d00.

Conflicts:
	chrome/browser/signin/account_reconcilor_unittest.cc

Original issue's description:
> Improve the no-op reconcilor so that it doesn't "hang" after the first execution, but instead successfully completes the reconciliation.
> Improve the UMAHistogramHelper so that it can nicely take snapshots between tests, allowing the test writer to easily test ONLY the changes logged in "this" test.
> Write a new unit test that executes the reconcilor twice, and make all reconcilor unit tests execute with and without the flag.
>
> BUG=357693
> TBR=phajdan.jr@chromium.org
>
> Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=277605

BUG=357693,386045
TEST=None
TBR=mlerman@chromium.org

Review URL: https://codereview.chromium.org/344513005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@277990 0039d316-1c4b-4281-b951-d872f2087c98
parent e1c52950
...@@ -17,10 +17,6 @@ class HistogramSamples; ...@@ -17,10 +17,6 @@ class HistogramSamples;
// This class acts as a differential reader for histogram samples, enabling // This class acts as a differential reader for histogram samples, enabling
// tests to check that metrics were recorded as they should be. // tests to check that metrics were recorded as they should be.
//
// This class is DEPRECATED.
// TODO(mlerman): Remove all references to this class with UMAHistogramHelper
// references. crbug.com/384011
class StatisticsDeltaReader { class StatisticsDeltaReader {
public: public:
StatisticsDeltaReader(); StatisticsDeltaReader();
......
...@@ -11,27 +11,6 @@ ...@@ -11,27 +11,6 @@
#include "content/public/browser/histogram_fetcher.h" #include "content/public/browser/histogram_fetcher.h"
UMAHistogramHelper::UMAHistogramHelper() { UMAHistogramHelper::UMAHistogramHelper() {
base::StatisticsRecorder::Initialize();
}
UMAHistogramHelper::~UMAHistogramHelper() {
}
void UMAHistogramHelper::PrepareSnapshot(const char* const histogram_names[],
size_t num_histograms) {
for (size_t i = 0; i < num_histograms; ++i) {
std::string histogram_name = histogram_names[i];
base::HistogramBase* histogram =
base::StatisticsRecorder::FindHistogram(histogram_name);
// If there is no histogram present, then don't record a snapshot. The logic
// in the Expect* methods will act to treat no histogram equivalent to
// samples with zeros.
if (histogram) {
histogram_snapshots[histogram_name] =
make_linked_ptr(histogram->SnapshotSamples().release());
}
}
} }
void UMAHistogramHelper::Fetch() { void UMAHistogramHelper::Fetch() {
...@@ -103,25 +82,18 @@ void UMAHistogramHelper::CheckBucketCount( ...@@ -103,25 +82,18 @@ void UMAHistogramHelper::CheckBucketCount(
base::HistogramBase::Sample sample, base::HistogramBase::Sample sample,
base::HistogramBase::Count expected_count, base::HistogramBase::Count expected_count,
base::HistogramSamples& samples) { base::HistogramSamples& samples) {
int actual_count = samples.GetCount(sample); EXPECT_EQ(expected_count, samples.GetCount(sample))
if (histogram_snapshots.count(name))
actual_count -= histogram_snapshots[name]->GetCount(sample);
EXPECT_EQ(expected_count, actual_count)
<< "Histogram \"" << name << "Histogram \"" << name
<< "\" does not have the right number of samples (" << expected_count << "\" does not have the right number of samples (" << expected_count
<< ") in the expected bucket (" << sample << "). It has (" << actual_count << ") in the expected bucket (" << sample << ").";
<< ").";
} }
void UMAHistogramHelper::CheckTotalCount( void UMAHistogramHelper::CheckTotalCount(
const std::string& name, const std::string& name,
base::HistogramBase::Count expected_count, base::HistogramBase::Count expected_count,
base::HistogramSamples& samples) { base::HistogramSamples& samples) {
int actual_count = samples.TotalCount(); EXPECT_EQ(expected_count, samples.TotalCount())
if (histogram_snapshots.count(name))
actual_count -= histogram_snapshots[name]->TotalCount();
EXPECT_EQ(expected_count, actual_count)
<< "Histogram \"" << name << "Histogram \"" << name
<< "\" does not have the right total number of samples (" << "\" does not have the right total number of samples ("
<< expected_count << "). It has (" << actual_count << ")."; << expected_count << ").";
} }
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#ifndef CHROME_TEST_BASE_UMA_HISTOGRAM_HELPER_H_ #ifndef CHROME_TEST_BASE_UMA_HISTOGRAM_HELPER_H_
#define CHROME_TEST_BASE_UMA_HISTOGRAM_HELPER_H_ #define CHROME_TEST_BASE_UMA_HISTOGRAM_HELPER_H_
#include "base/memory/linked_ptr.h"
#include "base/metrics/histogram.h" #include "base/metrics/histogram.h"
#include "base/metrics/histogram_base.h" #include "base/metrics/histogram_base.h"
#include "base/metrics/histogram_samples.h" #include "base/metrics/histogram_samples.h"
...@@ -15,40 +14,25 @@ ...@@ -15,40 +14,25 @@
// intended. // intended.
class UMAHistogramHelper { class UMAHistogramHelper {
public: public:
// UMAHistogramHelper should be created before the execution of the test case.
UMAHistogramHelper(); UMAHistogramHelper();
~UMAHistogramHelper();
// Parameters should be string literals of all histograms to snapshot.
// Call this before executing the test code. This method can be called
// multiple times. The existing snapshots are preserved, except when one of
// the |histogram_names| was previously passed as a parameter, then a new
// snapshot will replace the existing one.
void PrepareSnapshot(const char* const histogram_names[],
size_t num_histograms);
// Each child process may have its own histogram data, make sure this data // Each child process may have its own histogram data, make sure this data
// gets accumulated into the browser process before we examine the histograms. // gets accumulated into the browser process before we examine the histograms.
void Fetch(); void Fetch();
// We know the exact number of samples in a bucket, and that no other bucket // We know the exact number of samples in a bucket, and that no other bucket
// should have samples. If |PrepareSnapshot| was called for the histogram // should have samples.
// named |name| then the |expected_count| is the diff from the snapshot.
void ExpectUniqueSample(const std::string& name, void ExpectUniqueSample(const std::string& name,
base::HistogramBase::Sample sample, base::HistogramBase::Sample sample,
base::HistogramBase::Count expected_count); base::HistogramBase::Count expected_count);
// We know the exact number of samples in a bucket, but other buckets may // We know the exact number of samples in a bucket, but other buckets may
// have samples as well. If |PrepareSnapshot| was called for histogram named // have samples as well.
// |name| then the |expected_count| is the diff from the snapshot.
void ExpectBucketCount(const std::string& name, void ExpectBucketCount(const std::string& name,
base::HistogramBase::Sample sample, base::HistogramBase::Sample sample,
base::HistogramBase::Count expected_count); base::HistogramBase::Count expected_count);
// We don't know the values of the samples, but we know how many there are. If // We don't know the values of the samples, but we know how many there are.
// |PrepareSnapshot| was called for |name| histogram, then the
// |count| is the diff from the snapshot.
void ExpectTotalCount(const std::string& name, void ExpectTotalCount(const std::string& name,
base::HistogramBase::Count count); base::HistogramBase::Count count);
...@@ -65,10 +49,6 @@ class UMAHistogramHelper { ...@@ -65,10 +49,6 @@ class UMAHistogramHelper {
base::HistogramSamples& samples); base::HistogramSamples& samples);
DISALLOW_COPY_AND_ASSIGN(UMAHistogramHelper); DISALLOW_COPY_AND_ASSIGN(UMAHistogramHelper);
// The map from histogram names to their snapshots
std::map<std::string, linked_ptr<base::HistogramSamples> >
histogram_snapshots;
}; };
#endif // CHROME_TEST_BASE_UMA_HISTOGRAM_HELPER_H_ #endif // CHROME_TEST_BASE_UMA_HISTOGRAM_HELPER_H_
...@@ -359,10 +359,8 @@ void AccountReconcilor::GoogleSignedOut(const std::string& username) { ...@@ -359,10 +359,8 @@ void AccountReconcilor::GoogleSignedOut(const std::string& username) {
} }
void AccountReconcilor::PerformMergeAction(const std::string& account_id) { void AccountReconcilor::PerformMergeAction(const std::string& account_id) {
if (!switches::IsNewProfileManagement()) { if (!switches::IsNewProfileManagement())
MarkAccountAsAddedToCookie(account_id);
return; return;
}
VLOG(1) << "AccountReconcilor::PerformMergeAction: " << account_id; VLOG(1) << "AccountReconcilor::PerformMergeAction: " << account_id;
merge_session_helper_.LogIn(account_id); merge_session_helper_.LogIn(account_id);
} }
...@@ -400,10 +398,8 @@ void AccountReconcilor::PerformFinishRemoveAction( ...@@ -400,10 +398,8 @@ void AccountReconcilor::PerformFinishRemoveAction(
void AccountReconcilor::PerformAddToChromeAction(const std::string& account_id, void AccountReconcilor::PerformAddToChromeAction(const std::string& account_id,
int session_index) { int session_index) {
if (!switches::IsNewProfileManagement()) { if (!switches::IsNewProfileManagement())
MarkAccountAsAddedToChrome(account_id);
return; return;
}
VLOG(1) << "AccountReconcilor::PerformAddToChromeAction:" VLOG(1) << "AccountReconcilor::PerformAddToChromeAction:"
<< " account=" << account_id << " session_index=" << session_index; << " account=" << account_id << " session_index=" << session_index;
...@@ -710,9 +706,13 @@ void AccountReconcilor::ScheduleStartReconcileIfChromeAccountsChanged() { ...@@ -710,9 +706,13 @@ void AccountReconcilor::ScheduleStartReconcileIfChromeAccountsChanged() {
} }
} }
// Remove the account from the list that is being merged. void AccountReconcilor::MergeSessionCompleted(
void AccountReconcilor::MarkAccountAsAddedToCookie( const std::string& account_id,
const std::string& account_id) { const GoogleServiceAuthError& error) {
VLOG(1) << "AccountReconcilor::MergeSessionCompleted: account_id="
<< account_id;
// Remove the account from the list that is being merged.
for (std::vector<std::string>::iterator i = add_to_cookie_.begin(); for (std::vector<std::string>::iterator i = add_to_cookie_.begin();
i != add_to_cookie_.end(); i != add_to_cookie_.end();
++i) { ++i) {
...@@ -721,15 +721,7 @@ void AccountReconcilor::MarkAccountAsAddedToCookie( ...@@ -721,15 +721,7 @@ void AccountReconcilor::MarkAccountAsAddedToCookie(
break; break;
} }
} }
}
void AccountReconcilor::MergeSessionCompleted(
const std::string& account_id,
const GoogleServiceAuthError& error) {
VLOG(1) << "AccountReconcilor::MergeSessionCompleted: account_id="
<< account_id;
MarkAccountAsAddedToCookie(account_id);
CalculateIfReconcileIsDone(); CalculateIfReconcileIsDone();
ScheduleStartReconcileIfChromeAccountsChanged(); ScheduleStartReconcileIfChromeAccountsChanged();
} }
...@@ -756,9 +748,13 @@ void AccountReconcilor::PerformAddAccountToTokenService( ...@@ -756,9 +748,13 @@ void AccountReconcilor::PerformAddAccountToTokenService(
token_service_->UpdateCredentials(account_id, refresh_token); token_service_->UpdateCredentials(account_id, refresh_token);
} }
// Remove the account from the list that is being updated. void AccountReconcilor::HandleRefreshTokenFetched(
void AccountReconcilor::MarkAccountAsAddedToChrome( const std::string& account_id,
const std::string& account_id) { const std::string& refresh_token) {
if (!refresh_token.empty()) {
PerformAddAccountToTokenService(account_id, refresh_token);
}
// Remove the account from the list that is being updated.
for (std::vector<std::pair<std::string, int> >::iterator i = for (std::vector<std::pair<std::string, int> >::iterator i =
add_to_chrome_.begin(); add_to_chrome_.begin();
i != add_to_chrome_.end(); i != add_to_chrome_.end();
...@@ -768,14 +764,6 @@ void AccountReconcilor::MarkAccountAsAddedToChrome( ...@@ -768,14 +764,6 @@ void AccountReconcilor::MarkAccountAsAddedToChrome(
break; break;
} }
} }
}
void AccountReconcilor::HandleRefreshTokenFetched(
const std::string& account_id,
const std::string& refresh_token) {
if (!refresh_token.empty())
PerformAddAccountToTokenService(account_id, refresh_token);
MarkAccountAsAddedToChrome(account_id);
CalculateIfReconcileIsDone(); CalculateIfReconcileIsDone();
} }
...@@ -121,8 +121,6 @@ class AccountReconcilor : public KeyedService, ...@@ -121,8 +121,6 @@ class AccountReconcilor : public KeyedService,
FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, StartReconcileNoopWithDots); FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, StartReconcileNoopWithDots);
FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, StartReconcileNoopMultiple); FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, StartReconcileNoopMultiple);
FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, StartReconcileAddToCookie); FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, StartReconcileAddToCookie);
FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest,
StartReconcileAddToCookieTwice);
FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, StartReconcileAddToChrome); FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, StartReconcileAddToChrome);
FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, StartReconcileBadPrimary); FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, StartReconcileBadPrimary);
FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, StartReconcileOnlyOnce); FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, StartReconcileOnlyOnce);
...@@ -174,10 +172,6 @@ class AccountReconcilor : public KeyedService, ...@@ -174,10 +172,6 @@ class AccountReconcilor : public KeyedService,
const GoogleServiceAuthError& error, const GoogleServiceAuthError& error,
const std::vector<std::pair<std::string, bool> >& accounts); const std::vector<std::pair<std::string, bool> >& accounts);
void ValidateAccountsFromTokenService(); void ValidateAccountsFromTokenService();
// Note internally that this |account_id| is added to the cookie jar.
void MarkAccountAsAddedToCookie(const std::string& account_id);
// Note internally that this |account_id| is added to the token service.
void MarkAccountAsAddedToChrome(const std::string& account_id);
void OnCookieChanged(const net::CanonicalCookie* cookie); void OnCookieChanged(const net::CanonicalCookie* cookie);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment