| 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 #ifndef CHROME_BROWSER_SYNC_GLUE_GENERIC_CHANGE_PROCESSOR_H_ | 5 #ifndef CHROME_BROWSER_SYNC_GLUE_GENERIC_CHANGE_PROCESSOR_H_ |
| 6 #define CHROME_BROWSER_SYNC_GLUE_GENERIC_CHANGE_PROCESSOR_H_ | 6 #define CHROME_BROWSER_SYNC_GLUE_GENERIC_CHANGE_PROCESSOR_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/threading/non_thread_safe.h" | 12 #include "base/threading/non_thread_safe.h" |
| 13 #include "chrome/browser/sync/glue/change_processor.h" | 13 #include "chrome/browser/sync/glue/change_processor.h" |
| 14 #include "components/sync_driver/data_type_controller.h" | 14 #include "components/sync_driver/data_type_controller.h" |
| 15 #include "components/sync_driver/data_type_error_handler.h" | 15 #include "components/sync_driver/data_type_error_handler.h" |
| 16 #include "sync/api/attachments/attachment_service.h" |
| 17 #include "sync/api/attachments/attachment_service_proxy.h" |
| 16 #include "sync/api/sync_change_processor.h" | 18 #include "sync/api/sync_change_processor.h" |
| 17 #include "sync/api/sync_merge_result.h" | 19 #include "sync/api/sync_merge_result.h" |
| 18 | 20 |
| 19 namespace syncer { | 21 namespace syncer { |
| 20 class SyncData; | 22 class SyncData; |
| 21 class SyncableService; | 23 class SyncableService; |
| 22 class WriteNode; | 24 class WriteNode; |
| 23 class WriteTransaction; | 25 class WriteTransaction; |
| 24 | 26 |
| 25 typedef std::vector<syncer::SyncData> SyncDataList; | 27 typedef std::vector<syncer::SyncData> SyncDataList; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 39 // be used on the same thread in which it was created. | 41 // be used on the same thread in which it was created. |
| 40 class GenericChangeProcessor : public ChangeProcessor, | 42 class GenericChangeProcessor : public ChangeProcessor, |
| 41 public syncer::SyncChangeProcessor, | 43 public syncer::SyncChangeProcessor, |
| 42 public base::NonThreadSafe { | 44 public base::NonThreadSafe { |
| 43 public: | 45 public: |
| 44 // Create a change processor and connect it to the syncer. | 46 // Create a change processor and connect it to the syncer. |
| 45 GenericChangeProcessor( | 47 GenericChangeProcessor( |
| 46 DataTypeErrorHandler* error_handler, | 48 DataTypeErrorHandler* error_handler, |
| 47 const base::WeakPtr<syncer::SyncableService>& local_service, | 49 const base::WeakPtr<syncer::SyncableService>& local_service, |
| 48 const base::WeakPtr<syncer::SyncMergeResult>& merge_result, | 50 const base::WeakPtr<syncer::SyncMergeResult>& merge_result, |
| 49 syncer::UserShare* user_share); | 51 syncer::UserShare* user_share, |
| 52 scoped_ptr<syncer::AttachmentService> attachment_service); |
| 50 virtual ~GenericChangeProcessor(); | 53 virtual ~GenericChangeProcessor(); |
| 51 | 54 |
| 52 // ChangeProcessor interface. | 55 // ChangeProcessor interface. |
| 53 // Build and store a list of all changes into |syncer_changes_|. | 56 // Build and store a list of all changes into |syncer_changes_|. |
| 54 virtual void ApplyChangesFromSyncModel( | 57 virtual void ApplyChangesFromSyncModel( |
| 55 const syncer::BaseTransaction* trans, | 58 const syncer::BaseTransaction* trans, |
| 56 int64 version, | 59 int64 version, |
| 57 const syncer::ImmutableChangeRecordList& changes) OVERRIDE; | 60 const syncer::ImmutableChangeRecordList& changes) OVERRIDE; |
| 58 // Passes |syncer_changes_|, built in ApplyChangesFromSyncModel, onto | 61 // Passes |syncer_changes_|, built in ApplyChangesFromSyncModel, onto |
| 59 // |local_service_| by way of its ProcessSyncChanges method. | 62 // |local_service_| by way of its ProcessSyncChanges method. |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 // Set in ApplyChangesFromSyncModel, consumed in CommitChangesFromSyncModel. | 122 // Set in ApplyChangesFromSyncModel, consumed in CommitChangesFromSyncModel. |
| 120 syncer::SyncChangeList syncer_changes_; | 123 syncer::SyncChangeList syncer_changes_; |
| 121 | 124 |
| 122 // Our handle to the sync model. Unlike normal ChangeProcessors, we need to | 125 // Our handle to the sync model. Unlike normal ChangeProcessors, we need to |
| 123 // be able to access the sync model before the change processor begins | 126 // be able to access the sync model before the change processor begins |
| 124 // listening to changes (the local_service_ will be interacting with us | 127 // listening to changes (the local_service_ will be interacting with us |
| 125 // when it starts up). As such we can't wait until Start(_) has been called, | 128 // when it starts up). As such we can't wait until Start(_) has been called, |
| 126 // and have to keep a local pointer to the user_share. | 129 // and have to keep a local pointer to the user_share. |
| 127 syncer::UserShare* const share_handle_; | 130 syncer::UserShare* const share_handle_; |
| 128 | 131 |
| 132 scoped_ptr<syncer::AttachmentService> attachment_service_; |
| 133 // Must be destroyed before attachment_service_ to ensure WeakPtrs are |
| 134 // invalidated before attachment_service_ is destroyed. |
| 135 base::WeakPtrFactory<syncer::AttachmentService> |
| 136 attachment_service_weak_ptr_factory_; |
| 137 syncer::AttachmentServiceProxy attachment_service_proxy_; |
| 138 |
| 129 DISALLOW_COPY_AND_ASSIGN(GenericChangeProcessor); | 139 DISALLOW_COPY_AND_ASSIGN(GenericChangeProcessor); |
| 130 }; | 140 }; |
| 131 | 141 |
| 132 } // namespace browser_sync | 142 } // namespace browser_sync |
| 133 | 143 |
| 134 #endif // CHROME_BROWSER_SYNC_GLUE_GENERIC_CHANGE_PROCESSOR_H_ | 144 #endif // CHROME_BROWSER_SYNC_GLUE_GENERIC_CHANGE_PROCESSOR_H_ |
| OLD | NEW |