Chromium Code Reviews| 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/profiler/scoped_tracker.h" | 23 #include "base/profiler/scoped_tracker.h" |
| 24 #include "base/run_loop.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" |
| 33 #include "components/pref_registry/pref_registry_syncable.h" | 34 #include "components/pref_registry/pref_registry_syncable.h" |
| (...skipping 1345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1379 } | 1380 } |
| 1380 | 1381 |
| 1381 bool ProfileSyncService::IsFirstSetupInProgress() const { | 1382 bool ProfileSyncService::IsFirstSetupInProgress() const { |
| 1382 DCHECK(thread_checker_.CalledOnValidThread()); | 1383 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1383 return !IsFirstSetupComplete() && startup_controller_->IsSetupInProgress(); | 1384 return !IsFirstSetupComplete() && startup_controller_->IsSetupInProgress(); |
| 1384 } | 1385 } |
| 1385 | 1386 |
| 1386 std::unique_ptr<syncer::SyncSetupInProgressHandle> | 1387 std::unique_ptr<syncer::SyncSetupInProgressHandle> |
| 1387 ProfileSyncService::GetSetupInProgressHandle() { | 1388 ProfileSyncService::GetSetupInProgressHandle() { |
| 1388 DCHECK(thread_checker_.CalledOnValidThread()); | 1389 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1390 | |
| 1389 if (++outstanding_setup_in_progress_handles_ == 1) { | 1391 if (++outstanding_setup_in_progress_handles_ == 1) { |
| 1390 DCHECK(!startup_controller_->IsSetupInProgress()); | 1392 DCHECK(!startup_controller_->IsSetupInProgress()); |
| 1391 startup_controller_->SetSetupInProgress(true); | 1393 startup_controller_->SetSetupInProgress(true); |
| 1392 | 1394 |
| 1393 NotifyObservers(); | 1395 NotifyObservers(); |
| 1394 } | 1396 } |
| 1395 | 1397 |
| 1396 return std::unique_ptr<syncer::SyncSetupInProgressHandle>( | 1398 return std::unique_ptr<syncer::SyncSetupInProgressHandle>( |
| 1397 new syncer::SyncSetupInProgressHandle( | 1399 new syncer::SyncSetupInProgressHandle( |
| 1398 base::Bind(&ProfileSyncService::OnSetupInProgressHandleDestroyed, | 1400 base::Bind(&ProfileSyncService::OnSetupInProgressHandleDestroyed, |
| (...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2419 return; | 2421 return; |
| 2420 | 2422 |
| 2421 DCHECK(startup_controller_->IsSetupInProgress()); | 2423 DCHECK(startup_controller_->IsSetupInProgress()); |
| 2422 startup_controller_->SetSetupInProgress(false); | 2424 startup_controller_->SetSetupInProgress(false); |
| 2423 | 2425 |
| 2424 if (IsEngineInitialized()) | 2426 if (IsEngineInitialized()) |
| 2425 ReconfigureDatatypeManager(); | 2427 ReconfigureDatatypeManager(); |
| 2426 NotifyObservers(); | 2428 NotifyObservers(); |
| 2427 } | 2429 } |
| 2428 | 2430 |
| 2431 void ProfileSyncService::ClearServerDataForTest(const base::Closure& callback) { | |
| 2432 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 2433 engine_->StartConfiguration(); | |
|
skym
2017/03/07 21:32:25
I was always confused about this, why do you call
wylieb
2017/03/07 23:04:40
This is the only place I call StartConfiguration.
skym
2017/03/08 00:23:48
Heh, sorry, I said "again" because I've asked you
| |
| 2434 engine_->ClearServerData(callback); | |
| 2435 } | |
| 2436 | |
| 2429 } // namespace browser_sync | 2437 } // namespace browser_sync |
| OLD | NEW |