Chromium Code Reviews| 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. | |
|
akalin
2011/09/17 08:44:47
fix comment
not at google - send to devlin
2011/09/19 07:10:47
Done.
| |
| 44 // Ownership NOT given up. | |
| 45 const Value& value() const; | |
| 46 | |
| 47 private: | |
| 48 // Ref-counted container for the data. | |
| 49 // TODO(kalman): Use browser_sync::Immutable<Internal>. | |
| 50 class Internal : public base::RefCountedThreadSafe<Internal> { | |
| 51 public: | |
| 52 explicit Internal( | |
| 53 SyncChange::SyncChangeType change_type, | |
| 54 const std::string& extension_id, | |
| 55 const std::string& key, | |
| 56 Value* value); | |
| 57 | |
| 58 SyncChange::SyncChangeType change_type_; | |
| 59 std::string extension_id_; | |
| 60 std::string key_; | |
| 61 scoped_ptr<Value> value_; | |
| 62 | |
| 63 private: | |
| 64 friend class base::RefCountedThreadSafe<Internal>; | |
| 65 ~Internal(); | |
| 66 }; | |
| 67 | |
| 68 // Initializes internal_ from sync data. | |
| 69 void Init(SyncChange::SyncChangeType change_type, const SyncData& sync_data); | |
| 70 | |
| 71 scoped_refptr<Internal> internal_; | |
| 72 }; | |
| 73 | |
| 74 typedef std::vector<ExtensionSettingSyncData> ExtensionSettingSyncDataList; | |
| 75 | |
| 76 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTING_SYNC_DATA_H_ | |
| OLD | NEW |