Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_SYNC_GLUE_NEW_NON_FRONTEND_DATA_TYPE_CONTROLLER_H_ | |
| 6 #define CHROME_BROWSER_SYNC_GLUE_NEW_NON_FRONTEND_DATA_TYPE_CONTROLLER_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include "base/compiler_specific.h" | |
| 10 #include "base/memory/weak_ptr.h" | |
| 11 #include "chrome/browser/sync/glue/non_frontend_data_type_controller.h" | |
| 12 #include "chrome/browser/sync/glue/shared_change_processor.h" | |
| 13 | |
| 14 class SyncableService; | |
| 15 | |
| 16 namespace browser_sync { | |
| 17 | |
| 18 class NewNonFrontendDataTypeController : public NonFrontendDataTypeController { | |
| 19 public: | |
| 20 NewNonFrontendDataTypeController( | |
| 21 ProfileSyncFactory* profile_sync_factory, | |
| 22 Profile* profile); | |
| 23 virtual ~NewNonFrontendDataTypeController(); | |
| 24 | |
| 25 virtual void Start(StartCallback* start_callback) OVERRIDE; | |
| 26 virtual void Stop() OVERRIDE; | |
| 27 | |
| 28 protected: | |
| 29 NewNonFrontendDataTypeController(); | |
| 30 | |
| 31 // Override's of NonFrontendDataTypeController methods. | |
| 32 virtual void StartAssociation() OVERRIDE; | |
| 33 virtual void StartDone(DataTypeController::StartResult result, | |
| 34 DataTypeController::State new_state, | |
| 35 const SyncError& error) OVERRIDE; | |
| 36 | |
| 37 // Calls local_service_->StopSyncing() and releases our references to it and | |
| 38 // |shared_change_processor_|. | |
| 39 virtual void StopLocalService(); | |
|
akalin
2011/10/12 19:54:21
does this have to be virtual?
Nicolas Zea
2011/10/12 23:47:43
For mocking it does.
akalin
2011/10/13 00:08:16
Add comment to that effect
| |
| 40 // Posts StopLocalService() to the datatype's thread. | |
| 41 virtual void StopLocalServiceAsync() = 0; | |
| 42 | |
| 43 // Extract/create the syncable service from the profile and return a | |
| 44 // WeakHandle to it. | |
| 45 virtual base::WeakPtr<SyncableService> GetWeakPtrToSyncableService() | |
| 46 const = 0; | |
| 47 | |
| 48 private: | |
| 49 // Deprecated. | |
| 50 virtual bool StopAssociationAsync() OVERRIDE; | |
| 51 virtual void CreateSyncComponents() OVERRIDE; | |
| 52 | |
| 53 // A weak pointer to the actual local syncable service, which performs all the | |
| 54 // real work. We do not own the object, and it is only safe to access on the | |
| 55 // DataType's thread. | |
| 56 // Lifetime: it gets set in StartAssociation() and released in | |
| 57 // StopLocalService(). | |
| 58 base::WeakPtr<SyncableService> local_service_; | |
| 59 | |
| 60 // The thread-safe layer between the datatype and the syncer. It allows us to | |
| 61 // disconnect both the datatype and ourselves from the syncer at shutdown | |
| 62 // time. All accesses to the syncer from any thread other than the UI thread | |
| 63 // should be through this. Once connected, it must be released on the | |
| 64 // datatype's thread (but if we never connect it we can destroy it on the UI | |
| 65 // thread as well). | |
| 66 // Lifetime: It gets created on the UI thread in Start(..), connected to | |
| 67 // the syncer in StartAssociation() on the datatype's thread, and if | |
| 68 // successfully connected released in StopLocalService() on the datatype's | |
| 69 // thread. | |
| 70 scoped_refptr<SharedChangeProcessor> shared_change_processor_; | |
| 71 }; | |
| 72 | |
| 73 } // namespace browser_sync | |
| 74 | |
| 75 #endif // CHROME_BROWSER_SYNC_GLUE_NEW_NON_FRONTEND_DATA_TYPE_CONTROLLER_H_ | |
| OLD | NEW |