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

Side by Side Diff: content/browser/appcache/appcache_internals_ui.cc

Issue 1874893002: Convert //content/browser from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "content/browser/appcache/appcache_internals_ui.h" 5 #include "content/browser/appcache/appcache_internals_ui.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 int64_t i = 0; 48 int64_t i = 0;
49 base::StringToInt64(str.c_str(), &i); 49 base::StringToInt64(str.c_str(), &i);
50 return i; 50 return i;
51 } 51 }
52 52
53 bool SortByResourceUrl(const AppCacheResourceInfo& lhs, 53 bool SortByResourceUrl(const AppCacheResourceInfo& lhs,
54 const AppCacheResourceInfo& rhs) { 54 const AppCacheResourceInfo& rhs) {
55 return lhs.url.spec() < rhs.url.spec(); 55 return lhs.url.spec() < rhs.url.spec();
56 } 56 }
57 57
58 scoped_ptr<base::DictionaryValue> GetDictionaryValueForResponseEnquiry( 58 std::unique_ptr<base::DictionaryValue> GetDictionaryValueForResponseEnquiry(
59 const content::AppCacheInternalsUI::Proxy::ResponseEnquiry& 59 const content::AppCacheInternalsUI::Proxy::ResponseEnquiry&
60 response_enquiry) { 60 response_enquiry) {
61 scoped_ptr<base::DictionaryValue> dict_value(new base::DictionaryValue()); 61 std::unique_ptr<base::DictionaryValue> dict_value(
62 new base::DictionaryValue());
62 dict_value->SetString("manifestURL", response_enquiry.manifest_url); 63 dict_value->SetString("manifestURL", response_enquiry.manifest_url);
63 dict_value->SetString("groupId", 64 dict_value->SetString("groupId",
64 base::Int64ToString(response_enquiry.group_id)); 65 base::Int64ToString(response_enquiry.group_id));
65 dict_value->SetString("responseId", 66 dict_value->SetString("responseId",
66 base::Int64ToString(response_enquiry.response_id)); 67 base::Int64ToString(response_enquiry.response_id));
67 return dict_value; 68 return dict_value;
68 } 69 }
69 70
70 scoped_ptr<base::DictionaryValue> GetDictionaryValueForAppCacheInfo( 71 std::unique_ptr<base::DictionaryValue> GetDictionaryValueForAppCacheInfo(
71 const content::AppCacheInfo& appcache_info) { 72 const content::AppCacheInfo& appcache_info) {
72 scoped_ptr<base::DictionaryValue> dict_value(new base::DictionaryValue()); 73 std::unique_ptr<base::DictionaryValue> dict_value(
74 new base::DictionaryValue());
73 dict_value->SetString("manifestURL", appcache_info.manifest_url.spec()); 75 dict_value->SetString("manifestURL", appcache_info.manifest_url.spec());
74 dict_value->SetDouble("creationTime", appcache_info.creation_time.ToJsTime()); 76 dict_value->SetDouble("creationTime", appcache_info.creation_time.ToJsTime());
75 dict_value->SetDouble("lastUpdateTime", 77 dict_value->SetDouble("lastUpdateTime",
76 appcache_info.last_update_time.ToJsTime()); 78 appcache_info.last_update_time.ToJsTime());
77 dict_value->SetDouble("lastAccessTime", 79 dict_value->SetDouble("lastAccessTime",
78 appcache_info.last_access_time.ToJsTime()); 80 appcache_info.last_access_time.ToJsTime());
79 dict_value->SetString( 81 dict_value->SetString(
80 "size", 82 "size",
81 base::UTF16ToUTF8(base::FormatBytesUnlocalized(appcache_info.size))); 83 base::UTF16ToUTF8(base::FormatBytesUnlocalized(appcache_info.size)));
82 dict_value->SetString("groupId", base::Int64ToString(appcache_info.group_id)); 84 dict_value->SetString("groupId", base::Int64ToString(appcache_info.group_id));
83 85
84 return dict_value; 86 return dict_value;
85 } 87 }
86 88
87 scoped_ptr<base::ListValue> GetListValueForAppCacheInfoVector( 89 std::unique_ptr<base::ListValue> GetListValueForAppCacheInfoVector(
88 const AppCacheInfoVector& appcache_info_vector) { 90 const AppCacheInfoVector& appcache_info_vector) {
89 scoped_ptr<base::ListValue> list(new base::ListValue()); 91 std::unique_ptr<base::ListValue> list(new base::ListValue());
90 for (const AppCacheInfo& info : appcache_info_vector) 92 for (const AppCacheInfo& info : appcache_info_vector)
91 list->Append(GetDictionaryValueForAppCacheInfo(info)); 93 list->Append(GetDictionaryValueForAppCacheInfo(info));
92 return list; 94 return list;
93 } 95 }
94 96
95 scoped_ptr<base::ListValue> GetListValueFromAppCacheInfoCollection( 97 std::unique_ptr<base::ListValue> GetListValueFromAppCacheInfoCollection(
96 AppCacheInfoCollection* appcache_collection) { 98 AppCacheInfoCollection* appcache_collection) {
97 scoped_ptr<base::ListValue> list(new base::ListValue()); 99 std::unique_ptr<base::ListValue> list(new base::ListValue());
98 for (const auto& key_value : appcache_collection->infos_by_origin) { 100 for (const auto& key_value : appcache_collection->infos_by_origin) {
99 base::DictionaryValue* dict = new base::DictionaryValue; 101 base::DictionaryValue* dict = new base::DictionaryValue;
100 dict->SetString("originURL", key_value.first.spec()); 102 dict->SetString("originURL", key_value.first.spec());
101 dict->Set("manifests", GetListValueForAppCacheInfoVector(key_value.second)); 103 dict->Set("manifests", GetListValueForAppCacheInfoVector(key_value.second));
102 list->Append(scoped_ptr<base::Value>(dict)); 104 list->Append(std::unique_ptr<base::Value>(dict));
103 } 105 }
104 return list; 106 return list;
105 } 107 }
106 108
107 scoped_ptr<base::DictionaryValue> GetDictionaryValueForAppCacheResourceInfo( 109 std::unique_ptr<base::DictionaryValue>
110 GetDictionaryValueForAppCacheResourceInfo(
108 const AppCacheResourceInfo& resource_info) { 111 const AppCacheResourceInfo& resource_info) {
109 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); 112 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
110 dict->SetString("url", resource_info.url.spec()); 113 dict->SetString("url", resource_info.url.spec());
111 dict->SetString( 114 dict->SetString(
112 "size", 115 "size",
113 base::UTF16ToUTF8(base::FormatBytesUnlocalized(resource_info.size))); 116 base::UTF16ToUTF8(base::FormatBytesUnlocalized(resource_info.size)));
114 dict->SetString("responseId", base::Int64ToString(resource_info.response_id)); 117 dict->SetString("responseId", base::Int64ToString(resource_info.response_id));
115 dict->SetBoolean("isExplicit", resource_info.is_explicit); 118 dict->SetBoolean("isExplicit", resource_info.is_explicit);
116 dict->SetBoolean("isManifest", resource_info.is_manifest); 119 dict->SetBoolean("isManifest", resource_info.is_manifest);
117 dict->SetBoolean("isMaster", resource_info.is_master); 120 dict->SetBoolean("isMaster", resource_info.is_master);
118 dict->SetBoolean("isFallback", resource_info.is_fallback); 121 dict->SetBoolean("isFallback", resource_info.is_fallback);
119 dict->SetBoolean("isIntercept", resource_info.is_intercept); 122 dict->SetBoolean("isIntercept", resource_info.is_intercept);
120 dict->SetBoolean("isForeign", resource_info.is_foreign); 123 dict->SetBoolean("isForeign", resource_info.is_foreign);
121 124
122 return dict; 125 return dict;
123 } 126 }
124 127
125 scoped_ptr<base::ListValue> GetListValueForAppCacheResourceInfoVector( 128 std::unique_ptr<base::ListValue> GetListValueForAppCacheResourceInfoVector(
126 AppCacheResourceInfoVector* resource_info_vector) { 129 AppCacheResourceInfoVector* resource_info_vector) {
127 scoped_ptr<base::ListValue> list(new base::ListValue); 130 std::unique_ptr<base::ListValue> list(new base::ListValue);
128 for (const AppCacheResourceInfo& res_info : *resource_info_vector) 131 for (const AppCacheResourceInfo& res_info : *resource_info_vector)
129 list->Append(GetDictionaryValueForAppCacheResourceInfo(res_info)); 132 list->Append(GetDictionaryValueForAppCacheResourceInfo(res_info));
130 return list; 133 return list;
131 } 134 }
132 135
133 } // namespace 136 } // namespace
134 137
135 AppCacheInternalsUI::Proxy::Proxy( 138 AppCacheInternalsUI::Proxy::Proxy(
136 base::WeakPtr<AppCacheInternalsUI> appcache_internals_ui, 139 base::WeakPtr<AppCacheInternalsUI> appcache_internals_ui,
137 const base::FilePath& partition_path) 140 const base::FilePath& partition_path)
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 base::Bind(&Proxy::RequestAppCacheDetails, this, manifest_url)); 229 base::Bind(&Proxy::RequestAppCacheDetails, this, manifest_url));
227 return; 230 return;
228 } 231 }
229 232
230 if (appcache_service_) 233 if (appcache_service_)
231 appcache_service_->storage()->LoadOrCreateGroup(GURL(manifest_url), this); 234 appcache_service_->storage()->LoadOrCreateGroup(GURL(manifest_url), this);
232 } 235 }
233 236
234 void AppCacheInternalsUI::Proxy::OnGroupLoaded(AppCacheGroup* appcache_group, 237 void AppCacheInternalsUI::Proxy::OnGroupLoaded(AppCacheGroup* appcache_group,
235 const GURL& manifest_gurl) { 238 const GURL& manifest_gurl) {
236 scoped_ptr<AppCacheResourceInfoVector> resource_info_vector; 239 std::unique_ptr<AppCacheResourceInfoVector> resource_info_vector;
237 if (appcache_group && appcache_group->newest_complete_cache()) { 240 if (appcache_group && appcache_group->newest_complete_cache()) {
238 resource_info_vector.reset(new AppCacheResourceInfoVector); 241 resource_info_vector.reset(new AppCacheResourceInfoVector);
239 appcache_group->newest_complete_cache()->ToResourceInfoVector( 242 appcache_group->newest_complete_cache()->ToResourceInfoVector(
240 resource_info_vector.get()); 243 resource_info_vector.get());
241 std::sort(resource_info_vector->begin(), resource_info_vector->end(), 244 std::sort(resource_info_vector->begin(), resource_info_vector->end(),
242 SortByResourceUrl); 245 SortByResourceUrl);
243 } 246 }
244 BrowserThread::PostTask( 247 BrowserThread::PostTask(
245 BrowserThread::UI, FROM_HERE, 248 BrowserThread::UI, FROM_HERE,
246 base::Bind(&AppCacheInternalsUI::OnAppCacheDetailsReady, 249 base::Bind(&AppCacheInternalsUI::OnAppCacheDetailsReady,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 return; 283 return;
281 ResponseEnquiry response_enquiry = response_enquiries_.front(); 284 ResponseEnquiry response_enquiry = response_enquiries_.front();
282 response_enquiries_.pop_front(); 285 response_enquiries_.pop_front();
283 if (response) { 286 if (response) {
284 scoped_refptr<AppCacheResponseInfo> response_info = response; 287 scoped_refptr<AppCacheResponseInfo> response_info = response;
285 const int64_t kLimit = 100 * 1000; 288 const int64_t kLimit = 100 * 1000;
286 int64_t amount_to_read = 289 int64_t amount_to_read =
287 std::min(kLimit, response_info->response_data_size()); 290 std::min(kLimit, response_info->response_data_size());
288 scoped_refptr<net::IOBuffer> response_data(new net::IOBuffer( 291 scoped_refptr<net::IOBuffer> response_data(new net::IOBuffer(
289 base::CheckedNumeric<size_t>(amount_to_read).ValueOrDie())); 292 base::CheckedNumeric<size_t>(amount_to_read).ValueOrDie()));
290 scoped_ptr<AppCacheResponseReader> reader( 293 std::unique_ptr<AppCacheResponseReader> reader(
291 appcache_service_->storage()->CreateResponseReader( 294 appcache_service_->storage()->CreateResponseReader(
292 GURL(response_enquiry.manifest_url), response_enquiry.group_id, 295 GURL(response_enquiry.manifest_url), response_enquiry.group_id,
293 response_enquiry.response_id)); 296 response_enquiry.response_id));
294 297
295 reader->ReadData( 298 reader->ReadData(
296 response_data.get(), amount_to_read, 299 response_data.get(), amount_to_read,
297 base::Bind(&Proxy::OnResponseDataReadComplete, this, response_enquiry, 300 base::Bind(&Proxy::OnResponseDataReadComplete, this, response_enquiry,
298 response_info, base::Passed(&reader), response_data)); 301 response_info, base::Passed(&reader), response_data));
299 } else { 302 } else {
300 OnResponseDataReadComplete(response_enquiry, nullptr, nullptr, nullptr, -1); 303 OnResponseDataReadComplete(response_enquiry, nullptr, nullptr, nullptr, -1);
301 } 304 }
302 } 305 }
303 306
304 void AppCacheInternalsUI::Proxy::OnResponseDataReadComplete( 307 void AppCacheInternalsUI::Proxy::OnResponseDataReadComplete(
305 const ResponseEnquiry& response_enquiry, 308 const ResponseEnquiry& response_enquiry,
306 scoped_refptr<AppCacheResponseInfo> response_info, 309 scoped_refptr<AppCacheResponseInfo> response_info,
307 scoped_ptr<AppCacheResponseReader> reader, 310 std::unique_ptr<AppCacheResponseReader> reader,
308 scoped_refptr<net::IOBuffer> response_data, 311 scoped_refptr<net::IOBuffer> response_data,
309 int net_result_code) { 312 int net_result_code) {
310 if (shutdown_called_) 313 if (shutdown_called_)
311 return; 314 return;
312 if (!response_info || net_result_code < 0) { 315 if (!response_info || net_result_code < 0) {
313 BrowserThread::PostTask( 316 BrowserThread::PostTask(
314 BrowserThread::UI, FROM_HERE, 317 BrowserThread::UI, FROM_HERE,
315 base::Bind(&AppCacheInternalsUI::OnFileDetailsFailed, 318 base::Bind(&AppCacheInternalsUI::OnFileDetailsFailed,
316 appcache_internals_ui_, response_enquiry, net_result_code)); 319 appcache_internals_ui_, response_enquiry, net_result_code));
317 } else { 320 } else {
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 bool deleted) { 433 bool deleted) {
431 web_ui()->CallJavascriptFunction( 434 web_ui()->CallJavascriptFunction(
432 kFunctionOnAppCacheInfoDeleted, 435 kFunctionOnAppCacheInfoDeleted,
433 base::StringValue(partition_path.AsUTF8Unsafe()), 436 base::StringValue(partition_path.AsUTF8Unsafe()),
434 base::StringValue(manifest_url), base::FundamentalValue(deleted)); 437 base::StringValue(manifest_url), base::FundamentalValue(deleted));
435 } 438 }
436 439
437 void AppCacheInternalsUI::OnAppCacheDetailsReady( 440 void AppCacheInternalsUI::OnAppCacheDetailsReady(
438 const base::FilePath& partition_path, 441 const base::FilePath& partition_path,
439 const std::string& manifest_url, 442 const std::string& manifest_url,
440 scoped_ptr<AppCacheResourceInfoVector> resource_info_vector) { 443 std::unique_ptr<AppCacheResourceInfoVector> resource_info_vector) {
441 if (resource_info_vector) { 444 if (resource_info_vector) {
442 web_ui()->CallJavascriptFunction( 445 web_ui()->CallJavascriptFunction(
443 kFunctionOnAppCacheDetailsReady, base::StringValue(manifest_url), 446 kFunctionOnAppCacheDetailsReady, base::StringValue(manifest_url),
444 base::StringValue(partition_path.AsUTF8Unsafe()), 447 base::StringValue(partition_path.AsUTF8Unsafe()),
445 *GetListValueForAppCacheResourceInfoVector(resource_info_vector.get())); 448 *GetListValueForAppCacheResourceInfoVector(resource_info_vector.get()));
446 } else { 449 } else {
447 web_ui()->CallJavascriptFunction( 450 web_ui()->CallJavascriptFunction(
448 kFunctionOnAppCacheDetailsReady, base::StringValue(manifest_url), 451 kFunctionOnAppCacheDetailsReady, base::StringValue(manifest_url),
449 base::StringValue(partition_path.AsUTF8Unsafe())); 452 base::StringValue(partition_path.AsUTF8Unsafe()));
450 } 453 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 const base::FilePath& partition_path) { 504 const base::FilePath& partition_path) {
502 for (const scoped_refptr<Proxy>& proxy : appcache_proxies_) { 505 for (const scoped_refptr<Proxy>& proxy : appcache_proxies_) {
503 if (proxy->partition_path_ == partition_path) 506 if (proxy->partition_path_ == partition_path)
504 return proxy.get(); 507 return proxy.get();
505 } 508 }
506 NOTREACHED(); 509 NOTREACHED();
507 return nullptr; 510 return nullptr;
508 } 511 }
509 512
510 } // namespace content 513 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/appcache/appcache_internals_ui.h ('k') | content/browser/appcache/appcache_quota_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698