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_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_data.h" | |
13 #include "chrome/browser/sync/api/sync_change.h" | |
14 | |
15 // Container for data interpreted from sync data/changes. Safe and efficient | |
16 // to copy. | |
17 class ExtensionSettingSyncData { | |
18 public: | |
19 // Creates from a sync change. | |
20 explicit ExtensionSettingSyncData(const SyncChange& sync_change); | |
21 | |
22 // Creates from sync data. change_type will be ACTION_INVALID. | |
23 explicit ExtensionSettingSyncData(const SyncData& sync_data); | |
24 | |
25 ExtensionSettingSyncData( | |
26 SyncChange::SyncChangeType change_type, | |
27 const std::string& extension_id, | |
28 const std::string& key, | |
29 // May be NULL. Ownership taken if not. | |
30 Value* value); | |
31 | |
32 ~ExtensionSettingSyncData(); | |
33 | |
34 // Returns the type of the sync change; may be ACTION_INVALID. | |
35 SyncChange::SyncChangeType change_type() const; | |
36 | |
37 // Returns the extension id the setting is for. | |
38 const std::string& extension_id() const; | |
39 | |
40 // Returns the settings key. | |
41 const std::string& key() const; | |
42 | |
43 // Returns the value of the setting, possibly NULL. | |
44 // Ownership NOT given up. | |
45 const Value* value() const; | |
akalin
2011/09/15 19:56:44
should return const Value&
not at google - send to devlin
2011/09/16 05:18:59
Done.
| |
46 | |
47 private: | |
48 // Ref-counted container for the data. | |
akalin
2011/09/15 19:56:44
Add TODO to use Immutable<T> (see http://coderevie
not at google - send to devlin
2011/09/16 05:18:59
Done.
| |
49 class Internal : public base::RefCountedThreadSafe<Internal> { | |
50 public: | |
51 explicit Internal( | |
52 SyncChange::SyncChangeType change_type, | |
53 const std::string& extension_id, | |
54 const std::string& key, | |
55 Value* value); | |
56 | |
57 SyncChange::SyncChangeType change_type_; | |
58 std::string extension_id_; | |
59 std::string key_; | |
60 scoped_ptr<Value> value_; | |
61 | |
62 private: | |
63 friend class base::RefCountedThreadSafe<Internal>; | |
64 virtual ~Internal(); | |
akalin
2011/09/15 19:56:44
no need for virtual
not at google - send to devlin
2011/09/16 05:18:59
IIRC clang complains if a destructor isn't virtual
| |
65 }; | |
66 | |
67 scoped_refptr<Internal> internal_; | |
68 }; | |
69 | |
70 typedef std::vector<ExtensionSettingSyncData> ExtensionSettingSyncDataList; | |
71 | |
72 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTING_SYNC_DATA_H_ | |
OLD | NEW |