Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(539)

Side by Side Diff: components/sync/driver/data_type_manager.h

Issue 2376123003: [Sync] Move //components/sync to the syncer namespace. (Closed)
Patch Set: Rebase. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 sync_driver { 18 namespace syncer {
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, 46 ConfigureResult(ConfigureStatus status, ModelTypeSet requested_types);
47 syncer::ModelTypeSet requested_types);
48 ConfigureResult(const ConfigureResult& other); 47 ConfigureResult(const ConfigureResult& other);
49 ~ConfigureResult(); 48 ~ConfigureResult();
50 49
51 ConfigureStatus status; 50 ConfigureStatus status;
52 syncer::ModelTypeSet requested_types; 51 ModelTypeSet requested_types;
53 DataTypeStatusTable data_type_status_table; 52 DataTypeStatusTable data_type_status_table;
54 }; 53 };
55 54
56 virtual ~DataTypeManager() {} 55 virtual ~DataTypeManager() {}
57 56
58 // Convert a ConfigureStatus to string for debug purposes. 57 // Convert a ConfigureStatus to string for debug purposes.
59 static std::string ConfigureStatusToString(ConfigureStatus status); 58 static std::string ConfigureStatusToString(ConfigureStatus status);
60 59
61 // Begins asynchronous configuration of data types. Any currently 60 // Begins asynchronous configuration of data types. Any currently
62 // running data types that are not in the desired_types set will be 61 // running data types that are not in the desired_types set will be
63 // stopped. Any stopped data types that are in the desired_types 62 // stopped. Any stopped data types that are in the desired_types
64 // set will be started. All other data types are left in their 63 // set will be started. All other data types are left in their
65 // current state. A SYNC_CONFIGURE_START notification will be sent 64 // current state. A SYNC_CONFIGURE_START notification will be sent
66 // to the UI thread when configuration is started and a 65 // to the UI thread when configuration is started and a
67 // SYNC_CONFIGURE_DONE notification will be sent (with a 66 // SYNC_CONFIGURE_DONE notification will be sent (with a
68 // ConfigureResult detail) when configuration is complete. 67 // ConfigureResult detail) when configuration is complete.
69 // 68 //
70 // Note that you may call Configure() while configuration is in 69 // Note that you may call Configure() while configuration is in
71 // progress. Configuration will be complete only when the 70 // progress. Configuration will be complete only when the
72 // desired_types supplied in the last call to Configure is achieved. 71 // desired_types supplied in the last call to Configure is achieved.
73 virtual void Configure(syncer::ModelTypeSet desired_types, 72 virtual void Configure(ModelTypeSet desired_types,
74 syncer::ConfigureReason reason) = 0; 73 ConfigureReason reason) = 0;
75 74
76 // Resets the error state for |type| and triggers a reconfiguration if 75 // Resets the error state for |type| and triggers a reconfiguration if
77 // necessary. 76 // necessary.
78 virtual void ReenableType(syncer::ModelType type) = 0; 77 virtual void ReenableType(ModelType type) = 0;
79 78
80 // Resets all data type error state. 79 // Resets all data type error state.
81 virtual void ResetDataTypeErrors() = 0; 80 virtual void ResetDataTypeErrors() = 0;
82 81
83 virtual void PurgeForMigration(syncer::ModelTypeSet undesired_types, 82 virtual void PurgeForMigration(ModelTypeSet undesired_types,
84 syncer::ConfigureReason reason) = 0; 83 ConfigureReason reason) = 0;
85 84
86 // Synchronously stops all registered data types. If called after 85 // Synchronously stops all registered data types. If called after
87 // Configure() is called but before it finishes, it will abort the 86 // Configure() is called but before it finishes, it will abort the
88 // configure and any data types that have been started will be 87 // configure and any data types that have been started will be
89 // stopped. 88 // stopped.
90 virtual void Stop() = 0; 89 virtual void Stop() = 0;
91 90
92 // The current state of the data type manager. 91 // The current state of the data type manager.
93 virtual State state() const = 0; 92 virtual State state() const = 0;
94 }; 93 };
95 94
96 } // namespace sync_driver 95 } // namespace syncer
97 96
98 #endif // COMPONENTS_SYNC_DRIVER_DATA_TYPE_MANAGER_H__ 97 #endif // COMPONENTS_SYNC_DRIVER_DATA_TYPE_MANAGER_H__
OLDNEW
« no previous file with comments | « components/sync/driver/data_type_encryption_handler.cc ('k') | components/sync/driver/data_type_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698