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/syncable_service_adapter.h" | 5 #include "chrome/browser/sync/glue/syncable_service_adapter.h" |
6 | 6 |
7 #include "chrome/browser/sync/api/syncable_service.h" | 7 #include "chrome/browser/sync/api/syncable_service.h" |
8 #include "chrome/browser/sync/api/sync_data.h" | 8 #include "chrome/browser/sync/api/sync_data.h" |
9 #include "chrome/browser/sync/glue/generic_change_processor.h" | 9 #include "chrome/browser/sync/glue/generic_change_processor.h" |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 SyncableServiceAdapter::~SyncableServiceAdapter() { | 23 SyncableServiceAdapter::~SyncableServiceAdapter() { |
24 if (syncing_) { | 24 if (syncing_) { |
25 NOTREACHED(); | 25 NOTREACHED(); |
26 LOG(ERROR) << "SyncableServiceAdapter for " | 26 LOG(ERROR) << "SyncableServiceAdapter for " |
27 << syncable::ModelTypeToString(type_) << " destroyed before " | 27 << syncable::ModelTypeToString(type_) << " destroyed before " |
28 << "without being shut down properly."; | 28 << "without being shut down properly."; |
29 service_->StopSyncing(type_); | 29 service_->StopSyncing(type_); |
30 } | 30 } |
31 } | 31 } |
32 | 32 |
33 bool SyncableServiceAdapter::AssociateModels() { | 33 bool SyncableServiceAdapter::AssociateModels(SyncError* error) { |
34 syncing_ = true; | 34 syncing_ = true; |
35 SyncDataList initial_sync_data; | 35 SyncDataList initial_sync_data; |
36 if (!sync_processor_->GetSyncDataForType(type_, &initial_sync_data)) { | 36 SyncError temp_error = |
| 37 sync_processor_->GetSyncDataForType(type_, &initial_sync_data); |
| 38 if (temp_error.IsSet()) { |
| 39 *error = temp_error; |
37 return false; | 40 return false; |
38 } | 41 } |
39 return service_->MergeDataAndStartSyncing(type_, | 42 temp_error = service_->MergeDataAndStartSyncing(type_, |
40 initial_sync_data, | 43 initial_sync_data, |
41 sync_processor_); | 44 sync_processor_); |
| 45 if (temp_error.IsSet()) { |
| 46 *error = temp_error; |
| 47 return false; |
| 48 } |
| 49 return true; |
42 } | 50 } |
43 | 51 |
44 bool SyncableServiceAdapter::DisassociateModels() { | 52 bool SyncableServiceAdapter::DisassociateModels(SyncError* error) { |
45 service_->StopSyncing(type_); | 53 service_->StopSyncing(type_); |
46 syncing_ = false; | 54 syncing_ = false; |
47 return true; | 55 return true; |
48 } | 56 } |
49 | 57 |
50 bool SyncableServiceAdapter::SyncModelHasUserCreatedNodes(bool* has_nodes) { | 58 bool SyncableServiceAdapter::SyncModelHasUserCreatedNodes(bool* has_nodes) { |
51 return sync_processor_->SyncModelHasUserCreatedNodes(type_, has_nodes); | 59 return sync_processor_->SyncModelHasUserCreatedNodes(type_, has_nodes); |
52 } | 60 } |
53 | 61 |
54 void SyncableServiceAdapter::AbortAssociation() { | 62 void SyncableServiceAdapter::AbortAssociation() { |
55 service_->StopSyncing(type_); | 63 service_->StopSyncing(type_); |
56 syncing_ = false; | 64 syncing_ = false; |
57 } | 65 } |
58 | 66 |
59 bool SyncableServiceAdapter::CryptoReadyIfNecessary() { | 67 bool SyncableServiceAdapter::CryptoReadyIfNecessary() { |
60 return sync_processor_->CryptoReadyIfNecessary(type_); | 68 return sync_processor_->CryptoReadyIfNecessary(type_); |
61 } | 69 } |
62 | 70 |
63 } // namespace browser_sync | 71 } // namespace browser_sync |
OLD | NEW |