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

Side by Side Diff: chrome/browser/sync/glue/sync_backend_host.cc

Issue 10830100: Fix SyncManager initialization failure crash. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add virtual destructor Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/sync/profile_sync_service_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #include "chrome/browser/sync/glue/sync_backend_host.h" 7 #include "chrome/browser/sync/glue/sync_backend_host.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <map> 10 #include <map>
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 &SyncBackendHost::HandleSyncCycleCompletedOnFrontendLoop, 839 &SyncBackendHost::HandleSyncCycleCompletedOnFrontendLoop,
840 snapshot); 840 snapshot);
841 } 841 }
842 842
843 843
844 void SyncBackendHost::Core::OnInitializationComplete( 844 void SyncBackendHost::Core::OnInitializationComplete(
845 const syncer::WeakHandle<syncer::JsBackend>& js_backend, 845 const syncer::WeakHandle<syncer::JsBackend>& js_backend,
846 bool success, 846 bool success,
847 const syncer::ModelTypeSet restored_types) { 847 const syncer::ModelTypeSet restored_types) {
848 DCHECK_EQ(MessageLoop::current(), sync_loop_); 848 DCHECK_EQ(MessageLoop::current(), sync_loop_);
849
850 if (!success) {
851 sync_manager_->RemoveObserver(this);
852 sync_manager_->ShutdownOnSyncThread();
853 sync_manager_.reset();
854 }
855
849 host_.Call( 856 host_.Call(
850 FROM_HERE, 857 FROM_HERE,
851 &SyncBackendHost::HandleSyncManagerInitializationOnFrontendLoop, 858 &SyncBackendHost::HandleSyncManagerInitializationOnFrontendLoop,
852 js_backend, success, restored_types); 859 js_backend, success, restored_types);
853 860
854 if (success) { 861 if (success) {
855 // Initialization is complete, so we can schedule recurring SaveChanges. 862 // Initialization is complete, so we can schedule recurring SaveChanges.
856 sync_loop_->PostTask(FROM_HERE, 863 sync_loop_->PostTask(FROM_HERE,
857 base::Bind(&Core::StartSavingChanges, this)); 864 base::Bind(&Core::StartSavingChanges, this));
858 } 865 }
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1044 void SyncBackendHost::Core::DoRefreshNigori( 1051 void SyncBackendHost::Core::DoRefreshNigori(
1045 const base::Closure& done_callback) { 1052 const base::Closure& done_callback) {
1046 DCHECK_EQ(MessageLoop::current(), sync_loop_); 1053 DCHECK_EQ(MessageLoop::current(), sync_loop_);
1047 chrome::VersionInfo version_info; 1054 chrome::VersionInfo version_info;
1048 sync_manager_->RefreshNigori(version_info.CreateVersionString(), 1055 sync_manager_->RefreshNigori(version_info.CreateVersionString(),
1049 done_callback); 1056 done_callback);
1050 } 1057 }
1051 1058
1052 void SyncBackendHost::Core::DoStopSyncManagerForShutdown( 1059 void SyncBackendHost::Core::DoStopSyncManagerForShutdown(
1053 const base::Closure& closure) { 1060 const base::Closure& closure) {
1054 DCHECK(sync_manager_.get()); 1061 if (sync_manager_.get()) {
1055 sync_manager_->StopSyncingForShutdown(closure); 1062 sync_manager_->StopSyncingForShutdown(closure);
1063 } else {
1064 sync_loop_->PostTask(FROM_HERE, closure);
1065 }
1056 } 1066 }
1057 1067
1058 void SyncBackendHost::Core::DoShutdown(bool sync_disabled) { 1068 void SyncBackendHost::Core::DoShutdown(bool sync_disabled) {
1059 DCHECK_EQ(MessageLoop::current(), sync_loop_); 1069 DCHECK_EQ(MessageLoop::current(), sync_loop_);
1060 if (!sync_manager_.get()) 1070 if (sync_manager_.get()) {
1061 return; 1071 save_changes_timer_.reset();
1072 sync_manager_->ShutdownOnSyncThread();
1073 sync_manager_->RemoveObserver(this);
1074 sync_manager_.reset();
1075 }
1062 1076
1063 save_changes_timer_.reset();
1064 sync_manager_->ShutdownOnSyncThread();
1065 sync_manager_->RemoveObserver(this);
1066 sync_manager_.reset();
1067 chrome_sync_notification_bridge_ = NULL; 1077 chrome_sync_notification_bridge_ = NULL;
1068 registrar_ = NULL; 1078 registrar_ = NULL;
1069 1079
1070 if (sync_disabled) 1080 if (sync_disabled)
1071 DeleteSyncDataFolder(); 1081 DeleteSyncDataFolder();
1072 1082
1073 sync_loop_ = NULL; 1083 sync_loop_ = NULL;
1074 1084
1075 host_.Reset(); 1085 host_.Reset();
1076 } 1086 }
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
1379 FROM_HERE, 1389 FROM_HERE,
1380 base::Bind(&SyncBackendHost::Core::DoRefreshNigori, 1390 base::Bind(&SyncBackendHost::Core::DoRefreshNigori,
1381 core_.get(), sync_thread_done_callback)); 1391 core_.get(), sync_thread_done_callback));
1382 } 1392 }
1383 1393
1384 #undef SDVLOG 1394 #undef SDVLOG
1385 1395
1386 #undef SLOG 1396 #undef SLOG
1387 1397
1388 } // namespace browser_sync 1398 } // namespace browser_sync
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/sync/profile_sync_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698