0

Move gaia::AccountTracker into //components/gcm_driver

This class is deprecated and slated for removal. It now has only one
remaining consumer. This CL moves it into the directory of that consumer,
with followup merging it into the code of that consumer.

This CL also excludes AccountTracker and GCMAccountTracker from the
build on Android, as they're not used on that platform.

Bug: 729590, 809923
Change-Id: I225edf86a3af293779a8cc231ffffac711f22246
Reviewed-on: https://chromium-review.googlesource.com/1002845
Commit-Queue: Colin Blundell <blundell@chromium.org>
Reviewed-by: Peter Beverloo <peter@chromium.org>
Reviewed-by: Mihai Sardarescu <msarda@chromium.org>
Cr-Commit-Position: refs/heads/master@{#551904}
This commit is contained in:
Colin Blundell
2018-04-19 01:03:24 +00:00
committed by Commit Bot
parent 1836ae055c
commit 021e3e4d70
9 changed files with 38 additions and 40 deletions

@ -14,8 +14,6 @@ static_library("gcm_driver") {
sources = [
"features.cc",
"features.h",
"gcm_account_tracker.cc",
"gcm_account_tracker.h",
"gcm_activity.cc",
"gcm_activity.h",
"gcm_app_handler.cc",
@ -88,8 +86,12 @@ static_library("gcm_driver") {
]
} else {
sources += [
"account_tracker.cc",
"account_tracker.h",
"gcm_account_mapper.cc",
"gcm_account_mapper.h",
"gcm_account_tracker.cc",
"gcm_account_tracker.h",
"gcm_channel_status_request.cc",
"gcm_channel_status_request.h",
"gcm_channel_status_syncer.cc",
@ -169,7 +171,6 @@ source_set("unit_tests") {
testonly = true
sources = [
"gcm_account_tracker_unittest.cc",
"gcm_delayed_task_controller_unittest.cc",
"gcm_stats_recorder_android_unittest.cc",
]
@ -192,7 +193,9 @@ source_set("unit_tests") {
if (!use_gcm_from_platform) {
sources += [
"account_tracker_unittest.cc",
"gcm_account_mapper_unittest.cc",
"gcm_account_tracker_unittest.cc",
"gcm_channel_status_request_unittest.cc",
"gcm_client_impl_unittest.cc",
"gcm_driver_desktop_unittest.cc",

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "google_apis/gaia/account_tracker.h"
#include "components/gcm_driver/account_tracker.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
@ -10,7 +10,7 @@
#include "base/trace_event/trace_event.h"
#include "net/url_request/url_request_context_getter.h"
namespace gaia {
namespace gcm {
AccountTracker::AccountTracker(
IdentityProvider* identity_provider,
@ -289,4 +289,4 @@ void AccountIdFetcher::OnNetworkError(int response_code) {
tracker_->OnUserInfoFetchFailure(this);
}
} // namespace gaia
} // namespace gcm

@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef GOOGLE_APIS_GAIA_ACCOUNT_TRACKER_H_
#define GOOGLE_APIS_GAIA_ACCOUNT_TRACKER_H_
#ifndef COMPONENTS_GCM_DRIVER_ACCOUNT_TRACKER_H_
#define COMPONENTS_GCM_DRIVER_ACCOUNT_TRACKER_H_
#include <map>
#include <memory>
@ -21,7 +21,7 @@ namespace net {
class URLRequestContextGetter;
}
namespace gaia {
namespace gcm {
struct AccountIds {
std::string account_key; // The account ID used by OAuth2TokenService.
@ -148,6 +148,6 @@ class AccountIdFetcher : public OAuth2TokenService::Consumer,
std::unique_ptr<gaia::GaiaOAuthClient> gaia_oauth_client_;
};
} // namespace gaia
} // namespace gcm
#endif // GOOGLE_APIS_GAIA_ACCOUNT_TRACKER_H_
#endif // COMPONENTS_GCM_DRIVER_ACCOUNT_TRACKER_H_

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "google_apis/gaia/account_tracker.h"
#include "components/gcm_driver/account_tracker.h"
#include <algorithm>
#include <vector>
@ -87,7 +87,7 @@ std::string Str(const std::vector<TrackingEvent>& events) {
} // namespace
namespace gaia {
namespace gcm {
class AccountTrackerObserver : public AccountTracker::Observer {
public:
@ -709,4 +709,4 @@ TEST_F(IdentityAccountTrackerTest,
EXPECT_EQ(0ul, ids.size());
}
} // namespace gaia
} // namespace gcm

@ -45,7 +45,7 @@ GCMAccountTracker::AccountInfo::~AccountInfo() {
}
GCMAccountTracker::GCMAccountTracker(
std::unique_ptr<gaia::AccountTracker> account_tracker,
std::unique_ptr<AccountTracker> account_tracker,
GCMDriver* driver)
: OAuth2TokenService::Consumer(kGCMAccountTrackerName),
account_tracker_(account_tracker.release()),
@ -69,10 +69,9 @@ void GCMAccountTracker::Start() {
account_tracker_->AddObserver(this);
driver_->AddConnectionObserver(this);
std::vector<gaia::AccountIds> accounts = account_tracker_->GetAccounts();
for (std::vector<gaia::AccountIds>::const_iterator iter = accounts.begin();
iter != accounts.end();
++iter) {
std::vector<AccountIds> accounts = account_tracker_->GetAccounts();
for (std::vector<AccountIds>::const_iterator iter = accounts.begin();
iter != accounts.end(); ++iter) {
if (!iter->email.empty()) {
account_infos_.insert(std::make_pair(
iter->account_key, AccountInfo(iter->email, TOKEN_NEEDED)));
@ -101,7 +100,7 @@ void GCMAccountTracker::ScheduleReportTokens() {
GetTimeToNextTokenReporting());
}
void GCMAccountTracker::OnAccountSignInChanged(const gaia::AccountIds& ids,
void GCMAccountTracker::OnAccountSignInChanged(const AccountIds& ids,
bool is_signed_in) {
if (is_signed_in)
OnAccountSignedIn(ids);
@ -183,7 +182,7 @@ void GCMAccountTracker::ReportTokens() {
return;
}
// Wait for gaia::AccountTracker to be done with fetching the user info, as
// Wait for AccountTracker to be done with fetching the user info, as
// well as all of the pending token requests from GCMAccountTracker to be done
// before you report the results.
if (!account_tracker_->IsAllUserInfoFetched() ||
@ -337,7 +336,7 @@ void GCMAccountTracker::GetToken(AccountInfos::iterator& account_iter) {
account_iter->second.state = GETTING_TOKEN;
}
void GCMAccountTracker::OnAccountSignedIn(const gaia::AccountIds& ids) {
void GCMAccountTracker::OnAccountSignedIn(const AccountIds& ids) {
DVLOG(1) << "Account signed in: " << ids.email;
AccountInfos::iterator iter = account_infos_.find(ids.account_key);
if (iter == account_infos_.end()) {
@ -351,7 +350,7 @@ void GCMAccountTracker::OnAccountSignedIn(const gaia::AccountIds& ids) {
GetAllNeededTokens();
}
void GCMAccountTracker::OnAccountSignedOut(const gaia::AccountIds& ids) {
void GCMAccountTracker::OnAccountSignedOut(const AccountIds& ids) {
DVLOG(1) << "Account signed out: " << ids.email;
AccountInfos::iterator iter = account_infos_.find(ids.account_key);
if (iter == account_infos_.end())

@ -13,9 +13,9 @@
#include <vector>
#include "base/macros.h"
#include "components/gcm_driver/account_tracker.h"
#include "components/gcm_driver/gcm_client.h"
#include "components/gcm_driver/gcm_connection_observer.h"
#include "google_apis/gaia/account_tracker.h"
#include "google_apis/gaia/oauth2_token_service.h"
namespace base {
@ -33,7 +33,7 @@ class GCMDriver;
// still logged into the profile, so that in the case that the user is not, we
// can immediately report that to the GCM and stop messages addressed to that
// user from ever reaching Chrome.
class GCMAccountTracker : public gaia::AccountTracker::Observer,
class GCMAccountTracker : public AccountTracker::Observer,
public OAuth2TokenService::Consumer,
public GCMConnectionObserver {
public:
@ -71,7 +71,7 @@ class GCMAccountTracker : public gaia::AccountTracker::Observer,
// |account_tracker| is used to deliver information about the accounts present
// in the browser context to |driver|.
GCMAccountTracker(std::unique_ptr<gaia::AccountTracker> account_tracker,
GCMAccountTracker(std::unique_ptr<AccountTracker> account_tracker,
GCMDriver* driver);
~GCMAccountTracker() override;
@ -96,7 +96,7 @@ class GCMAccountTracker : public gaia::AccountTracker::Observer,
typedef std::map<std::string, AccountInfo> AccountInfos;
// AccountTracker::Observer overrides.
void OnAccountSignInChanged(const gaia::AccountIds& ids,
void OnAccountSignInChanged(const AccountIds& ids,
bool is_signed_in) override;
// OAuth2TokenService::Consumer overrides.
@ -136,13 +136,13 @@ class GCMAccountTracker : public gaia::AccountTracker::Observer,
void GetToken(AccountInfos::iterator& account_iter);
// Handling of actual sign in and sign out for accounts.
void OnAccountSignedIn(const gaia::AccountIds& ids);
void OnAccountSignedOut(const gaia::AccountIds& ids);
void OnAccountSignedIn(const AccountIds& ids);
void OnAccountSignedOut(const AccountIds& ids);
OAuth2TokenService* GetTokenService();
// Account tracker.
std::unique_ptr<gaia::AccountTracker> account_tracker_;
std::unique_ptr<AccountTracker> account_tracker_;
// GCM Driver. Not owned.
GCMDriver* driver_;

@ -198,10 +198,9 @@ GCMAccountTrackerTest::GCMAccountTrackerTest() {
fake_identity_provider_.reset(
new FakeIdentityProvider(fake_token_service_.get()));
std::unique_ptr<gaia::AccountTracker> gaia_account_tracker(
new gaia::AccountTracker(
fake_identity_provider_.get(),
new net::TestURLRequestContextGetter(message_loop_.task_runner())));
std::unique_ptr<AccountTracker> gaia_account_tracker(new AccountTracker(
fake_identity_provider_.get(),
new net::TestURLRequestContextGetter(message_loop_.task_runner())));
tracker_.reset(
new GCMAccountTracker(std::move(gaia_account_tracker), &driver_));

@ -22,13 +22,13 @@
#include "base/bind.h"
#include "base/files/file_path.h"
#include "base/memory/weak_ptr.h"
#include "components/gcm_driver/account_tracker.h"
#include "components/gcm_driver/gcm_account_tracker.h"
#include "components/gcm_driver/gcm_channel_status_syncer.h"
#include "components/gcm_driver/gcm_client_factory.h"
#include "components/gcm_driver/gcm_desktop_utils.h"
#include "components/gcm_driver/gcm_driver_desktop.h"
#include "components/signin/core/browser/signin_manager.h"
#include "google_apis/gaia/account_tracker.h"
#include "google_apis/gaia/identity_provider.h"
#include "net/url_request/url_request_context_getter.h"
#endif
@ -107,8 +107,8 @@ void GCMProfileService::IdentityObserver::StartAccountTracker(
if (gcm_account_tracker_)
return;
std::unique_ptr<gaia::AccountTracker> gaia_account_tracker(
new gaia::AccountTracker(identity_provider_, request_context));
std::unique_ptr<AccountTracker> gaia_account_tracker(
new AccountTracker(identity_provider_, request_context));
gcm_account_tracker_.reset(
new GCMAccountTracker(std::move(gaia_account_tracker), driver_));

@ -84,8 +84,6 @@ config("key_defines") {
template("google_apis_tmpl") {
source_set(target_name) {
sources = [
"gaia/account_tracker.cc",
"gaia/account_tracker.h",
"gaia/gaia_auth_consumer.cc",
"gaia/gaia_auth_consumer.h",
"gaia/gaia_auth_fetcher.cc",
@ -233,7 +231,6 @@ static_library("test_support") {
test("google_apis_unittests") {
sources = [
"gaia/account_tracker_unittest.cc",
"gaia/gaia_auth_fetcher_unittest.cc",
"gaia/gaia_auth_util_unittest.cc",
"gaia/gaia_oauth_client_unittest.cc",