| 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/glue/shared_change_processor.h" | 5 #include "chrome/browser/sync/glue/shared_change_processor.h" |
| 6 | 6 |
| 7 #include "chrome/browser/sync/glue/generic_change_processor.h" | 7 #include "chrome/browser/sync/glue/generic_change_processor.h" |
| 8 #include "chrome/browser/sync/profile_sync_components_factory.h" | 8 #include "chrome/browser/sync/profile_sync_components_factory.h" |
| 9 #include "chrome/browser/sync/profile_sync_service.h" | 9 #include "chrome/browser/sync/profile_sync_service.h" |
| 10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
| 11 #include "sync/api/sync_change.h" | 11 #include "sync/api/sync_change.h" |
| 12 | 12 |
| 13 using base::AutoLock; | 13 using base::AutoLock; |
| 14 using content::BrowserThread; | 14 using content::BrowserThread; |
| 15 | 15 |
| 16 namespace browser_sync { | 16 namespace browser_sync { |
| 17 | 17 |
| 18 SharedChangeProcessor::SharedChangeProcessor() | 18 SharedChangeProcessor::SharedChangeProcessor() |
| 19 : disconnected_(false), | 19 : disconnected_(false), |
| 20 type_(syncable::UNSPECIFIED), | 20 type_(syncer::UNSPECIFIED), |
| 21 sync_service_(NULL), | 21 sync_service_(NULL), |
| 22 generic_change_processor_(NULL), | 22 generic_change_processor_(NULL), |
| 23 error_handler_(NULL) { | 23 error_handler_(NULL) { |
| 24 // We're always created on the UI thread. | 24 // We're always created on the UI thread. |
| 25 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 25 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 26 } | 26 } |
| 27 | 27 |
| 28 SharedChangeProcessor::~SharedChangeProcessor() { | 28 SharedChangeProcessor::~SharedChangeProcessor() { |
| 29 // We can either be deleted when the DTC is destroyed (on UI | 29 // We can either be deleted when the DTC is destroyed (on UI |
| 30 // thread), or when the syncer::SyncableService stop's syncing (datatype | 30 // thread), or when the syncer::SyncableService stop's syncing (datatype |
| (...skipping 11 matching lines...) Expand all Loading... |
| 42 DCHECK(backend_loop_.get()); | 42 DCHECK(backend_loop_.get()); |
| 43 DCHECK(backend_loop_->BelongsToCurrentThread()); | 43 DCHECK(backend_loop_->BelongsToCurrentThread()); |
| 44 delete generic_change_processor_; | 44 delete generic_change_processor_; |
| 45 } | 45 } |
| 46 } | 46 } |
| 47 | 47 |
| 48 base::WeakPtr<syncer::SyncableService> SharedChangeProcessor::Connect( | 48 base::WeakPtr<syncer::SyncableService> SharedChangeProcessor::Connect( |
| 49 ProfileSyncComponentsFactory* sync_factory, | 49 ProfileSyncComponentsFactory* sync_factory, |
| 50 ProfileSyncService* sync_service, | 50 ProfileSyncService* sync_service, |
| 51 DataTypeErrorHandler* error_handler, | 51 DataTypeErrorHandler* error_handler, |
| 52 syncable::ModelType type) { | 52 syncer::ModelType type) { |
| 53 DCHECK(sync_factory); | 53 DCHECK(sync_factory); |
| 54 DCHECK(sync_service); | 54 DCHECK(sync_service); |
| 55 DCHECK(error_handler); | 55 DCHECK(error_handler); |
| 56 DCHECK_NE(type, syncable::UNSPECIFIED); | 56 DCHECK_NE(type, syncer::UNSPECIFIED); |
| 57 backend_loop_ = base::MessageLoopProxy::current(); | 57 backend_loop_ = base::MessageLoopProxy::current(); |
| 58 AutoLock lock(monitor_lock_); | 58 AutoLock lock(monitor_lock_); |
| 59 if (disconnected_) | 59 if (disconnected_) |
| 60 return base::WeakPtr<syncer::SyncableService>(); | 60 return base::WeakPtr<syncer::SyncableService>(); |
| 61 type_ = type; | 61 type_ = type; |
| 62 sync_service_ = sync_service; | 62 sync_service_ = sync_service; |
| 63 error_handler_ = error_handler; | 63 error_handler_ = error_handler; |
| 64 base::WeakPtr<syncer::SyncableService> local_service = | 64 base::WeakPtr<syncer::SyncableService> local_service = |
| 65 sync_factory->GetSyncableServiceForType(type); | 65 sync_factory->GetSyncableServiceForType(type); |
| 66 if (!local_service.get()) { | 66 if (!local_service.get()) { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 const std::string& message) { | 156 const std::string& message) { |
| 157 AutoLock lock(monitor_lock_); | 157 AutoLock lock(monitor_lock_); |
| 158 if (!disconnected_) { | 158 if (!disconnected_) { |
| 159 return error_handler_->CreateAndUploadError(location, message, type_); | 159 return error_handler_->CreateAndUploadError(location, message, type_); |
| 160 } else { | 160 } else { |
| 161 return syncer::SyncError(location, message, type_); | 161 return syncer::SyncError(location, message, type_); |
| 162 } | 162 } |
| 163 } | 163 } |
| 164 | 164 |
| 165 } // namespace browser_sync | 165 } // namespace browser_sync |
| OLD | NEW |