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

Side by Side Diff: chrome/browser/extensions/extension_setting_sync_data.h

Issue 7775008: Enable sync for the settings from the Extension Settings API. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Sync to tip. Latest comments. Created 9 years, 3 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) 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_EXTENSIONS_EXTENSION_SETTING_SYNC_DATA_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTING_SYNC_DATA_H_
7 #pragma once
8
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/values.h"
12 #include "chrome/browser/sync/api/sync_change.h"
13
14 class SyncData;
15
16 // Container for data interpreted from sync data/changes. Safe and efficient
17 // to copy.
18 class ExtensionSettingSyncData {
19 public:
20 // Creates from a sync change.
21 explicit ExtensionSettingSyncData(const SyncChange& sync_change);
22
23 // Creates from sync data. change_type will be ACTION_INVALID.
24 explicit ExtensionSettingSyncData(const SyncData& sync_data);
25
26 // Creates explicitly.
27 ExtensionSettingSyncData(
28 SyncChange::SyncChangeType change_type,
29 const std::string& extension_id,
30 const std::string& key,
31 // May NOT be NULL. Ownership taken.
32 Value* value);
33
34 ~ExtensionSettingSyncData();
35
36 // Returns the type of the sync change; may be ACTION_INVALID.
37 SyncChange::SyncChangeType change_type() const;
38
39 // Returns the extension id the setting is for.
40 const std::string& extension_id() const;
41
42 // Returns the settings key.
43 const std::string& key() const;
44
45 // Returns the value of the setting.
46 const Value& value() const;
47
48 private:
49 // Ref-counted container for the data.
50 // TODO(kalman): Use browser_sync::Immutable<Internal>.
51 class Internal : public base::RefCountedThreadSafe<Internal> {
52 public:
53 explicit Internal(
54 SyncChange::SyncChangeType change_type,
55 const std::string& extension_id,
56 const std::string& key,
57 Value* value);
58
59 SyncChange::SyncChangeType change_type_;
60 std::string extension_id_;
61 std::string key_;
62 scoped_ptr<Value> value_;
63
64 private:
65 friend class base::RefCountedThreadSafe<Internal>;
66 ~Internal();
67 };
68
69 // Initializes internal_ from sync data.
70 void Init(SyncChange::SyncChangeType change_type, const SyncData& sync_data);
71
72 scoped_refptr<Internal> internal_;
73 };
74
75 typedef std::vector<ExtensionSettingSyncData> ExtensionSettingSyncDataList;
76
77 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTING_SYNC_DATA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698