| 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 "chrome/browser/sync/profile_sync_service.h" | 5 #include "chrome/browser/sync/profile_sync_service.h" |
| 6 | 6 |
| 7 #include <cstddef> | 7 #include <cstddef> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
| 16 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
| 17 #include "base/logging.h" | 17 #include "base/logging.h" |
| 18 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
| 19 #include "base/message_loop.h" | 19 #include "base/message_loop.h" |
| 20 #include "base/metrics/histogram.h" | 20 #include "base/metrics/histogram.h" |
| 21 #include "base/string16.h" | 21 #include "base/string16.h" |
| 22 #include "base/stringprintf.h" | 22 #include "base/stringprintf.h" |
| 23 #include "base/threading/thread_restrictions.h" | 23 #include "base/threading/thread_restrictions.h" |
| 24 #include "build/build_config.h" | 24 #include "build/build_config.h" |
| 25 #include "chrome/browser/about_flags.h" | 25 #include "chrome/browser/about_flags.h" |
| 26 #include "chrome/browser/browser_process.h" | 26 #include "chrome/browser/browser_process.h" |
| 27 #include "chrome/browser/defaults.h" | 27 #include "chrome/browser/defaults.h" |
| 28 #include "chrome/browser/extensions/extension_service.h" | |
| 29 #include "chrome/browser/extensions/extension_system.h" | |
| 30 #include "chrome/browser/net/chrome_cookie_notification_details.h" | 28 #include "chrome/browser/net/chrome_cookie_notification_details.h" |
| 31 #include "chrome/browser/prefs/pref_service.h" | 29 #include "chrome/browser/prefs/pref_service.h" |
| 32 #include "chrome/browser/profiles/profile.h" | 30 #include "chrome/browser/profiles/profile.h" |
| 33 #include "chrome/browser/signin/signin_manager.h" | 31 #include "chrome/browser/signin/signin_manager.h" |
| 34 #include "chrome/browser/signin/signin_manager_factory.h" | 32 #include "chrome/browser/signin/signin_manager_factory.h" |
| 35 #include "chrome/browser/signin/token_service.h" | 33 #include "chrome/browser/signin/token_service.h" |
| 36 #include "chrome/browser/signin/token_service_factory.h" | 34 #include "chrome/browser/signin/token_service_factory.h" |
| 37 #include "chrome/browser/sync/backend_migrator.h" | 35 #include "chrome/browser/sync/backend_migrator.h" |
| 38 #include "chrome/browser/sync/glue/change_processor.h" | 36 #include "chrome/browser/sync/glue/change_processor.h" |
| 39 #include "chrome/browser/sync/glue/chrome_encryptor.h" | 37 #include "chrome/browser/sync/glue/chrome_encryptor.h" |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 syncer::ObjectIdSet notify_ids; | 508 syncer::ObjectIdSet notify_ids; |
| 511 notify_ids.insert(id); | 509 notify_ids.insert(id); |
| 512 | 510 |
| 513 const syncer::ObjectIdInvalidationMap& invalidation_map = | 511 const syncer::ObjectIdInvalidationMap& invalidation_map = |
| 514 ObjectIdSetToInvalidationMap(notify_ids, payload); | 512 ObjectIdSetToInvalidationMap(notify_ids, payload); |
| 515 OnIncomingInvalidation(invalidation_map, syncer::REMOTE_INVALIDATION); | 513 OnIncomingInvalidation(invalidation_map, syncer::REMOTE_INVALIDATION); |
| 516 } | 514 } |
| 517 | 515 |
| 518 void ProfileSyncService::Shutdown() { | 516 void ProfileSyncService::Shutdown() { |
| 519 DCHECK(invalidator_registrar_.get()); | 517 DCHECK(invalidator_registrar_.get()); |
| 520 // TODO(akalin): Remove this once http://crbug.com/153827 is fixed. | |
| 521 ExtensionService* const extension_service = | |
| 522 extensions::ExtensionSystem::Get(profile_)->extension_service(); | |
| 523 // |extension_service| may be NULL if it was never initialized | |
| 524 // (e.g., extension sync wasn't enabled in tests). | |
| 525 if (extension_service) | |
| 526 extension_service->OnProfileSyncServiceShutdown(); | |
| 527 | |
| 528 // Reset |invalidator_registrar_| first so that ShutdownImpl cannot | 518 // Reset |invalidator_registrar_| first so that ShutdownImpl cannot |
| 529 // use it. | 519 // use it. |
| 530 invalidator_registrar_.reset(); | 520 invalidator_registrar_.reset(); |
| 531 | 521 |
| 532 ShutdownImpl(false); | 522 ShutdownImpl(false); |
| 533 } | 523 } |
| 534 | 524 |
| 535 void ProfileSyncService::ShutdownImpl(bool sync_disabled) { | 525 void ProfileSyncService::ShutdownImpl(bool sync_disabled) { |
| 536 // First, we spin down the backend and wait for it to stop syncing completely | 526 // First, we spin down the backend and wait for it to stop syncing completely |
| 537 // before we Stop the data type manager. This is to avoid a late sync cycle | 527 // before we Stop the data type manager. This is to avoid a late sync cycle |
| (...skipping 1368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1906 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine
d-behaviour-after-directly-calling-the-destru. | 1896 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine
d-behaviour-after-directly-calling-the-destru. |
| 1907 ProfileSyncService* old_this = this; | 1897 ProfileSyncService* old_this = this; |
| 1908 this->~ProfileSyncService(); | 1898 this->~ProfileSyncService(); |
| 1909 new(old_this) ProfileSyncService( | 1899 new(old_this) ProfileSyncService( |
| 1910 new ProfileSyncComponentsFactoryImpl(profile, | 1900 new ProfileSyncComponentsFactoryImpl(profile, |
| 1911 CommandLine::ForCurrentProcess()), | 1901 CommandLine::ForCurrentProcess()), |
| 1912 profile, | 1902 profile, |
| 1913 signin, | 1903 signin, |
| 1914 behavior); | 1904 behavior); |
| 1915 } | 1905 } |
| OLD | NEW |