OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_SYNC_GLUE_EXTENSION_SYNC_H_ | |
6 #define CHROME_BROWSER_SYNC_GLUE_EXTENSION_SYNC_H_ | |
7 #pragma once | |
8 | |
9 // This file contains functions necessary for syncing | |
10 // extensions-related data types. | |
11 | |
12 #include <map> | |
13 #include <string> | |
14 | |
15 class Extension; | |
16 class ExtensionServiceInterface; | |
17 struct ExtensionSyncData; | |
18 | |
19 namespace sync_api { | |
20 struct UserShare; | |
21 } // namespace sync_api | |
22 | |
23 namespace sync_pb { | |
24 class ExtensionSpecifics; | |
25 } // namespace sync_pb | |
26 | |
27 namespace browser_sync { | |
28 | |
29 struct ExtensionSyncTraits; | |
30 | |
31 // A map from extension IDs to ExtensionSyncData objects. | |
32 typedef std::map<std::string, ExtensionSyncData> ExtensionDataMap; | |
33 | |
34 // Fills in |has_children| with whether or not the root node with the | |
35 // given tag has child nodes. Returns true iff the lookup succeeded. | |
36 // | |
37 // TODO(akalin): Move this somewhere where it can be used by | |
38 // other data types. | |
39 bool RootNodeHasChildren(const char* tag, | |
40 sync_api::UserShare* user_share, | |
41 bool* has_children); | |
42 | |
43 // Fills |extension_data_map| with both client-side information about | |
44 // installed extensions and the server-side information about | |
45 // extensions to be synced. Returns true iff this was successful; if | |
46 // unsuccessful, the contents of |extension_data_map| are undefined. | |
47 bool SlurpExtensionData(const ExtensionSyncTraits& traits, | |
48 const ExtensionServiceInterface& extension_service, | |
49 sync_api::UserShare* user_share, | |
50 ExtensionDataMap* extension_data_map); | |
51 | |
52 // Updates the server and client as necessary from | |
53 // |extension_data_map|. Returns true iff this was successful. | |
54 // | |
55 // NOTE(akalin): Keep in mind that updating the client is an | |
56 // asynchronous process; the only thing that's guaranteed if this | |
57 // function is returned is that the updates were successfully started. | |
58 bool FlushExtensionData(const ExtensionSyncTraits& traits, | |
59 const ExtensionDataMap& extension_data_map, | |
60 ExtensionServiceInterface* extension_service, | |
61 sync_api::UserShare* user_share); | |
62 | |
63 // Updates the server data for the given extension. Returns true iff | |
64 // this was successful; if unsuccessful, an error string is put into | |
65 // |error|. | |
66 // | |
67 // TODO(akalin): Remove dependence on Extension once we have the | |
68 // ExtensionService push changes onto us. | |
69 bool UpdateServerData(const ExtensionSyncTraits& traits, | |
70 const Extension& extension, | |
71 const ExtensionServiceInterface& extension_service, | |
72 sync_api::UserShare* user_share, | |
73 std::string* error); | |
74 | |
75 // Removes the server data for the given extension ID. | |
76 void RemoveServerData(const ExtensionSyncTraits& traits, | |
77 const std::string& id, | |
78 sync_api::UserShare* user_share); | |
79 | |
80 } // namespace browser_sync | |
81 | |
82 #endif // CHROME_BROWSER_SYNC_GLUE_EXTENSION_SYNC_H_ | |
OLD | NEW |