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

Side by Side Diff: chrome/browser/sync/glue/extension_util.h

Issue 6902054: [Sync] Rip out overly-complicated ExtensionData class (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed asargent's comments Created 9 years, 8 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 | Annotate | Revision Log
OLDNEW
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_EXTENSION_UTIL_H_ 5 #ifndef CHROME_BROWSER_SYNC_GLUE_EXTENSION_UTIL_H_
6 #define CHROME_BROWSER_SYNC_GLUE_EXTENSION_UTIL_H_ 6 #define CHROME_BROWSER_SYNC_GLUE_EXTENSION_UTIL_H_
7 #pragma once 7 #pragma once
8 8
9 // This file contains some low-level utility functions used by 9 // This file contains some low-level utility functions used by
10 // extensions sync. 10 // extensions sync.
11 11
12 #include <string> 12 #include <string>
13 13
14 class Extension; 14 class Extension;
15 class ExtensionServiceInterface;
16 struct ExtensionSyncData; 15 struct ExtensionSyncData;
17 16
18 namespace sync_pb { 17 namespace sync_pb {
19 class ExtensionSpecifics; 18 class ExtensionSpecifics;
20 } // sync_pb 19 } // sync_pb
21 20
22 namespace browser_sync { 21 namespace browser_sync {
23 22
24 // Returns whether or not the given extension is one we want to sync. 23 // Returns whether or not the given extension is one we want to sync.
25 bool IsExtensionValid(const Extension& extension); 24 bool IsExtensionValid(const Extension& extension);
26 25
27 // Stringifies the given ExtensionSpecifics. 26 // Stringifies the given ExtensionSpecifics.
28 std::string ExtensionSpecificsToString( 27 std::string ExtensionSpecificsToString(
29 const sync_pb::ExtensionSpecifics& specifics); 28 const sync_pb::ExtensionSpecifics& specifics);
30 29
31 // Returns whether or not the values of the given specifics are valid,
32 // in particular the id, version, and update URL.
33 bool IsExtensionSpecificsValid(
34 const sync_pb::ExtensionSpecifics& specifics);
35
36 // Equivalent to DCHECK(IsExtensionSpecificsValid(specifics)) <<
37 // ExtensionSpecificsToString(specifics);
38 void DcheckIsExtensionSpecificsValid(
39 const sync_pb::ExtensionSpecifics& specifics);
40
41 // Returns true iff two ExtensionSpecifics denote the same extension
42 // state. Neither |a| nor |b| need to be valid.
43 bool AreExtensionSpecificsEqual(const sync_pb::ExtensionSpecifics& a,
44 const sync_pb::ExtensionSpecifics& b);
45
46 // Returns true iff the given ExtensionSpecifics is equal to the empty
47 // ExtensionSpecifics object. |specifics| does not have to be valid
48 // and indeed, IsExtensionSpecificsValid(specifics) ->
49 // !IsExtensionSpecificsUnset(specifics).
50 bool IsExtensionSpecificsUnset(
51 const sync_pb::ExtensionSpecifics& specifics);
52
53 // Copies the user properties from |specifics| into |dest_specifics|.
54 // User properties are properties that are set by the user, i.e. not
55 // inherent to the extension. Currently they include |enabled| and
56 // |incognito_enabled|. Neither parameter need be valid.
57 void CopyUserProperties(
58 const sync_pb::ExtensionSpecifics& specifics,
59 sync_pb::ExtensionSpecifics* dest_specifics);
60
61 // Copies everything but non-user properties. Neither parameter need
62 // be valid.
63 void CopyNonUserProperties(
64 const sync_pb::ExtensionSpecifics& specifics,
65 sync_pb::ExtensionSpecifics* dest_specifics);
66
67 // Returns true iff two ExtensionSpecifics have the same user
68 // properties. Neither |a| nor |b| need to be valid.
69 bool AreExtensionSpecificsUserPropertiesEqual(
70 const sync_pb::ExtensionSpecifics& a,
71 const sync_pb::ExtensionSpecifics& b);
72
73 // Returns true iff two ExtensionSpecifics have the same non-user
74 // properties. Neither |a| nor |b| need to be valid.
75 bool AreExtensionSpecificsNonUserPropertiesEqual(
76 const sync_pb::ExtensionSpecifics& a,
77 const sync_pb::ExtensionSpecifics& b);
78
79 // Merge |specifics| into |merged_specifics|. Both must be valid and
80 // have the same ID. The merge policy is currently to copy the
81 // non-user properties of |specifics| into |merged_specifics| (and the
82 // user properties if |merge_user_properties| is set) if |specifics|
83 // has a more recent or the same version as |merged_specifics|.
84 void MergeExtensionSpecifics(
85 const sync_pb::ExtensionSpecifics& specifics,
86 bool merge_user_properties,
87 sync_pb::ExtensionSpecifics* merged_specifics);
88
89 // Fills |sync_data| with the data from |specifics|. Returns true iff 30 // Fills |sync_data| with the data from |specifics|. Returns true iff
90 // succesful. 31 // succesful.
91 bool SpecificsToSyncData( 32 bool SpecificsToSyncData(
92 const sync_pb::ExtensionSpecifics& specifics, 33 const sync_pb::ExtensionSpecifics& specifics,
93 ExtensionSyncData* sync_data); 34 ExtensionSyncData* sync_data);
94 35
95 // Fills |specifics| with the data from |sync_data|. 36 // Fills |specifics| with the data from |sync_data|.
96 void SyncDataToSpecifics( 37 void SyncDataToSpecifics(
97 const ExtensionSyncData& sync_data, 38 const ExtensionSyncData& sync_data,
98 sync_pb::ExtensionSpecifics* specifics); 39 sync_pb::ExtensionSpecifics* specifics);
99 40
100 } // namespace browser_sync 41 } // namespace browser_sync
101 42
102 #endif // CHROME_BROWSER_SYNC_GLUE_EXTENSION_UTIL_H_ 43 #endif // CHROME_BROWSER_SYNC_GLUE_EXTENSION_UTIL_H_
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/extension_sync_traits.cc ('k') | chrome/browser/sync/glue/extension_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698