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

Side by Side Diff: chrome/browser/extensions/api/storage/setting_sync_data.h

Issue 1871713002: Convert //chrome/browser/extensions from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and fix header Created 4 years, 8 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_API_STORAGE_SETTING_SYNC_DATA_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTING_SYNC_DATA_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTING_SYNC_DATA_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTING_SYNC_DATA_H_
7 7
8 #include <memory>
8 #include <string> 9 #include <string>
9 10
10 #include "base/macros.h" 11 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/scoped_vector.h" 12 #include "base/memory/scoped_vector.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "sync/api/sync_change.h" 14 #include "sync/api/sync_change.h"
15 15
16 namespace syncer { 16 namespace syncer {
17 class SyncData; 17 class SyncData;
18 } 18 }
19 19
20 namespace sync_pb { 20 namespace sync_pb {
21 class ExtensionSettingSpecifics; 21 class ExtensionSettingSpecifics;
22 } 22 }
23 23
24 namespace extensions { 24 namespace extensions {
25 25
26 // Container for data interpreted from sync data/changes for an extension or 26 // Container for data interpreted from sync data/changes for an extension or
27 // app setting. Safe and efficient to copy. 27 // app setting. Safe and efficient to copy.
28 class SettingSyncData { 28 class SettingSyncData {
29 public: 29 public:
30 // Creates from a sync change. 30 // Creates from a sync change.
31 explicit SettingSyncData(const syncer::SyncChange& sync_change); 31 explicit SettingSyncData(const syncer::SyncChange& sync_change);
32 32
33 // Creates from sync data. |change_type| will be ACTION_INVALID. 33 // Creates from sync data. |change_type| will be ACTION_INVALID.
34 explicit SettingSyncData(const syncer::SyncData& sync_data); 34 explicit SettingSyncData(const syncer::SyncData& sync_data);
35 35
36 // Creates explicitly. 36 // Creates explicitly.
37 SettingSyncData( 37 SettingSyncData(syncer::SyncChange::SyncChangeType change_type,
38 syncer::SyncChange::SyncChangeType change_type, 38 const std::string& extension_id,
39 const std::string& extension_id, 39 const std::string& key,
40 const std::string& key, 40 std::unique_ptr<base::Value> value);
41 scoped_ptr<base::Value> value);
42 41
43 ~SettingSyncData(); 42 ~SettingSyncData();
44 43
45 // May return ACTION_INVALID if this object represents sync data that isn't 44 // May return ACTION_INVALID if this object represents sync data that isn't
46 // associated with a sync operation. 45 // associated with a sync operation.
47 syncer::SyncChange::SyncChangeType change_type() const { 46 syncer::SyncChange::SyncChangeType change_type() const {
48 return change_type_; 47 return change_type_;
49 } 48 }
50 const std::string& extension_id() const { return extension_id_; } 49 const std::string& extension_id() const { return extension_id_; }
51 const std::string& key() const { return key_; } 50 const std::string& key() const { return key_; }
52 // value() cannot be called if PassValue() has been called. 51 // value() cannot be called if PassValue() has been called.
53 const base::Value& value() const { return *value_; } 52 const base::Value& value() const { return *value_; }
54 53
55 // Releases ownership of the value to the caller. Neither value() nor 54 // Releases ownership of the value to the caller. Neither value() nor
56 // PassValue() can be after this. 55 // PassValue() can be after this.
57 scoped_ptr<base::Value> PassValue(); 56 std::unique_ptr<base::Value> PassValue();
58 57
59 private: 58 private:
60 // Populates the extension ID, key, and value from |sync_data|. This will be 59 // Populates the extension ID, key, and value from |sync_data|. This will be
61 // either an extension or app settings data type. 60 // either an extension or app settings data type.
62 void ExtractSyncData(const syncer::SyncData& sync_data); 61 void ExtractSyncData(const syncer::SyncData& sync_data);
63 62
64 syncer::SyncChange::SyncChangeType change_type_; 63 syncer::SyncChange::SyncChangeType change_type_;
65 std::string extension_id_; 64 std::string extension_id_;
66 std::string key_; 65 std::string key_;
67 scoped_ptr<base::Value> value_; 66 std::unique_ptr<base::Value> value_;
68 67
69 DISALLOW_COPY_AND_ASSIGN(SettingSyncData); 68 DISALLOW_COPY_AND_ASSIGN(SettingSyncData);
70 }; 69 };
71 70
72 typedef ScopedVector<SettingSyncData> SettingSyncDataList; 71 typedef ScopedVector<SettingSyncData> SettingSyncDataList;
73 72
74 } // namespace extensions 73 } // namespace extensions
75 74
76 #endif // CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTING_SYNC_DATA_H_ 75 #endif // CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTING_SYNC_DATA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698