| 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 #ifndef CHROME_BROWSER_SYNC_GLUE_FRONTEND_DATA_TYPE_CONTROLLER_H__ | 5 #ifndef CHROME_BROWSER_SYNC_GLUE_FRONTEND_DATA_TYPE_CONTROLLER_H__ |
| 6 #define CHROME_BROWSER_SYNC_GLUE_FRONTEND_DATA_TYPE_CONTROLLER_H__ | 6 #define CHROME_BROWSER_SYNC_GLUE_FRONTEND_DATA_TYPE_CONTROLLER_H__ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 class FrontendDataTypeController : public DataTypeController { | 37 class FrontendDataTypeController : public DataTypeController { |
| 38 public: | 38 public: |
| 39 FrontendDataTypeController( | 39 FrontendDataTypeController( |
| 40 ProfileSyncFactory* profile_sync_factory, | 40 ProfileSyncFactory* profile_sync_factory, |
| 41 Profile* profile, | 41 Profile* profile, |
| 42 ProfileSyncService* sync_service); | 42 ProfileSyncService* sync_service); |
| 43 virtual ~FrontendDataTypeController(); | 43 virtual ~FrontendDataTypeController(); |
| 44 | 44 |
| 45 // DataTypeController interface. | 45 // DataTypeController interface. |
| 46 virtual void Start(StartCallback* start_callback); | 46 virtual void Start(StartCallback* start_callback); |
| 47 | |
| 48 virtual void Stop(); | 47 virtual void Stop(); |
| 49 | |
| 50 virtual syncable::ModelType type() const = 0; | 48 virtual syncable::ModelType type() const = 0; |
| 51 | |
| 52 virtual browser_sync::ModelSafeGroup model_safe_group() const; | 49 virtual browser_sync::ModelSafeGroup model_safe_group() const; |
| 53 | |
| 54 virtual std::string name() const; | 50 virtual std::string name() const; |
| 55 | |
| 56 virtual State state() const; | 51 virtual State state() const; |
| 57 | 52 |
| 58 // UnrecoverableErrorHandler interface. | 53 // UnrecoverableErrorHandler interface. |
| 59 virtual void OnUnrecoverableError(const tracked_objects::Location& from_here, | 54 virtual void OnUnrecoverableError(const tracked_objects::Location& from_here, |
| 60 const std::string& message); | 55 const std::string& message); |
| 61 protected: | 56 protected: |
| 62 // For testing only. | 57 // For testing only. |
| 63 FrontendDataTypeController(); | 58 FrontendDataTypeController(); |
| 64 | 59 |
| 65 // Kick off any dependent services that need to be running before we can | 60 // Kick off any dependent services that need to be running before we can |
| 66 // associate models. The default implementation is a no-op. | 61 // associate models. The default implementation is a no-op. |
| 62 // Return value: |
| 63 // True - if models are ready and association can proceed. |
| 64 // False - if models are not ready. Associate() should be called when the |
| 65 // models are ready. Refer to Start(_) implementation. |
| 67 virtual bool StartModels(); | 66 virtual bool StartModels(); |
| 68 | 67 |
| 69 // Build sync components and associate models. | 68 // Build sync components and associate models. |
| 69 // Return value: |
| 70 // True - if association was successful. FinishStart should have been |
| 71 // invoked. |
| 72 // False - if association failed. StartFailed should have been invoked. |
| 70 virtual bool Associate(); | 73 virtual bool Associate(); |
| 71 | 74 |
| 75 // Datatype specific creation of sync components. |
| 76 virtual void CreateSyncComponents() = 0; |
| 77 |
| 72 // Perform any DataType controller specific state cleanup before stopping | 78 // Perform any DataType controller specific state cleanup before stopping |
| 73 // the datatype controller. The default implementation is a no-op. | 79 // the datatype controller. The default implementation is a no-op. |
| 74 virtual void CleanupState(); | 80 virtual void CleanUpState(); |
| 81 |
| 82 // Cleans up state and calls callback when start fails. |
| 83 virtual void StartFailed(StartResult result, |
| 84 const tracked_objects::Location& from_here); |
| 75 | 85 |
| 76 // Helper method to run the stashed start callback with a given result. | 86 // Helper method to run the stashed start callback with a given result. |
| 77 virtual void FinishStart(StartResult result, | 87 virtual void FinishStart(StartResult result, |
| 78 const tracked_objects::Location& from_here); | 88 const tracked_objects::Location& from_here); |
| 79 | 89 |
| 80 // Cleans up state and calls callback when start fails. | |
| 81 virtual void StartFailed(StartResult result, | |
| 82 const tracked_objects::Location& from_here); | |
| 83 | |
| 84 // Datatype specific creation of sync components. | |
| 85 virtual void CreateSyncComponents() = 0; | |
| 86 | |
| 87 // DataType specific histogram methods. Because histograms use static's, the | 90 // DataType specific histogram methods. Because histograms use static's, the |
| 88 // specific datatype controllers must implement this themselves. | 91 // specific datatype controllers must implement this themselves. |
| 89 // Record unrecoverable errors. | 92 // Record unrecoverable errors. |
| 90 virtual void RecordUnrecoverableError( | 93 virtual void RecordUnrecoverableError( |
| 91 const tracked_objects::Location& from_here, | 94 const tracked_objects::Location& from_here, |
| 92 const std::string& message) = 0; | 95 const std::string& message) = 0; |
| 93 // Record association time. | 96 // Record association time. |
| 94 virtual void RecordAssociationTime(base::TimeDelta time) = 0; | 97 virtual void RecordAssociationTime(base::TimeDelta time) = 0; |
| 95 // Record causes of start failure. | 98 // Record causes of start failure. |
| 96 virtual void RecordStartFailure(StartResult result) = 0; | 99 virtual void RecordStartFailure(StartResult result) = 0; |
| 97 | 100 |
| 98 ProfileSyncFactory* const profile_sync_factory_; | 101 ProfileSyncFactory* const profile_sync_factory_; |
| 99 Profile* const profile_; | 102 Profile* const profile_; |
| 100 ProfileSyncService* const sync_service_; | 103 ProfileSyncService* const sync_service_; |
| 101 | 104 |
| 102 State state_; | 105 State state_; |
| 103 | 106 |
| 104 scoped_ptr<StartCallback> start_callback_; | 107 scoped_ptr<StartCallback> start_callback_; |
| 105 scoped_ptr<AssociatorInterface> model_associator_; | 108 scoped_ptr<AssociatorInterface> model_associator_; |
| 106 scoped_ptr<ChangeProcessor> change_processor_; | 109 scoped_ptr<ChangeProcessor> change_processor_; |
| 107 | 110 |
| 108 DISALLOW_COPY_AND_ASSIGN(FrontendDataTypeController); | 111 DISALLOW_COPY_AND_ASSIGN(FrontendDataTypeController); |
| 109 }; | 112 }; |
| 110 | 113 |
| 111 } // namespace browser_sync | 114 } // namespace browser_sync |
| 112 | 115 |
| 113 #endif // CHROME_BROWSER_SYNC_GLUE_FRONTEND_DATA_TYPE_CONTROLLER_H__ | 116 #endif // CHROME_BROWSER_SYNC_GLUE_FRONTEND_DATA_TYPE_CONTROLLER_H__ |
| OLD | NEW |