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 // Construct manually. | |
| 26 explicit ExtensionSettingSyncData( | |
|
akalin
2011/08/31 07:49:34
no need for explicit here
not at google - send to devlin
2011/09/02 05:00:40
Done.
| |
| 27 SyncChange::SyncChangeType change_type, | |
| 28 const std::string& extension_id, | |
| 29 const std::string& key, | |
| 30 // May be NULL. Ownership taken if not. | |
| 31 Value* value); | |
| 32 | |
| 33 ~ExtensionSettingSyncData(); | |
| 34 | |
| 35 // Returns the type of the sync change; may be INVALID if this is not | |
| 36 // constructed from a SyncChange. | |
| 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, possibly NULL. | |
| 46 // Ownership NOT given up. | |
| 47 const Value* value() const; | |
| 48 | |
| 49 // Returns a string representation of the data. | |
| 50 std::string ToString() const; | |
| 51 | |
| 52 private: | |
| 53 // Ref-counted container for the data. | |
| 54 class Internal : public base::RefCountedThreadSafe<Internal> { | |
| 55 public: | |
| 56 explicit Internal( | |
| 57 SyncChange::SyncChangeType change_type, | |
| 58 const std::string& extension_id, | |
| 59 const std::string& key, | |
| 60 Value* value); | |
| 61 | |
| 62 SyncChange::SyncChangeType change_type_; | |
| 63 std::string extension_id_; | |
| 64 std::string key_; | |
| 65 scoped_ptr<Value> value_; | |
| 66 | |
| 67 private: | |
| 68 friend class base::RefCountedThreadSafe<Internal>; | |
| 69 virtual ~Internal(); | |
| 70 }; | |
| 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_ | |
| OLD | NEW |