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 @@
#include "chrome/browser/drive/drive_notification_manager_factory.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/profiles/profile.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/invalidation/impl/profile_invalidation_provider.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
......@@ -21,7 +19,6 @@ namespace {
constexpr char kDriveFcmSenderId[] = "947318989803";
invalidation::InvalidationService* GetInvalidationService(Profile* profile) {
if (base::FeatureList::IsEnabled(features::kDriveFcmInvalidations)) {
if (!invalidation::ProfileInvalidationProviderFactory::GetForProfile(
profile)) {
return nullptr;
......@@ -29,14 +26,6 @@ invalidation::InvalidationService* GetInvalidationService(Profile* profile) {
return invalidation::ProfileInvalidationProviderFactory::GetForProfile(
profile)
->GetInvalidationServiceForCustomSender(kDriveFcmSenderId);
}
if (!invalidation::DeprecatedProfileInvalidationProviderFactory::
GetForProfile(profile)) {
return nullptr;
}
return invalidation::DeprecatedProfileInvalidationProviderFactory::
GetForProfile(profile)
->GetInvalidationService();
}
} // namespace
......@@ -76,8 +65,6 @@ DriveNotificationManagerFactory::DriveNotificationManagerFactory()
"DriveNotificationManager",
BrowserContextDependencyManager::GetInstance()) {
DependsOn(ProfileSyncServiceFactory::GetInstance());
DependsOn(invalidation::DeprecatedProfileInvalidationProviderFactory::
GetInstance());
DependsOn(invalidation::ProfileInvalidationProviderFactory::GetInstance());
}
......@@ -86,8 +73,7 @@ DriveNotificationManagerFactory::~DriveNotificationManagerFactory() {}
KeyedService* DriveNotificationManagerFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const {
return new DriveNotificationManager(
GetInvalidationService(Profile::FromBrowserContext(context)),
base::FeatureList::IsEnabled(features::kDriveFcmInvalidations));
GetInvalidationService(Profile::FromBrowserContext(context)));
}
} // namespace drive
......@@ -308,10 +308,6 @@ const base::Feature kDownloadsLocationChange{"DownloadsLocationChange",
base::FEATURE_ENABLED_BY_DEFAULT};
#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
// invalidations.
const base::Feature kPolicyFcmInvalidations{"PolicyFCMInvalidations",
......
......@@ -172,9 +172,6 @@ COMPONENT_EXPORT(CHROME_FEATURES)
extern const base::Feature kDownloadsLocationChange;
#endif
COMPONENT_EXPORT(CHROME_FEATURES)
extern const base::Feature kDriveFcmInvalidations;
COMPONENT_EXPORT(CHROME_FEATURES)
extern const base::Feature kPolicyFcmInvalidations;
......
......@@ -33,29 +33,21 @@ const int kSlowPollingIntervalInSecs = 3600;
constexpr int kInvalidationBatchIntervalSecs = 15;
// The sync invalidation object ID for Google Drive.
const char kDriveInvalidationObjectId[] = "CHANGELOG";
// 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:";
const char kDriveInvalidationObjectId[] = "Drive";
// Team drive invalidation ID's from FCM are "team-drive-<team_drive_id>".
constexpr char kFcmTeamDriveChangePrefix[] = "team-drive-";
constexpr char kTeamDriveChangePrefix[] = "team-drive-";
} // namespace
DriveNotificationManager::DriveNotificationManager(
invalidation::InvalidationService* invalidation_service,
bool use_fcm_object_ids,
const base::TickClock* clock)
: invalidation_service_(invalidation_service),
push_notification_registered_(false),
push_notification_enabled_(false),
observers_notified_(false),
batch_timer_(clock),
use_fcm_object_ids_(use_fcm_object_ids) {
batch_timer_(clock) {
DCHECK(invalidation_service_);
RegisterDriveNotifications();
RestartPollingTimer();
......@@ -131,7 +123,7 @@ void DriveNotificationManager::OnIncomingInvalidation(
std::string DriveNotificationManager::GetOwnerName() const { return "Drive"; }
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(
......@@ -293,21 +285,17 @@ std::string DriveNotificationManager::NotificationSourceToString(
}
std::string DriveNotificationManager::GetDriveInvalidationObjectId() const {
return use_fcm_object_ids_ ? kFcmDriveInvalidationObjectId
: kDriveInvalidationObjectId;
return kDriveInvalidationObjectId;
}
std::string DriveNotificationManager::GetTeamDriveInvalidationObjectId(
const std::string& team_drive_id) const {
return base::StrCat(
{use_fcm_object_ids_ ? kFcmTeamDriveChangePrefix : kTeamDriveChangePrefix,
team_drive_id});
return base::StrCat({kTeamDriveChangePrefix, team_drive_id});
}
std::string DriveNotificationManager::ExtractTeamDriveId(
base::StringPiece object_id) const {
base::StringPiece prefix =
use_fcm_object_ids_ ? kFcmTeamDriveChangePrefix : kTeamDriveChangePrefix;
base::StringPiece prefix = kTeamDriveChangePrefix;
if (!object_id.starts_with(prefix)) {
return {};
}
......
......@@ -38,7 +38,6 @@ class DriveNotificationManager : public KeyedService,
// |clock| can be injected for testing.
explicit DriveNotificationManager(
invalidation::InvalidationService* invalidation_service,
bool use_fcm_object_ids = false,
const base::TickClock* clock = base::DefaultTickClock::GetInstance());
~DriveNotificationManager() override;
......@@ -140,12 +139,6 @@ class DriveNotificationManager : public KeyedService,
// service, will be reset when when send the invalidations to the observers.
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_);
// Note: This should remain the last member so it'll be destroyed and
......
......@@ -19,7 +19,7 @@ namespace {
const invalidation::ObjectId kDefaultCorpusObjectId(
ipc::invalidation::ObjectSource::COSMO_CHANGELOG,
"CHANGELOG");
"Drive");
struct ShutdownHelper {
template <typename T>
......@@ -57,7 +57,7 @@ invalidation::ObjectId CreateTeamDriveInvalidationObjectId(
const std::string& team_drive_id) {
return invalidation::ObjectId(
ipc::invalidation::ObjectSource::COSMO_CHANGELOG,
base::StrCat({"TD:", team_drive_id}));
base::StrCat({"team-drive-", team_drive_id}));
}
} // 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