Commit a770aefd authored by Sam McNally's avatar Sam McNally Committed by Commit Bot

Remove Drive support for the deprecated invalidation service.

Bug: 912281
Tbr: fukino@chromium.org
Change-Id: I339af2344343ee668d3e54e83542707d4e215b47
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1945947
Commit-Queue: Sam McNally <sammc@chromium.org>
Auto-Submit: Sam McNally <sammc@chromium.org>
Reviewed-by: default avatarStuart Langley <slangley@chromium.org>
Cr-Commit-Position: refs/heads/master@{#727292}
parent ad511e56
...@@ -5,11 +5,9 @@ ...@@ -5,11 +5,9 @@
#include "chrome/browser/drive/drive_notification_manager_factory.h" #include "chrome/browser/drive/drive_notification_manager_factory.h"
#include "base/logging.h" #include "base/logging.h"
#include "chrome/browser/invalidation/deprecated_profile_invalidation_provider_factory.h"
#include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/profile_sync_service_factory.h" #include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/common/chrome_features.h"
#include "components/drive/drive_notification_manager.h" #include "components/drive/drive_notification_manager.h"
#include "components/invalidation/impl/profile_invalidation_provider.h" #include "components/invalidation/impl/profile_invalidation_provider.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h" #include "components/keyed_service/content/browser_context_dependency_manager.h"
...@@ -21,22 +19,13 @@ namespace { ...@@ -21,22 +19,13 @@ namespace {
constexpr char kDriveFcmSenderId[] = "947318989803"; constexpr char kDriveFcmSenderId[] = "947318989803";
invalidation::InvalidationService* GetInvalidationService(Profile* profile) { invalidation::InvalidationService* GetInvalidationService(Profile* profile) {
if (base::FeatureList::IsEnabled(features::kDriveFcmInvalidations)) { if (!invalidation::ProfileInvalidationProviderFactory::GetForProfile(
if (!invalidation::ProfileInvalidationProviderFactory::GetForProfile( profile)) {
profile)) {
return nullptr;
}
return invalidation::ProfileInvalidationProviderFactory::GetForProfile(
profile)
->GetInvalidationServiceForCustomSender(kDriveFcmSenderId);
}
if (!invalidation::DeprecatedProfileInvalidationProviderFactory::
GetForProfile(profile)) {
return nullptr; return nullptr;
} }
return invalidation::DeprecatedProfileInvalidationProviderFactory:: return invalidation::ProfileInvalidationProviderFactory::GetForProfile(
GetForProfile(profile) profile)
->GetInvalidationService(); ->GetInvalidationServiceForCustomSender(kDriveFcmSenderId);
} }
} // namespace } // namespace
...@@ -76,8 +65,6 @@ DriveNotificationManagerFactory::DriveNotificationManagerFactory() ...@@ -76,8 +65,6 @@ DriveNotificationManagerFactory::DriveNotificationManagerFactory()
"DriveNotificationManager", "DriveNotificationManager",
BrowserContextDependencyManager::GetInstance()) { BrowserContextDependencyManager::GetInstance()) {
DependsOn(ProfileSyncServiceFactory::GetInstance()); DependsOn(ProfileSyncServiceFactory::GetInstance());
DependsOn(invalidation::DeprecatedProfileInvalidationProviderFactory::
GetInstance());
DependsOn(invalidation::ProfileInvalidationProviderFactory::GetInstance()); DependsOn(invalidation::ProfileInvalidationProviderFactory::GetInstance());
} }
...@@ -86,8 +73,7 @@ DriveNotificationManagerFactory::~DriveNotificationManagerFactory() {} ...@@ -86,8 +73,7 @@ DriveNotificationManagerFactory::~DriveNotificationManagerFactory() {}
KeyedService* DriveNotificationManagerFactory::BuildServiceInstanceFor( KeyedService* DriveNotificationManagerFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const { content::BrowserContext* context) const {
return new DriveNotificationManager( return new DriveNotificationManager(
GetInvalidationService(Profile::FromBrowserContext(context)), GetInvalidationService(Profile::FromBrowserContext(context)));
base::FeatureList::IsEnabled(features::kDriveFcmInvalidations));
} }
} // namespace drive } // namespace drive
...@@ -308,10 +308,6 @@ const base::Feature kDownloadsLocationChange{"DownloadsLocationChange", ...@@ -308,10 +308,6 @@ const base::Feature kDownloadsLocationChange{"DownloadsLocationChange",
base::FEATURE_ENABLED_BY_DEFAULT}; base::FEATURE_ENABLED_BY_DEFAULT};
#endif #endif
// If enabled, Drive will use FCM for its invalidations.
const base::Feature kDriveFcmInvalidations{"DriveFCMInvalidations",
base::FEATURE_ENABLED_BY_DEFAULT};
// If enabled, policies will use FCM (Firebase Cloud Messaging) for its // If enabled, policies will use FCM (Firebase Cloud Messaging) for its
// invalidations. // invalidations.
const base::Feature kPolicyFcmInvalidations{"PolicyFCMInvalidations", const base::Feature kPolicyFcmInvalidations{"PolicyFCMInvalidations",
......
...@@ -172,9 +172,6 @@ COMPONENT_EXPORT(CHROME_FEATURES) ...@@ -172,9 +172,6 @@ COMPONENT_EXPORT(CHROME_FEATURES)
extern const base::Feature kDownloadsLocationChange; extern const base::Feature kDownloadsLocationChange;
#endif #endif
COMPONENT_EXPORT(CHROME_FEATURES)
extern const base::Feature kDriveFcmInvalidations;
COMPONENT_EXPORT(CHROME_FEATURES) COMPONENT_EXPORT(CHROME_FEATURES)
extern const base::Feature kPolicyFcmInvalidations; extern const base::Feature kPolicyFcmInvalidations;
......
...@@ -33,29 +33,21 @@ const int kSlowPollingIntervalInSecs = 3600; ...@@ -33,29 +33,21 @@ const int kSlowPollingIntervalInSecs = 3600;
constexpr int kInvalidationBatchIntervalSecs = 15; constexpr int kInvalidationBatchIntervalSecs = 15;
// The sync invalidation object ID for Google Drive. // The sync invalidation object ID for Google Drive.
const char kDriveInvalidationObjectId[] = "CHANGELOG"; const char kDriveInvalidationObjectId[] = "Drive";
// The sync invalidation object ID for Google Drive.
const char kFcmDriveInvalidationObjectId[] = "Drive";
// Team drive invalidation ID's are "TD:<team_drive_id>".
constexpr char kTeamDriveChangePrefix[] = "TD:";
// Team drive invalidation ID's from FCM are "team-drive-<team_drive_id>". // Team drive invalidation ID's from FCM are "team-drive-<team_drive_id>".
constexpr char kFcmTeamDriveChangePrefix[] = "team-drive-"; constexpr char kTeamDriveChangePrefix[] = "team-drive-";
} // namespace } // namespace
DriveNotificationManager::DriveNotificationManager( DriveNotificationManager::DriveNotificationManager(
invalidation::InvalidationService* invalidation_service, invalidation::InvalidationService* invalidation_service,
bool use_fcm_object_ids,
const base::TickClock* clock) const base::TickClock* clock)
: invalidation_service_(invalidation_service), : invalidation_service_(invalidation_service),
push_notification_registered_(false), push_notification_registered_(false),
push_notification_enabled_(false), push_notification_enabled_(false),
observers_notified_(false), observers_notified_(false),
batch_timer_(clock), batch_timer_(clock) {
use_fcm_object_ids_(use_fcm_object_ids) {
DCHECK(invalidation_service_); DCHECK(invalidation_service_);
RegisterDriveNotifications(); RegisterDriveNotifications();
RestartPollingTimer(); RestartPollingTimer();
...@@ -131,7 +123,7 @@ void DriveNotificationManager::OnIncomingInvalidation( ...@@ -131,7 +123,7 @@ void DriveNotificationManager::OnIncomingInvalidation(
std::string DriveNotificationManager::GetOwnerName() const { return "Drive"; } std::string DriveNotificationManager::GetOwnerName() const { return "Drive"; }
bool DriveNotificationManager::IsPublicTopic(const syncer::Topic& topic) const { bool DriveNotificationManager::IsPublicTopic(const syncer::Topic& topic) const {
return base::StringPiece(topic).starts_with(kFcmTeamDriveChangePrefix); return base::StringPiece(topic).starts_with(kTeamDriveChangePrefix);
} }
void DriveNotificationManager::AddObserver( void DriveNotificationManager::AddObserver(
...@@ -293,21 +285,17 @@ std::string DriveNotificationManager::NotificationSourceToString( ...@@ -293,21 +285,17 @@ std::string DriveNotificationManager::NotificationSourceToString(
} }
std::string DriveNotificationManager::GetDriveInvalidationObjectId() const { std::string DriveNotificationManager::GetDriveInvalidationObjectId() const {
return use_fcm_object_ids_ ? kFcmDriveInvalidationObjectId return kDriveInvalidationObjectId;
: kDriveInvalidationObjectId;
} }
std::string DriveNotificationManager::GetTeamDriveInvalidationObjectId( std::string DriveNotificationManager::GetTeamDriveInvalidationObjectId(
const std::string& team_drive_id) const { const std::string& team_drive_id) const {
return base::StrCat( return base::StrCat({kTeamDriveChangePrefix, team_drive_id});
{use_fcm_object_ids_ ? kFcmTeamDriveChangePrefix : kTeamDriveChangePrefix,
team_drive_id});
} }
std::string DriveNotificationManager::ExtractTeamDriveId( std::string DriveNotificationManager::ExtractTeamDriveId(
base::StringPiece object_id) const { base::StringPiece object_id) const {
base::StringPiece prefix = base::StringPiece prefix = kTeamDriveChangePrefix;
use_fcm_object_ids_ ? kFcmTeamDriveChangePrefix : kTeamDriveChangePrefix;
if (!object_id.starts_with(prefix)) { if (!object_id.starts_with(prefix)) {
return {}; return {};
} }
......
...@@ -38,7 +38,6 @@ class DriveNotificationManager : public KeyedService, ...@@ -38,7 +38,6 @@ class DriveNotificationManager : public KeyedService,
// |clock| can be injected for testing. // |clock| can be injected for testing.
explicit DriveNotificationManager( explicit DriveNotificationManager(
invalidation::InvalidationService* invalidation_service, invalidation::InvalidationService* invalidation_service,
bool use_fcm_object_ids = false,
const base::TickClock* clock = base::DefaultTickClock::GetInstance()); const base::TickClock* clock = base::DefaultTickClock::GetInstance());
~DriveNotificationManager() override; ~DriveNotificationManager() override;
...@@ -140,12 +139,6 @@ class DriveNotificationManager : public KeyedService, ...@@ -140,12 +139,6 @@ class DriveNotificationManager : public KeyedService,
// service, will be reset when when send the invalidations to the observers. // service, will be reset when when send the invalidations to the observers.
std::map<std::string, int64_t> invalidated_change_ids_; std::map<std::string, int64_t> invalidated_change_ids_;
// Whether the FCM invalidation IDs should be used. This decides whether
// "Drive" or "CHANGELOG" is used for the Drive invalidations and whether
// the "TD:" or the "team-drive-" prefix is used. This value must match
// whether |invalidation_service_| is an FCMInvalidationService.
const bool use_fcm_object_ids_;
SEQUENCE_CHECKER(sequence_checker_); SEQUENCE_CHECKER(sequence_checker_);
// Note: This should remain the last member so it'll be destroyed and // Note: This should remain the last member so it'll be destroyed and
......
...@@ -19,7 +19,7 @@ namespace { ...@@ -19,7 +19,7 @@ namespace {
const invalidation::ObjectId kDefaultCorpusObjectId( const invalidation::ObjectId kDefaultCorpusObjectId(
ipc::invalidation::ObjectSource::COSMO_CHANGELOG, ipc::invalidation::ObjectSource::COSMO_CHANGELOG,
"CHANGELOG"); "Drive");
struct ShutdownHelper { struct ShutdownHelper {
template <typename T> template <typename T>
...@@ -57,7 +57,7 @@ invalidation::ObjectId CreateTeamDriveInvalidationObjectId( ...@@ -57,7 +57,7 @@ invalidation::ObjectId CreateTeamDriveInvalidationObjectId(
const std::string& team_drive_id) { const std::string& team_drive_id) {
return invalidation::ObjectId( return invalidation::ObjectId(
ipc::invalidation::ObjectSource::COSMO_CHANGELOG, ipc::invalidation::ObjectSource::COSMO_CHANGELOG,
base::StrCat({"TD:", team_drive_id})); base::StrCat({"team-drive-", team_drive_id}));
} }
} // namespace } // namespace
......
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