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

Side by Side Diff: sync/internal_api/sync_rollback_manager_base.cc

Issue 363543002: Properly handle initialization failure and following manager shutdown without (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "sync/internal_api/sync_rollback_manager_base.h" 5 #include "sync/internal_api/sync_rollback_manager_base.h"
6 6
7 #include "sync/internal_api/public/base/model_type.h" 7 #include "sync/internal_api/public/base/model_type.h"
8 #include "sync/internal_api/public/internal_components_factory.h" 8 #include "sync/internal_api/public/internal_components_factory.h"
9 #include "sync/internal_api/public/read_node.h" 9 #include "sync/internal_api/public/read_node.h"
10 #include "sync/internal_api/public/read_transaction.h" 10 #include "sync/internal_api/public/read_transaction.h"
(...skipping 25 matching lines...) Expand all
36 } 36 }
37 }; 37 };
38 38
39 } // anonymous namespace 39 } // anonymous namespace
40 40
41 namespace syncer { 41 namespace syncer {
42 42
43 SyncRollbackManagerBase::SyncRollbackManagerBase() 43 SyncRollbackManagerBase::SyncRollbackManagerBase()
44 : report_unrecoverable_error_function_(NULL), 44 : report_unrecoverable_error_function_(NULL),
45 weak_ptr_factory_(this), 45 weak_ptr_factory_(this),
46 dummy_handler_(new DummyEntryptionHandler) { 46 dummy_handler_(new DummyEntryptionHandler),
47 initialized_(false) {
47 } 48 }
48 49
49 SyncRollbackManagerBase::~SyncRollbackManagerBase() { 50 SyncRollbackManagerBase::~SyncRollbackManagerBase() {
50 } 51 }
51 52
52 void SyncRollbackManagerBase::Init( 53 void SyncRollbackManagerBase::Init(
53 const base::FilePath& database_location, 54 const base::FilePath& database_location,
54 const WeakHandle<JsEventHandler>& event_handler, 55 const WeakHandle<JsEventHandler>& event_handler,
55 const std::string& sync_server_and_path, 56 const std::string& sync_server_and_path,
56 int sync_server_port, 57 int sync_server_port,
(...skipping 13 matching lines...) Expand all
70 report_unrecoverable_error_function, 71 report_unrecoverable_error_function,
71 CancelationSignal* cancelation_signal) { 72 CancelationSignal* cancelation_signal) {
72 unrecoverable_error_handler_ = unrecoverable_error_handler.Pass(); 73 unrecoverable_error_handler_ = unrecoverable_error_handler.Pass();
73 report_unrecoverable_error_function_ = report_unrecoverable_error_function; 74 report_unrecoverable_error_function_ = report_unrecoverable_error_function;
74 75
75 if (!InitBackupDB(database_location, internal_components_factory)) { 76 if (!InitBackupDB(database_location, internal_components_factory)) {
76 NotifyInitializationFailure(); 77 NotifyInitializationFailure();
77 return; 78 return;
78 } 79 }
79 80
81 initialized_ = true;
80 NotifyInitializationSuccess(); 82 NotifyInitializationSuccess();
81 } 83 }
82 84
83 ModelTypeSet SyncRollbackManagerBase::InitialSyncEndedTypes() { 85 ModelTypeSet SyncRollbackManagerBase::InitialSyncEndedTypes() {
84 return share_.directory->InitialSyncEndedTypes(); 86 return share_.directory->InitialSyncEndedTypes();
85 } 87 }
86 88
87 ModelTypeSet SyncRollbackManagerBase::GetTypesWithEmptyProgressMarkerToken( 89 ModelTypeSet SyncRollbackManagerBase::GetTypesWithEmptyProgressMarkerToken(
88 ModelTypeSet types) { 90 ModelTypeSet types) {
89 ModelTypeSet inited_types = share_.directory->InitialSyncEndedTypes(); 91 ModelTypeSet inited_types = share_.directory->InitialSyncEndedTypes();
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 } 146 }
145 147
146 SyncStatus SyncRollbackManagerBase::GetDetailedStatus() const { 148 SyncStatus SyncRollbackManagerBase::GetDetailedStatus() const {
147 return SyncStatus(); 149 return SyncStatus();
148 } 150 }
149 151
150 void SyncRollbackManagerBase::SaveChanges() { 152 void SyncRollbackManagerBase::SaveChanges() {
151 } 153 }
152 154
153 void SyncRollbackManagerBase::ShutdownOnSyncThread() { 155 void SyncRollbackManagerBase::ShutdownOnSyncThread() {
154 if (share_.directory) { 156 if (initialized_) {
155 SaveChanges(); 157 SaveChanges();
156 share_.directory->Close(); 158 share_.directory->Close();
157 share_.directory.reset(); 159 share_.directory.reset();
160 initialized_ = false;
158 } 161 }
159 } 162 }
160 163
161 UserShare* SyncRollbackManagerBase::GetUserShare() { 164 UserShare* SyncRollbackManagerBase::GetUserShare() {
162 return &share_; 165 return &share_;
163 } 166 }
164 167
165 const std::string SyncRollbackManagerBase::cache_guid() { 168 const std::string SyncRollbackManagerBase::cache_guid() {
166 return share_.directory->cache_guid(); 169 return share_.directory->cache_guid();
167 } 170 }
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 340
338 void SyncRollbackManagerBase::UnregisterDirectoryTypeDebugInfoObserver( 341 void SyncRollbackManagerBase::UnregisterDirectoryTypeDebugInfoObserver(
339 syncer::TypeDebugInfoObserver* observer) {} 342 syncer::TypeDebugInfoObserver* observer) {}
340 343
341 bool SyncRollbackManagerBase::HasDirectoryTypeDebugInfoObserver( 344 bool SyncRollbackManagerBase::HasDirectoryTypeDebugInfoObserver(
342 syncer::TypeDebugInfoObserver* observer) { return false; } 345 syncer::TypeDebugInfoObserver* observer) { return false; }
343 346
344 void SyncRollbackManagerBase::RequestEmitDebugInfo() {} 347 void SyncRollbackManagerBase::RequestEmitDebugInfo() {}
345 348
346 } // namespace syncer 349 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/internal_api/sync_rollback_manager_base.h ('k') | sync/internal_api/sync_rollback_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698