Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(599)

Side by Side Diff: components/signin/core/browser/account_reconcilor.cc

Issue 270673003: UMA metrics - number of accounts per profile and account reconciler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile error, out-of-order parameter Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/signin/core/browser/account_reconcilor.h" 5 #include "components/signin/core/browser/account_reconcilor.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/message_loop/message_loop_proxy.h" 13 #include "base/message_loop/message_loop_proxy.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "base/time/time.h" 15 #include "base/time/time.h"
16 #include "components/signin/core/browser/profile_oauth2_token_service.h" 16 #include "components/signin/core/browser/profile_oauth2_token_service.h"
17 #include "components/signin/core/browser/signin_client.h" 17 #include "components/signin/core/browser/signin_client.h"
18 #include "components/signin/core/browser/signin_metrics.h"
18 #include "components/signin/core/browser/signin_oauth_helper.h" 19 #include "components/signin/core/browser/signin_oauth_helper.h"
19 #include "google_apis/gaia/gaia_auth_fetcher.h" 20 #include "google_apis/gaia/gaia_auth_fetcher.h"
20 #include "google_apis/gaia/gaia_auth_util.h" 21 #include "google_apis/gaia/gaia_auth_util.h"
21 #include "google_apis/gaia/gaia_constants.h" 22 #include "google_apis/gaia/gaia_constants.h"
22 #include "google_apis/gaia/gaia_oauth_client.h" 23 #include "google_apis/gaia/gaia_oauth_client.h"
23 #include "google_apis/gaia/gaia_urls.h" 24 #include "google_apis/gaia/gaia_urls.h"
24 #include "net/cookies/canonical_cookie.h" 25 #include "net/cookies/canonical_cookie.h"
25 26
26 27
27 namespace { 28 namespace {
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 SigninClient* client) 192 SigninClient* client)
192 : OAuth2TokenService::Consumer("account_reconcilor"), 193 : OAuth2TokenService::Consumer("account_reconcilor"),
193 token_service_(token_service), 194 token_service_(token_service),
194 signin_manager_(signin_manager), 195 signin_manager_(signin_manager),
195 client_(client), 196 client_(client),
196 merge_session_helper_(token_service_, 197 merge_session_helper_(token_service_,
197 client->GetURLRequestContext(), 198 client->GetURLRequestContext(),
198 this), 199 this),
199 registered_with_token_service_(false), 200 registered_with_token_service_(false),
200 is_reconcile_started_(false), 201 is_reconcile_started_(false),
202 first_execution_(true),
201 are_gaia_accounts_set_(false), 203 are_gaia_accounts_set_(false),
202 requests_(NULL) { 204 requests_(NULL) {
203 VLOG(1) << "AccountReconcilor::AccountReconcilor"; 205 VLOG(1) << "AccountReconcilor::AccountReconcilor";
204 } 206 }
205 207
206 AccountReconcilor::~AccountReconcilor() { 208 AccountReconcilor::~AccountReconcilor() {
207 VLOG(1) << "AccountReconcilor::~AccountReconcilor"; 209 VLOG(1) << "AccountReconcilor::~AccountReconcilor";
208 // Make sure shutdown was called first. 210 // Make sure shutdown was called first.
209 DCHECK(!registered_with_token_service_); 211 DCHECK(!registered_with_token_service_);
210 DCHECK(!requests_); 212 DCHECK(!requests_);
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 ++i) { 604 ++i) {
603 if (*i != primary_account_) 605 if (*i != primary_account_)
604 add_to_cookie_.push_back(*i); 606 add_to_cookie_.push_back(*i);
605 } 607 }
606 608
607 // For each account known to chrome, PerformMergeAction() if the account is 609 // For each account known to chrome, PerformMergeAction() if the account is
608 // not already in the cookie jar or its state is invalid, or signal merge 610 // not already in the cookie jar or its state is invalid, or signal merge
609 // completed otherwise. Make a copy of |add_to_cookie_| since calls to 611 // completed otherwise. Make a copy of |add_to_cookie_| since calls to
610 // SignalComplete() will change the array. 612 // SignalComplete() will change the array.
611 std::vector<std::string> add_to_cookie_copy = add_to_cookie_; 613 std::vector<std::string> add_to_cookie_copy = add_to_cookie_;
614 int added_to_cookie = 0;
612 for (size_t i = 0; i < add_to_cookie_copy.size(); ++i) { 615 for (size_t i = 0; i < add_to_cookie_copy.size(); ++i) {
613 if (gaia_accounts_.end() != 616 if (gaia_accounts_.end() !=
614 std::find_if(gaia_accounts_.begin(), 617 std::find_if(gaia_accounts_.begin(),
615 gaia_accounts_.end(), 618 gaia_accounts_.end(),
616 std::bind1st(EmailEqualToFunc(), 619 std::bind1st(EmailEqualToFunc(),
617 std::make_pair(add_to_cookie_copy[i], 620 std::make_pair(add_to_cookie_copy[i],
618 true)))) { 621 true)))) {
619 merge_session_helper_.SignalComplete( 622 merge_session_helper_.SignalComplete(
620 add_to_cookie_copy[i], 623 add_to_cookie_copy[i],
621 GoogleServiceAuthError::AuthErrorNone()); 624 GoogleServiceAuthError::AuthErrorNone());
622 } else { 625 } else {
623 PerformMergeAction(add_to_cookie_copy[i]); 626 PerformMergeAction(add_to_cookie_copy[i]);
627 added_to_cookie++;
624 } 628 }
625 } 629 }
626 630
627 // For each account in the gaia cookie not known to chrome, 631 // For each account in the gaia cookie not known to chrome,
628 // PerformAddToChromeAction. 632 // PerformAddToChromeAction.
629 for (std::vector<std::pair<std::string, int> >::const_iterator i = 633 for (std::vector<std::pair<std::string, int> >::const_iterator i =
630 add_to_chrome_.begin(); 634 add_to_chrome_.begin();
631 i != add_to_chrome_.end(); 635 i != add_to_chrome_.end();
632 ++i) { 636 ++i) {
633 PerformAddToChromeAction(i->first, i->second); 637 PerformAddToChromeAction(i->first, i->second);
634 } 638 }
635 639
640 signin_metrics::LogSigninAccountReconciliation(valid_chrome_accounts_.size(),
641 added_to_cookie,
642 add_to_chrome_.size(),
643 are_primaries_equal,
644 first_execution_);
645 first_execution_ = false;
636 CalculateIfReconcileIsDone(); 646 CalculateIfReconcileIsDone();
637 ScheduleStartReconcileIfChromeAccountsChanged(); 647 ScheduleStartReconcileIfChromeAccountsChanged();
638 } 648 }
639 649
640 void AccountReconcilor::AbortReconcile() { 650 void AccountReconcilor::AbortReconcile() {
641 VLOG(1) << "AccountReconcilor::AbortReconcile: we'll try again later"; 651 VLOG(1) << "AccountReconcilor::AbortReconcile: we'll try again later";
642 DeleteFetchers(); 652 DeleteFetchers();
643 add_to_cookie_.clear(); 653 add_to_cookie_.clear();
644 add_to_chrome_.clear(); 654 add_to_chrome_.clear();
645 CalculateIfReconcileIsDone(); 655 CalculateIfReconcileIsDone();
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 i != add_to_chrome_.end(); 723 i != add_to_chrome_.end();
714 ++i) { 724 ++i) {
715 if (gaia::AreEmailsSame(account_id, i->first)) { 725 if (gaia::AreEmailsSame(account_id, i->first)) {
716 add_to_chrome_.erase(i); 726 add_to_chrome_.erase(i);
717 break; 727 break;
718 } 728 }
719 } 729 }
720 730
721 CalculateIfReconcileIsDone(); 731 CalculateIfReconcileIsDone();
722 } 732 }
OLDNEW
« no previous file with comments | « components/signin/core/browser/account_reconcilor.h ('k') | components/signin/core/browser/signin_metrics.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698