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

Side by Side Diff: chrome/browser/extensions/api/storage/setting_sync_data.h

Issue 11826048: Revert 176015 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 11 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTING_SYNC_DATA_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTING_SYNC_DATA_H_
7
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/values.h"
11 #include "sync/api/sync_change.h"
12
13 namespace syncer {
14 class SyncData;
15 }
16
17 namespace sync_pb {
18 class ExtensionSettingSpecifics;
19 }
20
21 namespace extensions {
22
23 // Container for data interpreted from sync data/changes for an extension or
24 // app setting. Safe and efficient to copy.
25 class SettingSyncData {
26 public:
27 // Creates from a sync change.
28 explicit SettingSyncData(const syncer::SyncChange& sync_change);
29
30 // Creates from sync data. |change_type| will be ACTION_INVALID.
31 explicit SettingSyncData(const syncer::SyncData& sync_data);
32
33 // Creates explicitly.
34 SettingSyncData(
35 syncer::SyncChange::SyncChangeType change_type,
36 const std::string& extension_id,
37 const std::string& key,
38 scoped_ptr<Value> value);
39
40 ~SettingSyncData();
41
42 // Returns the type of the sync change; may be ACTION_INVALID.
43 syncer::SyncChange::SyncChangeType change_type() const;
44
45 // Returns the extension id the setting is for.
46 const std::string& extension_id() const;
47
48 // Returns the settings key.
49 const std::string& key() const;
50
51 // Returns the value of the setting.
52 const Value& value() const;
53
54 private:
55 // Ref-counted container for the data.
56 // TODO(kalman): Use browser_sync::Immutable<Internal>.
57 class Internal : public base::RefCountedThreadSafe<Internal> {
58 public:
59 Internal(
60 syncer::SyncChange::SyncChangeType change_type,
61 const std::string& extension_id,
62 const std::string& key,
63 scoped_ptr<Value> value);
64
65 syncer::SyncChange::SyncChangeType change_type_;
66 std::string extension_id_;
67 std::string key_;
68 scoped_ptr<Value> value_;
69
70 private:
71 friend class base::RefCountedThreadSafe<Internal>;
72 ~Internal();
73 };
74
75 // Initializes internal_ from sync data for an extension or app setting.
76 void Init(syncer::SyncChange::SyncChangeType change_type,
77 const syncer::SyncData& sync_data);
78
79 // Initializes internal_ from extension specifics.
80 void InitFromExtensionSettingSpecifics(
81 syncer::SyncChange::SyncChangeType change_type,
82 const sync_pb::ExtensionSettingSpecifics& specifics);
83
84 scoped_refptr<Internal> internal_;
85 };
86
87 typedef std::vector<SettingSyncData> SettingSyncDataList;
88
89 } // namespace extensions
90
91 #endif // CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTING_SYNC_DATA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698