1 // Copyright 2014 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.
5 #ifndef COMPONENTS_SYNC_DRIVER_DATA_TYPE_MANAGER_H__
6 #define COMPONENTS_SYNC_DRIVER_DATA_TYPE_MANAGER_H__
12 #include "components/sync_driver/data_type_controller.h"
13 #include "components/sync_driver/data_type_status_table.h"
14 #include "sync/api/sync_error.h"
15 #include "sync/internal_api/public/base/model_type.h"
16 #include "sync/internal_api/public/configure_reason.h"
18 namespace sync_driver {
20 // This interface is for managing the start up and shut down life cycle
21 // of many different syncable data types.
22 class DataTypeManager {
25 STOPPED, // No data types are currently running.
26 DOWNLOAD_PENDING, // Not implemented yet: Waiting for the syncer to
27 // complete the initial download of new data
30 CONFIGURING, // Data types are being started.
31 RETRYING, // Retrying a pending reconfiguration.
33 CONFIGURED, // All enabled data types are running.
34 STOPPING // Data types are being stopped.
37 // Update NotifyDone() in data_type_manager_impl.cc if you update
39 enum ConfigureStatus {
41 OK, // Configuration finished some or all types.
42 ABORTED, // Start was aborted by calling Stop() before
43 // all types were started.
44 UNRECOVERABLE_ERROR // We got an unrecoverable error during startup.
47 // Note: |errors| is only filled when status is not OK.
48 struct ConfigureResult {
50 ConfigureResult(ConfigureStatus status,
51 syncer::ModelTypeSet requested_types);
54 ConfigureStatus status;
55 syncer::ModelTypeSet requested_types;
56 DataTypeStatusTable data_type_status_table;
59 virtual ~DataTypeManager() {}
61 // Convert a ConfigureStatus to string for debug purposes.
62 static std::string ConfigureStatusToString(ConfigureStatus status);
64 // Begins asynchronous configuration of data types. Any currently
65 // running data types that are not in the desired_types set will be
66 // stopped. Any stopped data types that are in the desired_types
67 // set will be started. All other data types are left in their
68 // current state. A SYNC_CONFIGURE_START notification will be sent
69 // to the UI thread when configuration is started and a
70 // SYNC_CONFIGURE_DONE notification will be sent (with a
71 // ConfigureResult detail) when configuration is complete.
73 // Note that you may call Configure() while configuration is in
74 // progress. Configuration will be complete only when the
75 // desired_types supplied in the last call to Configure is achieved.
76 virtual void Configure(syncer::ModelTypeSet desired_types,
77 syncer::ConfigureReason reason) = 0;
79 // Resets the error state for |type| and triggers a reconfiguration if
81 virtual void ReenableType(syncer::ModelType type) = 0;
83 // Resets all data type error state.
84 virtual void ResetDataTypeErrors() = 0;
86 virtual void PurgeForMigration(syncer::ModelTypeSet undesired_types,
87 syncer::ConfigureReason reason) = 0;
89 // Synchronously stops all registered data types. If called after
90 // Configure() is called but before it finishes, it will abort the
91 // configure and any data types that have been started will be
93 virtual void Stop() = 0;
95 // The current state of the data type manager.
96 virtual State state() const = 0;
99 } // namespace sync_driver
101 #endif // COMPONENTS_SYNC_DRIVER_DATA_TYPE_MANAGER_H__