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_SETTINGS_SYNC_DATA_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_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 // XXX rename this to ExtensionSettingSyncData (*not plural*) |
| 18 class ExtensionSettingsSyncData { |
| 19 public: |
| 20 // Creates from a sync change. |
| 21 explicit ExtensionSettingsSyncData(const SyncChange& sync_change); |
| 22 |
| 23 // Creates from sync data. change_type will be ACTION_INVALID. |
| 24 explicit ExtensionSettingsSyncData(const SyncData& sync_data); |
| 25 |
| 26 // Construct manually. |
| 27 explicit ExtensionSettingsSyncData( |
| 28 SyncChange::SyncChangeType change_type, |
| 29 const std::string& extension_id, |
| 30 const std::string& key, |
| 31 // May be NULL. Ownership taken if not. |
| 32 Value* value); |
| 33 |
| 34 // Returns the type of the sync change; may be INVALID if this is not |
| 35 // constructed from a SyncChange. |
| 36 SyncChange::SyncChangeType change_type() const; |
| 37 |
| 38 // Returns the extension id the setting is for. |
| 39 const std::string& extension_id() const; |
| 40 |
| 41 // Returns the settings key. |
| 42 const std::string& key() const; |
| 43 |
| 44 // Returns the value of the setting, possibly NULL. |
| 45 // Ownership NOT given up. |
| 46 const Value* value() const; |
| 47 |
| 48 // Returns a string representation of the data. |
| 49 std::string ToString() const; |
| 50 |
| 51 private: |
| 52 // Ref-counted container for the data. |
| 53 class Internal : public base::RefCountedThreadSafe<Internal> { |
| 54 public: |
| 55 explicit Internal( |
| 56 SyncChange::SyncChangeType change_type, |
| 57 const std::string& extension_id, |
| 58 const std::string& key, |
| 59 Value* value); |
| 60 |
| 61 SyncChange::SyncChangeType change_type_; |
| 62 std::string extension_id_; |
| 63 std::string key_; |
| 64 scoped_ptr<Value> value_; |
| 65 |
| 66 private: |
| 67 friend class base::RefCountedThreadSafe<Internal>; |
| 68 ~Internal(); |
| 69 DISALLOW_COPY_AND_ASSIGN(Internal); |
| 70 }; |
| 71 |
| 72 scoped_refptr<Internal> internal_; |
| 73 }; |
| 74 |
| 75 typedef std::vector<ExtensionSettingsSyncData> ExtensionSettingsSyncDataList; |
| 76 |
| 77 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_SYNC_DATA_H_ |
OLD | NEW |