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

Side by Side Diff: chrome/browser/ui/webui/quota_internals/quota_internals_types.cc

Issue 2086763002: Don't use deprecated ListValue::Append(Value*) overload. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 6 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) 2011 The Chromium Authors. All rights reserved. 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 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/ui/webui/quota_internals/quota_internals_types.h" 5 #include "chrome/browser/ui/webui/quota_internals/quota_internals_types.h"
6 6
7 #include <memory> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "net/base/url_util.h" 11 #include "net/base/url_util.h"
12 12
13 namespace { 13 namespace {
14 14
15 std::string StorageTypeToString(storage::StorageType type) { 15 std::string StorageTypeToString(storage::StorageType type) {
16 switch (type) { 16 switch (type) {
17 case storage::kStorageTypeTemporary: 17 case storage::kStorageTypeTemporary:
(...skipping 13 matching lines...) Expand all
31 } // anonymous namespace 31 } // anonymous namespace
32 32
33 namespace quota_internals { 33 namespace quota_internals {
34 34
35 GlobalStorageInfo::GlobalStorageInfo(storage::StorageType type) 35 GlobalStorageInfo::GlobalStorageInfo(storage::StorageType type)
36 : type_(type), usage_(-1), unlimited_usage_(-1), quota_(-1) { 36 : type_(type), usage_(-1), unlimited_usage_(-1), quota_(-1) {
37 } 37 }
38 38
39 GlobalStorageInfo::~GlobalStorageInfo() {} 39 GlobalStorageInfo::~GlobalStorageInfo() {}
40 40
41 base::Value* GlobalStorageInfo::NewValue() const { 41 std::unique_ptr<base::Value> GlobalStorageInfo::NewValue() const {
42 // TODO(tzik): Add CreateLongIntegerValue to base/values.h and remove 42 // TODO(tzik): Add CreateLongIntegerValue to base/values.h and remove
43 // all static_cast<double> in this file. 43 // all static_cast<double> in this file.
44 base::DictionaryValue* dict = new base::DictionaryValue; 44 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
45 dict->SetString("type", StorageTypeToString(type_)); 45 dict->SetString("type", StorageTypeToString(type_));
46 if (usage_ >= 0) 46 if (usage_ >= 0)
47 dict->SetDouble("usage", static_cast<double>(usage_)); 47 dict->SetDouble("usage", static_cast<double>(usage_));
48 if (unlimited_usage_ >= 0) 48 if (unlimited_usage_ >= 0)
49 dict->SetDouble("unlimitedUsage", static_cast<double>(unlimited_usage_)); 49 dict->SetDouble("unlimitedUsage", static_cast<double>(unlimited_usage_));
50 if (quota_ >= 0) 50 if (quota_ >= 0)
51 dict->SetDouble("quota", static_cast<double>(quota_)); 51 dict->SetDouble("quota", static_cast<double>(quota_));
52 return dict; 52 return std::move(dict);
53 } 53 }
54 54
55 PerHostStorageInfo::PerHostStorageInfo(const std::string& host, 55 PerHostStorageInfo::PerHostStorageInfo(const std::string& host,
56 storage::StorageType type) 56 storage::StorageType type)
57 : host_(host), type_(type), usage_(-1), quota_(-1) { 57 : host_(host), type_(type), usage_(-1), quota_(-1) {
58 } 58 }
59 59
60 PerHostStorageInfo::~PerHostStorageInfo() {} 60 PerHostStorageInfo::~PerHostStorageInfo() {}
61 61
62 base::Value* PerHostStorageInfo::NewValue() const { 62 std::unique_ptr<base::Value> PerHostStorageInfo::NewValue() const {
63 base::DictionaryValue* dict = new base::DictionaryValue; 63 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
64 DCHECK(!host_.empty()); 64 DCHECK(!host_.empty());
65 dict->SetString("host", host_); 65 dict->SetString("host", host_);
66 dict->SetString("type", StorageTypeToString(type_)); 66 dict->SetString("type", StorageTypeToString(type_));
67 if (usage_ >= 0) 67 if (usage_ >= 0)
68 dict->SetDouble("usage", static_cast<double>(usage_)); 68 dict->SetDouble("usage", static_cast<double>(usage_));
69 if (quota_ >= 0) 69 if (quota_ >= 0)
70 dict->SetDouble("quota", static_cast<double>(quota_)); 70 dict->SetDouble("quota", static_cast<double>(quota_));
71 return dict; 71 return std::move(dict);
72 } 72 }
73 73
74 PerOriginStorageInfo::PerOriginStorageInfo(const GURL& origin, 74 PerOriginStorageInfo::PerOriginStorageInfo(const GURL& origin,
75 storage::StorageType type) 75 storage::StorageType type)
76 : origin_(origin), 76 : origin_(origin),
77 type_(type), 77 type_(type),
78 host_(net::GetHostOrSpecFromURL(origin)), 78 host_(net::GetHostOrSpecFromURL(origin)),
79 in_use_(-1), 79 in_use_(-1),
80 used_count_(-1) { 80 used_count_(-1) {
81 } 81 }
82 82
83 PerOriginStorageInfo::PerOriginStorageInfo(const PerOriginStorageInfo& other) = 83 PerOriginStorageInfo::PerOriginStorageInfo(const PerOriginStorageInfo& other) =
84 default; 84 default;
85 85
86 PerOriginStorageInfo::~PerOriginStorageInfo() {} 86 PerOriginStorageInfo::~PerOriginStorageInfo() {}
87 87
88 base::Value* PerOriginStorageInfo::NewValue() const { 88 std::unique_ptr<base::Value> PerOriginStorageInfo::NewValue() const {
89 base::DictionaryValue* dict = new base::DictionaryValue; 89 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
90 DCHECK(!origin_.is_empty()); 90 DCHECK(!origin_.is_empty());
91 DCHECK(!host_.empty()); 91 DCHECK(!host_.empty());
92 dict->SetString("origin", origin_.spec()); 92 dict->SetString("origin", origin_.spec());
93 dict->SetString("type", StorageTypeToString(type_)); 93 dict->SetString("type", StorageTypeToString(type_));
94 dict->SetString("host", host_); 94 dict->SetString("host", host_);
95 if (in_use_ >= 0) 95 if (in_use_ >= 0)
96 dict->SetBoolean("inUse", (in_use_ > 0)); 96 dict->SetBoolean("inUse", (in_use_ > 0));
97 if (used_count_ >= 0) 97 if (used_count_ >= 0)
98 dict->SetInteger("usedCount", used_count_); 98 dict->SetInteger("usedCount", used_count_);
99 if (!last_access_time_.is_null()) 99 if (!last_access_time_.is_null())
100 dict->SetDouble("lastAccessTime", last_access_time_.ToDoubleT() * 1000.0); 100 dict->SetDouble("lastAccessTime", last_access_time_.ToDoubleT() * 1000.0);
101 if (!last_modified_time_.is_null()) { 101 if (!last_modified_time_.is_null()) {
102 dict->SetDouble("lastModifiedTime", 102 dict->SetDouble("lastModifiedTime",
103 last_modified_time_.ToDoubleT() * 1000.0); 103 last_modified_time_.ToDoubleT() * 1000.0);
104 } 104 }
105 return dict; 105 return std::move(dict);
106 } 106 }
107 107
108 } // namespace quota_internals 108 } // namespace quota_internals
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698