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

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

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 #include "chrome/browser/extensions/api/storage/setting_sync_data.h" 5 #include "chrome/browser/extensions/api/storage/setting_sync_data.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 10 matching lines...) Expand all
21 } 21 }
22 22
23 SettingSyncData::SettingSyncData(const syncer::SyncData& sync_data) 23 SettingSyncData::SettingSyncData(const syncer::SyncData& sync_data)
24 : change_type_(syncer::SyncChange::ACTION_INVALID) { 24 : change_type_(syncer::SyncChange::ACTION_INVALID) {
25 ExtractSyncData(sync_data); 25 ExtractSyncData(sync_data);
26 } 26 }
27 27
28 SettingSyncData::SettingSyncData(syncer::SyncChange::SyncChangeType change_type, 28 SettingSyncData::SettingSyncData(syncer::SyncChange::SyncChangeType change_type,
29 const std::string& extension_id, 29 const std::string& extension_id,
30 const std::string& key, 30 const std::string& key,
31 scoped_ptr<base::Value> value) 31 std::unique_ptr<base::Value> value)
32 : change_type_(change_type), 32 : change_type_(change_type),
33 extension_id_(extension_id), 33 extension_id_(extension_id),
34 key_(key), 34 key_(key),
35 value_(std::move(value)) {} 35 value_(std::move(value)) {}
36 36
37 SettingSyncData::~SettingSyncData() {} 37 SettingSyncData::~SettingSyncData() {}
38 38
39 scoped_ptr<base::Value> SettingSyncData::PassValue() { 39 std::unique_ptr<base::Value> SettingSyncData::PassValue() {
40 DCHECK(value_) << "value has already been Pass()ed"; 40 DCHECK(value_) << "value has already been Pass()ed";
41 return std::move(value_); 41 return std::move(value_);
42 } 42 }
43 43
44 void SettingSyncData::ExtractSyncData(const syncer::SyncData& sync_data) { 44 void SettingSyncData::ExtractSyncData(const syncer::SyncData& sync_data) {
45 sync_pb::EntitySpecifics specifics = sync_data.GetSpecifics(); 45 sync_pb::EntitySpecifics specifics = sync_data.GetSpecifics();
46 // The specifics are exclusively either extension or app settings. 46 // The specifics are exclusively either extension or app settings.
47 DCHECK_NE(specifics.has_extension_setting(), specifics.has_app_setting()); 47 DCHECK_NE(specifics.has_extension_setting(), specifics.has_app_setting());
48 const sync_pb::ExtensionSettingSpecifics& extension_specifics = 48 const sync_pb::ExtensionSettingSpecifics& extension_specifics =
49 specifics.has_extension_setting() 49 specifics.has_extension_setting()
50 ? specifics.extension_setting() 50 ? specifics.extension_setting()
51 : specifics.app_setting().extension_setting(); 51 : specifics.app_setting().extension_setting();
52 52
53 extension_id_ = extension_specifics.extension_id(); 53 extension_id_ = extension_specifics.extension_id();
54 key_ = extension_specifics.key(); 54 key_ = extension_specifics.key();
55 value_ = base::JSONReader::Read(extension_specifics.value()); 55 value_ = base::JSONReader::Read(extension_specifics.value());
56 56
57 if (!value_) { 57 if (!value_) {
58 LOG(WARNING) << "Specifics for " << extension_id_ << "/" << key_ 58 LOG(WARNING) << "Specifics for " << extension_id_ << "/" << key_
59 << " had bad JSON for value: " << extension_specifics.value(); 59 << " had bad JSON for value: " << extension_specifics.value();
60 value_.reset(new base::DictionaryValue()); 60 value_.reset(new base::DictionaryValue());
61 } 61 }
62 } 62 }
63 63
64 } // namespace extensions 64 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/storage/setting_sync_data.h ('k') | chrome/browser/extensions/api/storage/settings_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698