OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_EXTENSIONS_APP_SYNC_BUNDLE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_APP_SYNC_BUNDLE_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_APP_SYNC_BUNDLE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_APP_SYNC_BUNDLE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "chrome/browser/extensions/app_sync_data.h" | 16 #include "chrome/browser/extensions/app_sync_data.h" |
17 #include "sync/api/syncable_service.h" | 17 #include "sync/api/syncable_service.h" |
18 | 18 |
19 class SyncChangeProcessor; | |
20 class ExtensionService; | 19 class ExtensionService; |
21 class ExtensionSet; | 20 class ExtensionSet; |
| 21 |
| 22 namespace csync { |
| 23 class SyncChangeProcessor; |
22 class SyncErrorFactory; | 24 class SyncErrorFactory; |
| 25 } |
23 | 26 |
24 namespace extensions { | 27 namespace extensions { |
25 | 28 |
26 class Extension; | 29 class Extension; |
27 | 30 |
28 // Bundle of app specific sync stuff. | 31 // Bundle of app specific sync stuff. |
29 class AppSyncBundle { | 32 class AppSyncBundle { |
30 public: | 33 public: |
31 explicit AppSyncBundle(ExtensionService* extension_service); | 34 explicit AppSyncBundle(ExtensionService* extension_service); |
32 virtual ~AppSyncBundle(); | 35 virtual ~AppSyncBundle(); |
33 | 36 |
34 // Setup this bundle to be sync application data. | 37 // Setup this bundle to be sync application data. |
35 void SetupSync(SyncChangeProcessor* sync_proccessor, | 38 void SetupSync(csync::SyncChangeProcessor* sync_proccessor, |
36 SyncErrorFactory* sync_error_factory, | 39 csync::SyncErrorFactory* sync_error_factory, |
37 const SyncDataList& initial_sync_data); | 40 const csync::SyncDataList& initial_sync_data); |
38 | 41 |
39 // Resets this class back to it default values, which will disable all syncing | 42 // Resets this class back to it default values, which will disable all syncing |
40 // until a new sync processor is set. | 43 // until a new sync processor is set. |
41 void Reset(); | 44 void Reset(); |
42 | 45 |
43 // Returns a SyncChange that will delete the given application. | 46 // Returns a csync::SyncChange that will delete the given application. |
44 SyncChange CreateSyncChangeToDelete(const Extension* extension) const; | 47 csync::SyncChange CreateSyncChangeToDelete(const Extension* extension) const; |
45 | 48 |
46 // Process the sync deletion of the given application. | 49 // Process the sync deletion of the given application. |
47 void ProcessDeletion(std::string extension_id, const SyncChange& sync_change); | 50 void ProcessDeletion( |
| 51 std::string extension_id, const csync::SyncChange& sync_change); |
48 | 52 |
49 // Create a sync change based on |sync_data|. | 53 // Create a sync change based on |sync_data|. |
50 SyncChange CreateSyncChange(const SyncData& sync_data); | 54 csync::SyncChange CreateSyncChange(const csync::SyncData& sync_data); |
51 | 55 |
52 // Get all the sync data contained in this bundle. | 56 // Get all the sync data contained in this bundle. |
53 SyncDataList GetAllSyncData() const; | 57 csync::SyncDataList GetAllSyncData() const; |
54 | 58 |
55 // Sync a newly-installed application or change an existing one. | 59 // Sync a newly-installed application or change an existing one. |
56 void SyncChangeIfNeeded(const Extension& extension); | 60 void SyncChangeIfNeeded(const Extension& extension); |
57 | 61 |
58 // Process the given sync change and apply it. | 62 // Process the given sync change and apply it. |
59 void ProcessSyncChange(AppSyncData app_sync_data); | 63 void ProcessSyncChange(AppSyncData app_sync_data); |
60 | 64 |
61 // Process the list of sync changes. | 65 // Process the list of sync changes. |
62 void ProcessSyncChangeList(SyncChangeList sync_change_list); | 66 void ProcessSyncChangeList(csync::SyncChangeList sync_change_list); |
63 | 67 |
64 // Check to see if the given |id| is either synced or pending to be synced. | 68 // Check to see if the given |id| is either synced or pending to be synced. |
65 bool HasExtensionId(const std::string& id) const; | 69 bool HasExtensionId(const std::string& id) const; |
66 bool HasPendingExtensionId(const std::string& id) const; | 70 bool HasPendingExtensionId(const std::string& id) const; |
67 | 71 |
68 // Add a pending app to be synced. | 72 // Add a pending app to be synced. |
69 void AddPendingApp(const std::string& id, | 73 void AddPendingApp(const std::string& id, |
70 const AppSyncData& app_sync_data); | 74 const AppSyncData& app_sync_data); |
71 | 75 |
72 // Returns true if |extension| should be handled by this sync bundle. | 76 // Returns true if |extension| should be handled by this sync bundle. |
(...skipping 11 matching lines...) Expand all Loading... |
84 // Add a synced app. | 88 // Add a synced app. |
85 void AddApp(const std::string& id); | 89 void AddApp(const std::string& id); |
86 | 90 |
87 // Remove a synced app. | 91 // Remove a synced app. |
88 void RemoveApp(const std::string& id); // make private | 92 void RemoveApp(const std::string& id); // make private |
89 | 93 |
90 // Change an app from being pending to synced. | 94 // Change an app from being pending to synced. |
91 void MarkPendingAppSynced(const std::string& id); | 95 void MarkPendingAppSynced(const std::string& id); |
92 | 96 |
93 ExtensionService* extension_service_; // Own us. | 97 ExtensionService* extension_service_; // Own us. |
94 scoped_ptr<SyncChangeProcessor> sync_processor_; | 98 scoped_ptr<csync::SyncChangeProcessor> sync_processor_; |
95 scoped_ptr<SyncErrorFactory> sync_error_factory_; | 99 scoped_ptr<csync::SyncErrorFactory> sync_error_factory_; |
96 | 100 |
97 std::set<std::string> synced_apps_; | 101 std::set<std::string> synced_apps_; |
98 std::map<std::string, AppSyncData> pending_sync_data_; | 102 std::map<std::string, AppSyncData> pending_sync_data_; |
99 | 103 |
100 DISALLOW_COPY_AND_ASSIGN(AppSyncBundle); | 104 DISALLOW_COPY_AND_ASSIGN(AppSyncBundle); |
101 }; | 105 }; |
102 | 106 |
103 } // namespace extensions | 107 } // namespace extensions |
104 | 108 |
105 #endif // CHROME_BROWSER_EXTENSIONS_APP_SYNC_BUNDLE_H_ | 109 #endif // CHROME_BROWSER_EXTENSIONS_APP_SYNC_BUNDLE_H_ |
OLD | NEW |