| 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_UI_DATA_TYPE_CONTROLLER_H__ | 5 #ifndef CHROME_BROWSER_SYNC_GLUE_UI_DATA_TYPE_CONTROLLER_H__ |
| 6 #define CHROME_BROWSER_SYNC_GLUE_UI_DATA_TYPE_CONTROLLER_H__ | 6 #define CHROME_BROWSER_SYNC_GLUE_UI_DATA_TYPE_CONTROLLER_H__ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "chrome/browser/sync/glue/data_type_controller.h" | 15 #include "chrome/browser/sync/glue/data_type_controller.h" |
| 16 #include "chrome/browser/sync/glue/shared_change_processor.h" | 16 #include "chrome/browser/sync/glue/shared_change_processor.h" |
| 17 | 17 |
| 18 class Profile; | 18 class Profile; |
| 19 class ProfileSyncService; | 19 class ProfileSyncService; |
| 20 class ProfileSyncComponentsFactory; | 20 class ProfileSyncComponentsFactory; |
| 21 |
| 22 namespace base { |
| 23 class TimeDelta; |
| 24 } |
| 25 |
| 26 namespace csync { |
| 21 class SyncableService; | 27 class SyncableService; |
| 22 class SyncError; | 28 class SyncError; |
| 29 } |
| 23 | 30 |
| 24 namespace base { class TimeDelta; } | |
| 25 namespace browser_sync { | 31 namespace browser_sync { |
| 26 | 32 |
| 27 // Implementation for datatypes that reside on the (UI thread). This is the same | 33 // Implementation for datatypes that reside on the (UI thread). This is the same |
| 28 // thread we perform initialization on, so we don't have to worry about thread | 34 // thread we perform initialization on, so we don't have to worry about thread |
| 29 // safety. The main start/stop funtionality is implemented by default. | 35 // safety. The main start/stop funtionality is implemented by default. |
| 30 // Note: RefCountedThreadSafe by way of DataTypeController. | 36 // Note: RefCountedThreadSafe by way of DataTypeController. |
| 31 class UIDataTypeController : public DataTypeController { | 37 class UIDataTypeController : public DataTypeController { |
| 32 public: | 38 public: |
| 33 UIDataTypeController( | 39 UIDataTypeController( |
| 34 syncable::ModelType type, | 40 syncable::ModelType type, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 virtual bool StartModels(); | 72 virtual bool StartModels(); |
| 67 | 73 |
| 68 // Perform any DataType controller specific state cleanup before stopping | 74 // Perform any DataType controller specific state cleanup before stopping |
| 69 // the datatype controller. The default implementation is a no-op. | 75 // the datatype controller. The default implementation is a no-op. |
| 70 virtual void StopModels(); | 76 virtual void StopModels(); |
| 71 | 77 |
| 72 // DataTypeController interface. | 78 // DataTypeController interface. |
| 73 virtual void OnModelLoaded() OVERRIDE; | 79 virtual void OnModelLoaded() OVERRIDE; |
| 74 | 80 |
| 75 // Helper methods for cleaning up state and invoking the start callback. | 81 // Helper methods for cleaning up state and invoking the start callback. |
| 76 virtual void StartFailed(StartResult result, const SyncError& error); | 82 virtual void StartFailed(StartResult result, const csync::SyncError& error); |
| 77 virtual void StartDone(StartResult result); | 83 virtual void StartDone(StartResult result); |
| 78 | 84 |
| 79 // Record association time. | 85 // Record association time. |
| 80 virtual void RecordAssociationTime(base::TimeDelta time); | 86 virtual void RecordAssociationTime(base::TimeDelta time); |
| 81 // Record causes of start failure. | 87 // Record causes of start failure. |
| 82 virtual void RecordStartFailure(StartResult result); | 88 virtual void RecordStartFailure(StartResult result); |
| 83 | 89 |
| 84 ProfileSyncComponentsFactory* const profile_sync_factory_; | 90 ProfileSyncComponentsFactory* const profile_sync_factory_; |
| 85 Profile* const profile_; | 91 Profile* const profile_; |
| 86 ProfileSyncService* const sync_service_; | 92 ProfileSyncService* const sync_service_; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 97 // through it to the datatype as well as vice versa. | 103 // through it to the datatype as well as vice versa. |
| 98 // | 104 // |
| 99 // Lifetime: it gets created when Start()) is called, and a reference to it | 105 // Lifetime: it gets created when Start()) is called, and a reference to it |
| 100 // is passed to |local_service_| during Associate(). We release our reference | 106 // is passed to |local_service_| during Associate(). We release our reference |
| 101 // when Stop() or StartFailed() is called, and |local_service_| releases its | 107 // when Stop() or StartFailed() is called, and |local_service_| releases its |
| 102 // reference when local_service_->StopSyncing() is called or when it is | 108 // reference when local_service_->StopSyncing() is called or when it is |
| 103 // destroyed. | 109 // destroyed. |
| 104 // | 110 // |
| 105 // Note: we use refcounting here primarily so that we can keep a uniform | 111 // Note: we use refcounting here primarily so that we can keep a uniform |
| 106 // SyncableService API, whether the datatype lives on the UI thread or not | 112 // SyncableService API, whether the datatype lives on the UI thread or not |
| 107 // (a SyncableService takes ownership of its SyncChangeProcessor when | 113 // (a csync::SyncableService takes ownership of its SyncChangeProcessor when |
| 108 // MergeDataAndStartSyncing is called). This will help us eventually merge the | 114 // MergeDataAndStartSyncing is called). This will help us eventually merge the |
| 109 // two datatype controller implementations (for ui and non-ui thread | 115 // two datatype controller implementations (for ui and non-ui thread |
| 110 // datatypes). | 116 // datatypes). |
| 111 scoped_refptr<SharedChangeProcessor> shared_change_processor_; | 117 scoped_refptr<SharedChangeProcessor> shared_change_processor_; |
| 112 | 118 |
| 113 // A weak pointer to the actual local syncable service, which performs all the | 119 // A weak pointer to the actual local syncable service, which performs all the |
| 114 // real work. We do not own the object. | 120 // real work. We do not own the object. |
| 115 base::WeakPtr<SyncableService> local_service_; | 121 base::WeakPtr<csync::SyncableService> local_service_; |
| 116 | 122 |
| 117 private: | 123 private: |
| 118 // Associate the sync model with the service's model, then start syncing. | 124 // Associate the sync model with the service's model, then start syncing. |
| 119 virtual void Associate(); | 125 virtual void Associate(); |
| 120 | 126 |
| 121 virtual void AbortModelLoad(); | 127 virtual void AbortModelLoad(); |
| 122 | 128 |
| 123 DISALLOW_COPY_AND_ASSIGN(UIDataTypeController); | 129 DISALLOW_COPY_AND_ASSIGN(UIDataTypeController); |
| 124 }; | 130 }; |
| 125 | 131 |
| 126 } // namespace browser_sync | 132 } // namespace browser_sync |
| 127 | 133 |
| 128 #endif // CHROME_BROWSER_SYNC_GLUE_UI_DATA_TYPE_CONTROLLER_H__ | 134 #endif // CHROME_BROWSER_SYNC_GLUE_UI_DATA_TYPE_CONTROLLER_H__ |
| OLD | NEW |