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

Unified Diff: components/browser_sync/profile_sync_service.cc

Issue 2442453002: [Sync] Adds a new switch for enabling the new local server backend. (Closed)
Patch Set: Ifdefs for Windows only. Created 4 years, 2 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
Index: components/browser_sync/profile_sync_service.cc
diff --git a/components/browser_sync/profile_sync_service.cc b/components/browser_sync/profile_sync_service.cc
index 86eb0068764fdffdf387853a9811d4bdb6c5ef26..aa6f9f78e15d05511d105e7a0019ca4178efafae 100644
--- a/components/browser_sync/profile_sync_service.cc
+++ b/components/browser_sync/profile_sync_service.cc
@@ -20,6 +20,7 @@
#include "base/memory/ptr_util.h"
#include "base/memory/ref_counted.h"
#include "base/metrics/histogram.h"
+#include "base/path_service.h"
#include "base/profiler/scoped_tracker.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/stringprintf.h"
@@ -118,6 +119,9 @@ typedef GoogleServiceAuthError AuthError;
const char kSyncUnrecoverableErrorHistogram[] = "Sync.UnrecoverableErrors";
+const base::FilePath::StringType kLoopbackServerBackendFilename =
+ FILE_PATH_LITERAL("profile.pb");
+
const net::BackoffEntry::Policy kRequestAccessTokenBackoffPolicy = {
// Number of initial errors (in sequence) to ignore before applying
// exponential back-off rules.
@@ -502,6 +506,30 @@ void ProfileSyncService::InitializeBackend(bool delete_stale_data) {
if (delete_stale_data)
ClearStaleErrors();
+ bool enable_local_sync_backend = false;
+ base::FilePath local_sync_backend_folder;
+#if defined(OS_WIN)
+ enable_local_sync_backend = base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableLocalSyncBackend);
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kLocalSyncBackendDir)) {
+ local_sync_backend_folder =
+ base::CommandLine::ForCurrentProcess()->GetSwitchValuePath(
+ switches::kLocalSyncBackendDir);
+ } else {
+ // TODO(pastarmovj): Add DIR_ROAMING_USER_DATA to PathService to simplify
+ // this code and move the logic in its right place. See crbug/657810.
+ CHECK(
+ base::PathService::Get(base::DIR_APP_DATA, &local_sync_backend_folder));
+ local_sync_backend_folder =
+ local_sync_backend_folder.Append(FILE_PATH_LITERAL("Chrome/User Data"));
+ }
+ local_sync_backend_folder =
+ local_sync_backend_folder.Append(base_directory_.BaseName());
pavely 2016/10/27 23:53:39 I guess base_directory_.BaseName() returns "Defaul
pastarmovj 2016/11/02 13:39:25 Yes this is a question we are still debating inter
+ local_sync_backend_folder =
+ local_sync_backend_folder.Append(kLoopbackServerBackendFilename);
+#endif // defined(OS_WIN)
+
SyncBackendHost::HttpPostProviderFactoryGetter
http_post_provider_factory_getter =
base::Bind(&syncer::NetworkResources::GetHttpPostProviderFactory,
@@ -511,9 +539,9 @@ void ProfileSyncService::InitializeBackend(bool delete_stale_data) {
backend_->Initialize(
this, std::move(sync_thread_), db_thread_, file_thread_,
GetJsEventHandler(), sync_service_url_, local_device_->GetSyncUserAgent(),
- credentials, delete_stale_data,
- std::unique_ptr<syncer::SyncManagerFactory>(
- new syncer::SyncManagerFactory()),
+ credentials, delete_stale_data, enable_local_sync_backend,
+ local_sync_backend_folder, std::unique_ptr<syncer::SyncManagerFactory>(
+ new syncer::SyncManagerFactory()),
MakeWeakHandle(sync_enabled_weak_factory_.GetWeakPtr()),
base::Bind(syncer::ReportUnrecoverableError, channel_),
http_post_provider_factory_getter, std::move(saved_nigori_state_));

Powered by Google App Engine
This is Rietveld 408576698