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 "sync/api/sync_error.h"
14 #include "sync/internal_api/public/base/model_type.h"
15 #include "sync/internal_api/public/configure_reason.h"
17 namespace sync_driver {
19 // This interface is for managing the start up and shut down life cycle
20 // of many different syncable data types.
21 class DataTypeManager {
24 STOPPED, // No data types are currently running.
25 DOWNLOAD_PENDING, // Not implemented yet: Waiting for the syncer to
26 // complete the initial download of new data
29 CONFIGURING, // Data types are being started.
30 RETRYING, // Retrying a pending reconfiguration.
32 CONFIGURED, // All enabled data types are running.
33 STOPPING // Data types are being stopped.
36 // Update NotifyDone() in data_type_manager_impl.cc if you update
38 enum ConfigureStatus {
40 OK, // Configuration finished some or all types.
41 ABORTED, // Start was aborted by calling Stop() before
42 // all types were started.
43 UNRECOVERABLE_ERROR // We got an unrecoverable error during startup.
46 // Note: |errors| is only filled when status is not OK.
47 struct ConfigureResult {
49 ConfigureResult(ConfigureStatus status,
50 syncer::ModelTypeSet requested_types);
53 ConfigureStatus status;
54 syncer::ModelTypeSet requested_types;
57 virtual ~DataTypeManager() {}
59 // Convert a ConfigureStatus to string for debug purposes.
60 static std::string ConfigureStatusToString(ConfigureStatus status);
62 // Begins asynchronous configuration of data types. Any currently
63 // running data types that are not in the desired_types set will be
64 // stopped. Any stopped data types that are in the desired_types
65 // set will be started. All other data types are left in their
66 // current state. A SYNC_CONFIGURE_START notification will be sent
67 // to the UI thread when configuration is started and a
68 // SYNC_CONFIGURE_DONE notification will be sent (with a
69 // ConfigureResult detail) when configuration is complete.
71 // Note that you may call Configure() while configuration is in
72 // progress. Configuration will be complete only when the
73 // desired_types supplied in the last call to Configure is achieved.
74 virtual void Configure(syncer::ModelTypeSet desired_types,
75 syncer::ConfigureReason reason) = 0;
77 virtual void PurgeForMigration(syncer::ModelTypeSet undesired_types,
78 syncer::ConfigureReason reason) = 0;
80 // Synchronously stops all registered data types. If called after
81 // Configure() is called but before it finishes, it will abort the
82 // configure and any data types that have been started will be
84 virtual void Stop() = 0;
86 // The current state of the data type manager.
87 virtual State state() const = 0;
90 } // namespace sync_driver
92 #endif // COMPONENTS_SYNC_DRIVER_DATA_TYPE_MANAGER_H__