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

Side by Side Diff: chrome/browser/sync/profile_sync_service.cc

Issue 1406943004: [sync] Isolate FOREIGN_SESSION_UPDATED notification in ProfileSyncService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 unified diff | Download patch
OLDNEW
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 <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/bind_helpers.h" 13 #include "base/bind_helpers.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/files/file_util.h" 17 #include "base/files/file_util.h"
18 #include "base/logging.h" 18 #include "base/logging.h"
19 #include "base/memory/ref_counted.h" 19 #include "base/memory/ref_counted.h"
20 #include "base/metrics/histogram.h" 20 #include "base/metrics/histogram.h"
21 #include "base/profiler/scoped_tracker.h" 21 #include "base/profiler/scoped_tracker.h"
22 #include "base/single_thread_task_runner.h" 22 #include "base/single_thread_task_runner.h"
23 #include "base/strings/string16.h" 23 #include "base/strings/string16.h"
24 #include "base/strings/stringprintf.h" 24 #include "base/strings/stringprintf.h"
25 #include "base/thread_task_runner_handle.h" 25 #include "base/thread_task_runner_handle.h"
26 #include "base/threading/thread_restrictions.h" 26 #include "base/threading/thread_restrictions.h"
27 #include "base/time/time.h" 27 #include "base/time/time.h"
28 #include "build/build_config.h" 28 #include "build/build_config.h"
29 #include "chrome/browser/browsing_data/browsing_data_helper.h" 29 #include "chrome/browser/browsing_data/browsing_data_helper.h"
30 #include "chrome/browser/chrome_notification_types.h"
30 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" 31 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h"
31 #include "chrome/browser/password_manager/password_store_factory.h" 32 #include "chrome/browser/password_manager/password_store_factory.h"
32 #include "chrome/browser/profiles/profile.h" 33 #include "chrome/browser/profiles/profile.h"
33 #include "chrome/browser/signin/chrome_signin_client_factory.h" 34 #include "chrome/browser/signin/chrome_signin_client_factory.h"
34 #include "chrome/browser/signin/signin_manager_factory.h" 35 #include "chrome/browser/signin/signin_manager_factory.h"
35 #include "chrome/browser/sync/glue/sync_backend_host.h" 36 #include "chrome/browser/sync/glue/sync_backend_host.h"
36 #include "chrome/browser/sync/glue/sync_backend_host_impl.h" 37 #include "chrome/browser/sync/glue/sync_backend_host_impl.h"
37 #include "chrome/browser/sync/supervised_user_signin_manager_wrapper.h" 38 #include "chrome/browser/sync/supervised_user_signin_manager_wrapper.h"
38 #include "chrome/browser/sync/sync_type_preference_provider.h" 39 #include "chrome/browser/sync/sync_type_preference_provider.h"
39 #include "chrome/common/channel_info.h" 40 #include "chrome/common/channel_info.h"
(...skipping 22 matching lines...) Expand all
62 #include "components/sync_driver/sync_error_controller.h" 63 #include "components/sync_driver/sync_error_controller.h"
63 #include "components/sync_driver/sync_stopped_reporter.h" 64 #include "components/sync_driver/sync_stopped_reporter.h"
64 #include "components/sync_driver/sync_util.h" 65 #include "components/sync_driver/sync_util.h"
65 #include "components/sync_driver/system_encryptor.h" 66 #include "components/sync_driver/system_encryptor.h"
66 #include "components/sync_driver/user_selectable_sync_type.h" 67 #include "components/sync_driver/user_selectable_sync_type.h"
67 #include "components/sync_sessions/favicon_cache.h" 68 #include "components/sync_sessions/favicon_cache.h"
68 #include "components/sync_sessions/sync_sessions_client.h" 69 #include "components/sync_sessions/sync_sessions_client.h"
69 #include "components/syncable_prefs/pref_service_syncable.h" 70 #include "components/syncable_prefs/pref_service_syncable.h"
70 #include "components/version_info/version_info_values.h" 71 #include "components/version_info/version_info_values.h"
71 #include "content/public/browser/browser_thread.h" 72 #include "content/public/browser/browser_thread.h"
73 #include "content/public/browser/notification_details.h"
74 #include "content/public/browser/notification_service.h"
75 #include "content/public/browser/notification_source.h"
72 #include "net/cookies/cookie_monster.h" 76 #include "net/cookies/cookie_monster.h"
73 #include "net/url_request/url_request_context_getter.h" 77 #include "net/url_request/url_request_context_getter.h"
74 #include "sync/api/sync_error.h" 78 #include "sync/api/sync_error.h"
75 #include "sync/internal_api/public/configure_reason.h" 79 #include "sync/internal_api/public/configure_reason.h"
76 #include "sync/internal_api/public/http_bridge_network_resources.h" 80 #include "sync/internal_api/public/http_bridge_network_resources.h"
77 #include "sync/internal_api/public/network_resources.h" 81 #include "sync/internal_api/public/network_resources.h"
78 #include "sync/internal_api/public/sessions/type_debug_info_observer.h" 82 #include "sync/internal_api/public/sessions/type_debug_info_observer.h"
79 #include "sync/internal_api/public/shutdown_reason.h" 83 #include "sync/internal_api/public/shutdown_reason.h"
80 #include "sync/internal_api/public/sync_encryption_handler.h" 84 #include "sync/internal_api/public/sync_encryption_handler.h"
81 #include "sync/internal_api/public/util/experiments.h" 85 #include "sync/internal_api/public/util/experiments.h"
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 scoped_ptr<browser_sync::LocalSessionEventRouter> router( 260 scoped_ptr<browser_sync::LocalSessionEventRouter> router(
257 sync_client_->GetSyncSessionsClient()->GetLocalSessionEventRouter()); 261 sync_client_->GetSyncSessionsClient()->GetLocalSessionEventRouter());
258 local_device_ = sync_client_->GetSyncApiComponentFactory() 262 local_device_ = sync_client_->GetSyncApiComponentFactory()
259 ->CreateLocalDeviceInfoProvider(); 263 ->CreateLocalDeviceInfoProvider();
260 sync_stopped_reporter_.reset( 264 sync_stopped_reporter_.reset(
261 new browser_sync::SyncStoppedReporter( 265 new browser_sync::SyncStoppedReporter(
262 sync_service_url_, 266 sync_service_url_,
263 local_device_->GetSyncUserAgent(), 267 local_device_->GetSyncUserAgent(),
264 profile_->GetRequestContext(), 268 profile_->GetRequestContext(),
265 browser_sync::SyncStoppedReporter::ResultCallback())); 269 browser_sync::SyncStoppedReporter::ResultCallback()));
270
271 registrar_.Add(this, chrome::NOTIFICATION_FOREIGN_SESSION_UPDATED,
272 content::Source<Profile>(profile));
266 sessions_sync_manager_.reset( 273 sessions_sync_manager_.reset(
267 new SessionsSyncManager(sync_client_->GetSyncSessionsClient(), profile, 274 new SessionsSyncManager(sync_client_->GetSyncSessionsClient(), profile,
268 local_device_.get(), router.Pass())); 275 local_device_.get(), router.Pass()));
269 device_info_sync_service_.reset( 276 device_info_sync_service_.reset(
270 new DeviceInfoSyncService(local_device_.get())); 277 new DeviceInfoSyncService(local_device_.get()));
271 278
272 std::string last_version = sync_prefs_.GetLastRunVersion(); 279 std::string last_version = sync_prefs_.GetLastRunVersion();
273 std::string current_version = PRODUCT_VERSION; 280 std::string current_version = PRODUCT_VERSION;
274 sync_prefs_.SetLastRunVersion(current_version); 281 sync_prefs_.SetLastRunVersion(current_version);
275 282
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 // Revert to "no auth error". 910 // Revert to "no auth error".
904 if (last_auth_error_.state() != GoogleServiceAuthError::NONE) 911 if (last_auth_error_.state() != GoogleServiceAuthError::NONE)
905 UpdateAuthErrorState(GoogleServiceAuthError::AuthErrorNone()); 912 UpdateAuthErrorState(GoogleServiceAuthError::AuthErrorNone());
906 913
907 NotifyObservers(); 914 NotifyObservers();
908 915
909 // Mark this as a clean shutdown(without crash). 916 // Mark this as a clean shutdown(without crash).
910 sync_prefs_.SetCleanShutdown(true); 917 sync_prefs_.SetCleanShutdown(true);
911 } 918 }
912 919
920 void ProfileSyncService::Observe(
921 int type, const content::NotificationSource& source,
922 const content::NotificationDetails& details) {
923 DCHECK_EQ(chrome::NOTIFICATION_FOREIGN_SESSION_UPDATED, type);
924 FOR_EACH_OBSERVER(sync_driver::SyncServiceObserver, observers_,
925 OnForeignSessionUpdated());
926 }
927
913 void ProfileSyncService::StopImpl(SyncStopDataFate data_fate) { 928 void ProfileSyncService::StopImpl(SyncStopDataFate data_fate) {
914 switch (data_fate) { 929 switch (data_fate) {
915 case KEEP_DATA: 930 case KEEP_DATA:
916 // TODO(maxbogue): Investigate whether this logic can/should be moved 931 // TODO(maxbogue): Investigate whether this logic can/should be moved
917 // into ShutdownImpl or SyncBackendHost itself. 932 // into ShutdownImpl or SyncBackendHost itself.
918 if (HasSyncingBackend()) { 933 if (HasSyncingBackend()) {
919 backend_->UnregisterInvalidationIds(); 934 backend_->UnregisterInvalidationIds();
920 } 935 }
921 ShutdownImpl(syncer::STOP_SYNC); 936 ShutdownImpl(syncer::STOP_SYNC);
922 break; 937 break;
(...skipping 1798 matching lines...) Expand 10 before | Expand all | Expand 10 after
2721 } 2736 }
2722 2737
2723 std::string ProfileSyncService::unrecoverable_error_message() const { 2738 std::string ProfileSyncService::unrecoverable_error_message() const {
2724 return unrecoverable_error_message_; 2739 return unrecoverable_error_message_;
2725 } 2740 }
2726 2741
2727 tracked_objects::Location ProfileSyncService::unrecoverable_error_location() 2742 tracked_objects::Location ProfileSyncService::unrecoverable_error_location()
2728 const { 2743 const {
2729 return unrecoverable_error_location_; 2744 return unrecoverable_error_location_;
2730 } 2745 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_service.h ('k') | chrome/browser/ui/webui/foreign_session_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698