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_DATA_TYPE_MANAGER_IMPL_H__ | 5 #ifndef CHROME_BROWSER_SYNC_GLUE_DATA_TYPE_MANAGER_IMPL_H__ |
6 #define CHROME_BROWSER_SYNC_GLUE_DATA_TYPE_MANAGER_IMPL_H__ | 6 #define CHROME_BROWSER_SYNC_GLUE_DATA_TYPE_MANAGER_IMPL_H__ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "chrome/browser/sync/glue/data_type_manager.h" | 9 #include "chrome/browser/sync/glue/data_type_manager.h" |
10 | 10 |
11 #include <map> | 11 #include <map> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "base/task.h" | 16 #include "base/task.h" |
17 #include "base/time.h" | 17 #include "base/time.h" |
18 | 18 |
19 namespace browser_sync { | 19 namespace browser_sync { |
20 | 20 |
21 class DataTypeController; | 21 class DataTypeController; |
22 class SyncBackendHost; | 22 class SyncBackendHost; |
23 | 23 |
24 class DataTypeManagerImpl : public DataTypeManager { | 24 class DataTypeManagerImpl : public DataTypeManager { |
25 public: | 25 public: |
26 DataTypeManagerImpl(SyncBackendHost* backend, | 26 DataTypeManagerImpl(SyncBackendHost* backend, |
27 const DataTypeController::TypeMap& controllers); | 27 const DataTypeController::TypeMap* controllers); |
28 virtual ~DataTypeManagerImpl(); | 28 virtual ~DataTypeManagerImpl(); |
29 | 29 |
30 // DataTypeManager interface. | 30 // DataTypeManager interface. |
31 virtual void Configure(const TypeSet& desired_types, | 31 virtual void Configure(const TypeSet& desired_types, |
32 sync_api::ConfigureReason reason); | 32 sync_api::ConfigureReason reason); |
33 | 33 |
34 // Needed only for backend migration. | 34 // Needed only for backend migration. |
35 virtual void ConfigureWithoutNigori(const TypeSet& desired_types, | 35 virtual void ConfigureWithoutNigori(const TypeSet& desired_types, |
36 sync_api::ConfigureReason reason); | 36 sync_api::ConfigureReason reason); |
37 | 37 |
38 virtual void Stop(); | 38 virtual void Stop(); |
39 virtual const DataTypeController::TypeMap& controllers(); | |
40 virtual State state(); | 39 virtual State state(); |
41 | 40 |
42 private: | 41 private: |
43 // Starts the next data type in the kStartOrder list, indicated by | 42 // Starts the next data type in the kStartOrder list, indicated by |
44 // the current_type_ member. If there are no more data types to | 43 // the current_type_ member. If there are no more data types to |
45 // start, the stashed start_callback_ is invoked. | 44 // start, the stashed start_callback_ is invoked. |
46 void StartNextType(); | 45 void StartNextType(); |
47 | 46 |
48 // Callback passed to each data type controller on startup. | 47 // Callback passed to each data type controller on startup. |
49 void TypeStartCallback(DataTypeController::StartResult result, | 48 void TypeStartCallback(DataTypeController::StartResult result, |
(...skipping 20 matching lines...) Expand all Loading... |
70 // Restart(). | 69 // Restart(). |
71 void AddToConfigureTime(); | 70 void AddToConfigureTime(); |
72 | 71 |
73 virtual void ConfigureImpl(const TypeSet& desired_types, | 72 virtual void ConfigureImpl(const TypeSet& desired_types, |
74 sync_api::ConfigureReason reason, | 73 sync_api::ConfigureReason reason, |
75 bool enable_nigori); | 74 bool enable_nigori); |
76 | 75 |
77 SyncBackendHost* backend_; | 76 SyncBackendHost* backend_; |
78 // Map of all data type controllers that are available for sync. | 77 // Map of all data type controllers that are available for sync. |
79 // This list is determined at startup by various command line flags. | 78 // This list is determined at startup by various command line flags. |
80 const DataTypeController::TypeMap controllers_; | 79 const DataTypeController::TypeMap* controllers_; |
81 State state_; | 80 State state_; |
82 std::map<syncable::ModelType, int> start_order_; | 81 std::map<syncable::ModelType, int> start_order_; |
83 TypeSet last_requested_types_; | 82 TypeSet last_requested_types_; |
84 std::vector<DataTypeController*> needs_start_; | 83 std::vector<DataTypeController*> needs_start_; |
85 std::vector<DataTypeController*> needs_stop_; | 84 std::vector<DataTypeController*> needs_stop_; |
86 | 85 |
87 // Whether an attempt to reconfigure was made while we were busy configuring. | 86 // Whether an attempt to reconfigure was made while we were busy configuring. |
88 // The |last_requested_types_| will reflect the newest set of requested types. | 87 // The |last_requested_types_| will reflect the newest set of requested types. |
89 bool needs_reconfigure_; | 88 bool needs_reconfigure_; |
90 | 89 |
91 // The reason for the last reconfigure attempt. Not this will be set to a | 90 // The reason for the last reconfigure attempt. Not this will be set to a |
92 // valid value only if needs_reconfigure_ is set. | 91 // valid value only if needs_reconfigure_ is set. |
93 sync_api::ConfigureReason last_configure_reason_; | 92 sync_api::ConfigureReason last_configure_reason_; |
94 | 93 |
95 base::WeakPtrFactory<DataTypeManagerImpl> weak_ptr_factory_; | 94 base::WeakPtrFactory<DataTypeManagerImpl> weak_ptr_factory_; |
96 | 95 |
97 // The last time Restart() was called. | 96 // The last time Restart() was called. |
98 base::Time last_restart_time_; | 97 base::Time last_restart_time_; |
99 | 98 |
100 // The accumulated time spent between calls to Restart() and going | 99 // The accumulated time spent between calls to Restart() and going |
101 // to the DONE/BLOCKED state. | 100 // to the DONE/BLOCKED state. |
102 base::TimeDelta configure_time_delta_; | 101 base::TimeDelta configure_time_delta_; |
103 | 102 |
104 DISALLOW_COPY_AND_ASSIGN(DataTypeManagerImpl); | 103 DISALLOW_COPY_AND_ASSIGN(DataTypeManagerImpl); |
105 }; | 104 }; |
106 | 105 |
107 } // namespace browser_sync | 106 } // namespace browser_sync |
108 | 107 |
109 #endif // CHROME_BROWSER_SYNC_GLUE_DATA_TYPE_MANAGER_IMPL_H__ | 108 #endif // CHROME_BROWSER_SYNC_GLUE_DATA_TYPE_MANAGER_IMPL_H__ |
OLD | NEW |