OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/browser_sync/profile_sync_service.h" | 5 #include "components/browser_sync/profile_sync_service.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <cstddef> | 9 #include <cstddef> |
10 #include <map> | 10 #include <map> |
11 #include <utility> | 11 #include <utility> |
12 | 12 |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/bind_helpers.h" | 14 #include "base/bind_helpers.h" |
15 #include "base/callback.h" | 15 #include "base/callback.h" |
16 #include "base/command_line.h" | 16 #include "base/command_line.h" |
17 #include "base/feature_list.h" | 17 #include "base/feature_list.h" |
18 #include "base/files/file_util.h" | 18 #include "base/files/file_util.h" |
19 #include "base/logging.h" | 19 #include "base/logging.h" |
20 #include "base/memory/ptr_util.h" | 20 #include "base/memory/ptr_util.h" |
21 #include "base/memory/ref_counted.h" | 21 #include "base/memory/ref_counted.h" |
22 #include "base/metrics/histogram.h" | 22 #include "base/metrics/histogram.h" |
23 #include "base/path_service.h" | |
23 #include "base/profiler/scoped_tracker.h" | 24 #include "base/profiler/scoped_tracker.h" |
24 #include "base/single_thread_task_runner.h" | 25 #include "base/single_thread_task_runner.h" |
25 #include "base/strings/stringprintf.h" | 26 #include "base/strings/stringprintf.h" |
26 #include "base/threading/thread_restrictions.h" | 27 #include "base/threading/thread_restrictions.h" |
27 #include "base/threading/thread_task_runner_handle.h" | 28 #include "base/threading/thread_task_runner_handle.h" |
28 #include "components/autofill/core/common/autofill_pref_names.h" | 29 #include "components/autofill/core/common/autofill_pref_names.h" |
29 #include "components/browser_sync/browser_sync_switches.h" | 30 #include "components/browser_sync/browser_sync_switches.h" |
30 #include "components/history/core/browser/typed_url_data_type_controller.h" | 31 #include "components/history/core/browser/typed_url_data_type_controller.h" |
31 #include "components/invalidation/impl/invalidation_prefs.h" | 32 #include "components/invalidation/impl/invalidation_prefs.h" |
32 #include "components/invalidation/public/invalidation_service.h" | 33 #include "components/invalidation/public/invalidation_service.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
111 using syncer::SyncCredentials; | 112 using syncer::SyncCredentials; |
112 using syncer::SyncProtocolError; | 113 using syncer::SyncProtocolError; |
113 using syncer::WeakHandle; | 114 using syncer::WeakHandle; |
114 | 115 |
115 namespace browser_sync { | 116 namespace browser_sync { |
116 | 117 |
117 typedef GoogleServiceAuthError AuthError; | 118 typedef GoogleServiceAuthError AuthError; |
118 | 119 |
119 const char kSyncUnrecoverableErrorHistogram[] = "Sync.UnrecoverableErrors"; | 120 const char kSyncUnrecoverableErrorHistogram[] = "Sync.UnrecoverableErrors"; |
120 | 121 |
122 const base::FilePath::StringType kLoopbackServerBackendFilename = | |
123 FILE_PATH_LITERAL("profile.pb"); | |
124 | |
121 const net::BackoffEntry::Policy kRequestAccessTokenBackoffPolicy = { | 125 const net::BackoffEntry::Policy kRequestAccessTokenBackoffPolicy = { |
122 // Number of initial errors (in sequence) to ignore before applying | 126 // Number of initial errors (in sequence) to ignore before applying |
123 // exponential back-off rules. | 127 // exponential back-off rules. |
124 0, | 128 0, |
125 | 129 |
126 // Initial delay for exponential back-off in ms. | 130 // Initial delay for exponential back-off in ms. |
127 2000, | 131 2000, |
128 | 132 |
129 // Factor by which the waiting time will be multiplied. | 133 // Factor by which the waiting time will be multiplied. |
130 2, | 134 2, |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
495 if (!backend_) { | 499 if (!backend_) { |
496 NOTREACHED(); | 500 NOTREACHED(); |
497 return; | 501 return; |
498 } | 502 } |
499 | 503 |
500 SyncCredentials credentials = GetCredentials(); | 504 SyncCredentials credentials = GetCredentials(); |
501 | 505 |
502 if (delete_stale_data) | 506 if (delete_stale_data) |
503 ClearStaleErrors(); | 507 ClearStaleErrors(); |
504 | 508 |
509 bool enable_local_sync_backend = false; | |
510 base::FilePath local_sync_backend_folder; | |
511 #if defined(OS_WIN) | |
512 enable_local_sync_backend = base::CommandLine::ForCurrentProcess()->HasSwitch( | |
513 switches::kEnableLocalSyncBackend); | |
514 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | |
515 switches::kLocalSyncBackendDir)) { | |
516 local_sync_backend_folder = | |
517 base::CommandLine::ForCurrentProcess()->GetSwitchValuePath( | |
518 switches::kLocalSyncBackendDir); | |
519 } else { | |
520 // TODO(pastarmovj): Add DIR_ROAMING_USER_DATA to PathService to simplify | |
521 // this code and move the logic in its right place. See crbug/657810. | |
522 CHECK( | |
523 base::PathService::Get(base::DIR_APP_DATA, &local_sync_backend_folder)); | |
524 local_sync_backend_folder = | |
525 local_sync_backend_folder.Append(FILE_PATH_LITERAL("Chrome/User Data")); | |
526 } | |
527 local_sync_backend_folder = | |
528 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
| |
529 local_sync_backend_folder = | |
530 local_sync_backend_folder.Append(kLoopbackServerBackendFilename); | |
531 #endif // defined(OS_WIN) | |
532 | |
505 SyncBackendHost::HttpPostProviderFactoryGetter | 533 SyncBackendHost::HttpPostProviderFactoryGetter |
506 http_post_provider_factory_getter = | 534 http_post_provider_factory_getter = |
507 base::Bind(&syncer::NetworkResources::GetHttpPostProviderFactory, | 535 base::Bind(&syncer::NetworkResources::GetHttpPostProviderFactory, |
508 base::Unretained(network_resources_.get()), | 536 base::Unretained(network_resources_.get()), |
509 url_request_context_, network_time_update_callback_); | 537 url_request_context_, network_time_update_callback_); |
510 | 538 |
511 backend_->Initialize( | 539 backend_->Initialize( |
512 this, std::move(sync_thread_), db_thread_, file_thread_, | 540 this, std::move(sync_thread_), db_thread_, file_thread_, |
513 GetJsEventHandler(), sync_service_url_, local_device_->GetSyncUserAgent(), | 541 GetJsEventHandler(), sync_service_url_, local_device_->GetSyncUserAgent(), |
514 credentials, delete_stale_data, | 542 credentials, delete_stale_data, enable_local_sync_backend, |
515 std::unique_ptr<syncer::SyncManagerFactory>( | 543 local_sync_backend_folder, std::unique_ptr<syncer::SyncManagerFactory>( |
516 new syncer::SyncManagerFactory()), | 544 new syncer::SyncManagerFactory()), |
517 MakeWeakHandle(sync_enabled_weak_factory_.GetWeakPtr()), | 545 MakeWeakHandle(sync_enabled_weak_factory_.GetWeakPtr()), |
518 base::Bind(syncer::ReportUnrecoverableError, channel_), | 546 base::Bind(syncer::ReportUnrecoverableError, channel_), |
519 http_post_provider_factory_getter, std::move(saved_nigori_state_)); | 547 http_post_provider_factory_getter, std::move(saved_nigori_state_)); |
520 } | 548 } |
521 | 549 |
522 bool ProfileSyncService::IsEncryptedDatatypeEnabled() const { | 550 bool ProfileSyncService::IsEncryptedDatatypeEnabled() const { |
523 if (encryption_pending()) | 551 if (encryption_pending()) |
524 return true; | 552 return true; |
525 const syncer::ModelTypeSet preferred_types = GetPreferredDataTypes(); | 553 const syncer::ModelTypeSet preferred_types = GetPreferredDataTypes(); |
526 const syncer::ModelTypeSet encrypted_types = GetEncryptedDataTypes(); | 554 const syncer::ModelTypeSet encrypted_types = GetEncryptedDataTypes(); |
(...skipping 1969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2496 | 2524 |
2497 DCHECK(startup_controller_->IsSetupInProgress()); | 2525 DCHECK(startup_controller_->IsSetupInProgress()); |
2498 startup_controller_->SetSetupInProgress(false); | 2526 startup_controller_->SetSetupInProgress(false); |
2499 | 2527 |
2500 if (IsBackendInitialized()) | 2528 if (IsBackendInitialized()) |
2501 ReconfigureDatatypeManager(); | 2529 ReconfigureDatatypeManager(); |
2502 NotifyObservers(); | 2530 NotifyObservers(); |
2503 } | 2531 } |
2504 | 2532 |
2505 } // namespace browser_sync | 2533 } // namespace browser_sync |
OLD | NEW |