| 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_SHARED_CHANGE_PROCESSOR_H_ | 5 #ifndef CHROME_BROWSER_SYNC_GLUE_SHARED_CHANGE_PROCESSOR_H_ |
| 6 #define CHROME_BROWSER_SYNC_GLUE_SHARED_CHANGE_PROCESSOR_H_ | 6 #define CHROME_BROWSER_SYNC_GLUE_SHARED_CHANGE_PROCESSOR_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 57 |
| 58 // Connect to the Syncer and prepare to handle changes for |type|. Will | 58 // Connect to the Syncer and prepare to handle changes for |type|. Will |
| 59 // create and store a new GenericChangeProcessor and return a weak pointer to | 59 // create and store a new GenericChangeProcessor and return a weak pointer to |
| 60 // the syncer::SyncableService associated with |type|. | 60 // the syncer::SyncableService associated with |type|. |
| 61 // Note: If this SharedChangeProcessor has been disconnected, or the | 61 // Note: If this SharedChangeProcessor has been disconnected, or the |
| 62 // syncer::SyncableService was not alive, will return a null weak pointer. | 62 // syncer::SyncableService was not alive, will return a null weak pointer. |
| 63 virtual base::WeakPtr<syncer::SyncableService> Connect( | 63 virtual base::WeakPtr<syncer::SyncableService> Connect( |
| 64 ProfileSyncComponentsFactory* sync_factory, | 64 ProfileSyncComponentsFactory* sync_factory, |
| 65 ProfileSyncService* sync_service, | 65 ProfileSyncService* sync_service, |
| 66 DataTypeErrorHandler* error_handler, | 66 DataTypeErrorHandler* error_handler, |
| 67 syncable::ModelType type); | 67 syncer::ModelType type); |
| 68 | 68 |
| 69 // Disconnects from the generic change processor. May be called from any | 69 // Disconnects from the generic change processor. May be called from any |
| 70 // thread. After this, all attempts to interact with the change processor by | 70 // thread. After this, all attempts to interact with the change processor by |
| 71 // |local_service_| are dropped and return errors. The syncer will be safe to | 71 // |local_service_| are dropped and return errors. The syncer will be safe to |
| 72 // shut down from the point of view of this datatype. | 72 // shut down from the point of view of this datatype. |
| 73 // Note: Once disconnected, you cannot reconnect without creating a new | 73 // Note: Once disconnected, you cannot reconnect without creating a new |
| 74 // SharedChangeProcessor. | 74 // SharedChangeProcessor. |
| 75 // Returns: true if we were previously succesfully connected, false if we were | 75 // Returns: true if we were previously succesfully connected, false if we were |
| 76 // already disconnected. | 76 // already disconnected. |
| 77 virtual bool Disconnect(); | 77 virtual bool Disconnect(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 102 private: | 102 private: |
| 103 // Monitor lock for this object. All methods that interact with the change | 103 // Monitor lock for this object. All methods that interact with the change |
| 104 // processor must aquire this lock and check whether we're disconnected or | 104 // processor must aquire this lock and check whether we're disconnected or |
| 105 // not. Once disconnected, all attempted changes to or loads from the change | 105 // not. Once disconnected, all attempted changes to or loads from the change |
| 106 // processor return errors. This enables us to shut down the syncer without | 106 // processor return errors. This enables us to shut down the syncer without |
| 107 // having to wait for possibly non-UI thread datatypes to complete work. | 107 // having to wait for possibly non-UI thread datatypes to complete work. |
| 108 mutable base::Lock monitor_lock_; | 108 mutable base::Lock monitor_lock_; |
| 109 bool disconnected_; | 109 bool disconnected_; |
| 110 | 110 |
| 111 // The sync datatype we were last connected to. | 111 // The sync datatype we were last connected to. |
| 112 syncable::ModelType type_; | 112 syncer::ModelType type_; |
| 113 | 113 |
| 114 // The ProfileSyncService we're currently connected to. | 114 // The ProfileSyncService we're currently connected to. |
| 115 ProfileSyncService* sync_service_; | 115 ProfileSyncService* sync_service_; |
| 116 | 116 |
| 117 // The loop that all methods except the constructor, destructor, and | 117 // The loop that all methods except the constructor, destructor, and |
| 118 // Disconnect() should be called on. Set in Connect(). | 118 // Disconnect() should be called on. Set in Connect(). |
| 119 scoped_refptr<base::MessageLoopProxy> backend_loop_; | 119 scoped_refptr<base::MessageLoopProxy> backend_loop_; |
| 120 | 120 |
| 121 // Used only on |backend_loop_|. | 121 // Used only on |backend_loop_|. |
| 122 GenericChangeProcessor* generic_change_processor_; | 122 GenericChangeProcessor* generic_change_processor_; |
| 123 | 123 |
| 124 DataTypeErrorHandler* error_handler_; | 124 DataTypeErrorHandler* error_handler_; |
| 125 | 125 |
| 126 DISALLOW_COPY_AND_ASSIGN(SharedChangeProcessor); | 126 DISALLOW_COPY_AND_ASSIGN(SharedChangeProcessor); |
| 127 }; | 127 }; |
| 128 | 128 |
| 129 } // namespace browser_sync | 129 } // namespace browser_sync |
| 130 | 130 |
| 131 #endif // CHROME_BROWSER_SYNC_GLUE_SHARED_CHANGE_PROCESSOR_H_ | 131 #endif // CHROME_BROWSER_SYNC_GLUE_SHARED_CHANGE_PROCESSOR_H_ |
| OLD | NEW |