OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_SYNC_BUNDLE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_SYNC_BUNDLE_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_SYNC_BUNDLE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_SYNC_BUNDLE_H_ |
7 | 7 |
| 8 #include <memory> |
8 #include <set> | 9 #include <set> |
9 #include <string> | 10 #include <string> |
10 | 11 |
11 #include "base/macros.h" | 12 #include "base/macros.h" |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "sync/api/sync_change.h" | 13 #include "sync/api/sync_change.h" |
14 #include "sync/api/sync_change_processor.h" | 14 #include "sync/api/sync_change_processor.h" |
15 #include "sync/api/sync_data.h" | 15 #include "sync/api/sync_data.h" |
16 | 16 |
17 class ExtensionSyncService; | 17 class ExtensionSyncService; |
18 | 18 |
19 namespace extensions { | 19 namespace extensions { |
20 | 20 |
21 class ExtensionSyncData; | 21 class ExtensionSyncData; |
22 | 22 |
23 class SyncBundle { | 23 class SyncBundle { |
24 public: | 24 public: |
25 SyncBundle(); | 25 SyncBundle(); |
26 ~SyncBundle(); | 26 ~SyncBundle(); |
27 | 27 |
28 void StartSyncing(scoped_ptr<syncer::SyncChangeProcessor> sync_processor); | 28 void StartSyncing( |
| 29 std::unique_ptr<syncer::SyncChangeProcessor> sync_processor); |
29 | 30 |
30 // Resets this class back to its default values, which will disable all | 31 // Resets this class back to its default values, which will disable all |
31 // syncing until StartSyncing is called again. | 32 // syncing until StartSyncing is called again. |
32 void Reset(); | 33 void Reset(); |
33 | 34 |
34 // Has this bundle started syncing yet? | 35 // Has this bundle started syncing yet? |
35 // Returns true if StartSyncing has been called, false otherwise. | 36 // Returns true if StartSyncing has been called, false otherwise. |
36 bool IsSyncing() const; | 37 bool IsSyncing() const; |
37 | 38 |
38 // Handles the given list of local SyncDatas. This updates the set of synced | 39 // Handles the given list of local SyncDatas. This updates the set of synced |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 syncer::SyncChange CreateSyncChange(const std::string& extension_id, | 72 syncer::SyncChange CreateSyncChange(const std::string& extension_id, |
72 const syncer::SyncData& sync_data) const; | 73 const syncer::SyncData& sync_data) const; |
73 | 74 |
74 // Pushes the given list of SyncChanges to the server. | 75 // Pushes the given list of SyncChanges to the server. |
75 void PushSyncChanges(const syncer::SyncChangeList& sync_change_list); | 76 void PushSyncChanges(const syncer::SyncChangeList& sync_change_list); |
76 | 77 |
77 void AddSyncedExtension(const std::string& id); | 78 void AddSyncedExtension(const std::string& id); |
78 void RemoveSyncedExtension(const std::string& id); | 79 void RemoveSyncedExtension(const std::string& id); |
79 bool HasSyncedExtension(const std::string& id) const; | 80 bool HasSyncedExtension(const std::string& id) const; |
80 | 81 |
81 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_; | 82 std::unique_ptr<syncer::SyncChangeProcessor> sync_processor_; |
82 | 83 |
83 // Stores the set of extensions we know about. Used to decide if a sync change | 84 // Stores the set of extensions we know about. Used to decide if a sync change |
84 // should be ACTION_ADD or ACTION_UPDATE. | 85 // should be ACTION_ADD or ACTION_UPDATE. |
85 std::set<std::string> synced_extensions_; | 86 std::set<std::string> synced_extensions_; |
86 | 87 |
87 // This stores pending installs we got from sync. We'll send this back to the | 88 // This stores pending installs we got from sync. We'll send this back to the |
88 // server until we've installed the extension locally, to prevent the sync | 89 // server until we've installed the extension locally, to prevent the sync |
89 // state from flipping back and forth until all clients are up to date. | 90 // state from flipping back and forth until all clients are up to date. |
90 std::map<std::string, ExtensionSyncData> pending_sync_data_; | 91 std::map<std::string, ExtensionSyncData> pending_sync_data_; |
91 | 92 |
92 DISALLOW_COPY_AND_ASSIGN(SyncBundle); | 93 DISALLOW_COPY_AND_ASSIGN(SyncBundle); |
93 }; | 94 }; |
94 | 95 |
95 } // namespace extensions | 96 } // namespace extensions |
96 | 97 |
97 #endif // CHROME_BROWSER_EXTENSIONS_SYNC_BUNDLE_H_ | 98 #endif // CHROME_BROWSER_EXTENSIONS_SYNC_BUNDLE_H_ |
OLD | NEW |