| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/api/sync_change.h" | 7 #include "chrome/browser/sync/api/sync_change.h" |
| 8 #include "chrome/browser/sync/glue/generic_change_processor.h" | 8 #include "chrome/browser/sync/glue/generic_change_processor.h" |
| 9 #include "chrome/browser/sync/profile_sync_factory.h" | 9 #include "chrome/browser/sync/profile_sync_components_factory.h" |
| 10 #include "chrome/browser/sync/profile_sync_service.h" | 10 #include "chrome/browser/sync/profile_sync_service.h" |
| 11 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.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 // We're always created on the UI thread. | 20 // We're always created on the UI thread. |
| 21 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 21 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 22 DetachFromThread(); | 22 DetachFromThread(); |
| 23 } | 23 } |
| 24 | 24 |
| 25 SharedChangeProcessor::~SharedChangeProcessor() { | 25 SharedChangeProcessor::~SharedChangeProcessor() { |
| 26 // We can either be deleted when the DTC is destroyed (on UI thread), | 26 // We can either be deleted when the DTC is destroyed (on UI thread), |
| 27 // or when the SyncableService stop's syncing (datatype thread). | 27 // or when the SyncableService stop's syncing (datatype thread). |
| 28 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || | 28 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || |
| 29 CalledOnValidThread()); | 29 CalledOnValidThread()); |
| 30 DetachFromThread(); | 30 DetachFromThread(); |
| 31 } | 31 } |
| 32 | 32 |
| 33 bool SharedChangeProcessor::Connect( | 33 bool SharedChangeProcessor::Connect( |
| 34 ProfileSyncFactory* sync_factory, | 34 ProfileSyncComponentsFactory* sync_factory, |
| 35 ProfileSyncService* sync_service, | 35 ProfileSyncService* sync_service, |
| 36 UnrecoverableErrorHandler* error_handler, | 36 UnrecoverableErrorHandler* error_handler, |
| 37 const base::WeakPtr<SyncableService>& local_service) { | 37 const base::WeakPtr<SyncableService>& local_service) { |
| 38 DCHECK(CalledOnValidThread()); | 38 DCHECK(CalledOnValidThread()); |
| 39 AutoLock lock(monitor_lock_); | 39 AutoLock lock(monitor_lock_); |
| 40 if (disconnected_) | 40 if (disconnected_) |
| 41 return false; | 41 return false; |
| 42 if (!local_service) { | 42 if (!local_service) { |
| 43 NOTREACHED() << "SyncableService destroyed before DTC was stopped."; | 43 NOTREACHED() << "SyncableService destroyed before DTC was stopped."; |
| 44 disconnected_ = true; | 44 disconnected_ = true; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 AutoLock lock(monitor_lock_); | 121 AutoLock lock(monitor_lock_); |
| 122 if (disconnected_) { | 122 if (disconnected_) { |
| 123 LOG(ERROR) << "Change processor disconnected."; | 123 LOG(ERROR) << "Change processor disconnected."; |
| 124 return; | 124 return; |
| 125 } | 125 } |
| 126 sync_service->ActivateDataType( | 126 sync_service->ActivateDataType( |
| 127 model_type, model_safe_group, generic_change_processor_.get()); | 127 model_type, model_safe_group, generic_change_processor_.get()); |
| 128 } | 128 } |
| 129 | 129 |
| 130 } // namespace browser_sync | 130 } // namespace browser_sync |
| OLD | NEW |