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

Unified Diff: content/browser/background_sync/background_sync_manager.cc

Issue 1376533002: [BackgroundSync] Add ability to disable Background Sync via Field Trial (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nit Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/background_sync/background_sync_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/background_sync/background_sync_manager.cc
diff --git a/content/browser/background_sync/background_sync_manager.cc b/content/browser/background_sync/background_sync_manager.cc
index d56d349051d499eb892dc5462ce1864051b1378b..3589bcc820a68f5fd4bf58d3500bcf3270a114de 100644
--- a/content/browser/background_sync/background_sync_manager.cc
+++ b/content/browser/background_sync/background_sync_manager.cc
@@ -7,6 +7,7 @@
#include "base/barrier_closure.h"
#include "base/bind.h"
#include "base/location.h"
+#include "base/metrics/field_trial.h"
#include "base/single_thread_task_runner.h"
#include "base/thread_task_runner_handle.h"
#include "content/browser/background_sync/background_sync_metrics.h"
@@ -51,6 +52,12 @@ void PostErrorResponse(
base::Passed(scoped_ptr<BackgroundSyncRegistrationHandle>().Pass())));
}
+bool ShouldDisableForFieldTrial() {
+ std::string experiment = base::FieldTrialList::FindFullName("BackgroundSync");
+ return base::StartsWith(experiment, "ExperimentDisable",
+ base::CompareCase::INSENSITIVE_ASCII);
+}
+
} // namespace
BackgroundSyncManager::BackgroundSyncRegistrations::
@@ -239,6 +246,11 @@ void BackgroundSyncManager::InitImpl(const base::Closure& callback) {
return;
}
+ if (ShouldDisableForFieldTrial()) {
+ DisableAndClearManager(callback);
+ return;
+ }
+
GetDataFromBackend(
kBackgroundSyncUserDataKey,
base::Bind(&BackgroundSyncManager::InitDidGetDataFromBackend,
@@ -333,6 +345,13 @@ void BackgroundSyncManager::RegisterImpl(
return;
}
+ if (ShouldDisableForFieldTrial()) {
+ DisableAndClearManager(base::Bind(
+ callback, BACKGROUND_SYNC_STATUS_STORAGE_ERROR,
+ base::Passed(scoped_ptr<BackgroundSyncRegistrationHandle>().Pass())));
+ return;
+ }
+
if (options.tag.length() > kMaxTagLength) {
BackgroundSyncMetrics::CountRegister(
options.periodicity, registration_could_fire,
« no previous file with comments | « no previous file | content/browser/background_sync/background_sync_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698