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