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

Side by Side Diff: chrome/browser/extensions/settings/setting_sync_data.h

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

Powered by Google App Engine
This is Rietveld 408576698