OLD | NEW |
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> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/logging.h" | 10 #include "base/logging.h" |
9 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/string_piece.h" | 12 #include "base/strings/string_piece.h" |
11 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
12 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
13 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
14 #include "base/threading/platform_thread.h" | 16 #include "base/threading/platform_thread.h" |
15 #include "base/values.h" | 17 #include "base/values.h" |
16 #include "content/browser/appcache/appcache.h" | 18 #include "content/browser/appcache/appcache.h" |
(...skipping 18 matching lines...) Expand all Loading... |
35 const char kRequestGetFileDetails[] = "getFileDetails"; | 37 const char kRequestGetFileDetails[] = "getFileDetails"; |
36 | 38 |
37 const char kFunctionOnAllAppCacheInfoReady[] = | 39 const char kFunctionOnAllAppCacheInfoReady[] = |
38 "appcache.onAllAppCacheInfoReady"; | 40 "appcache.onAllAppCacheInfoReady"; |
39 const char kFunctionOnAppCacheInfoDeleted[] = "appcache.onAppCacheInfoDeleted"; | 41 const char kFunctionOnAppCacheInfoDeleted[] = "appcache.onAppCacheInfoDeleted"; |
40 const char kFunctionOnAppCacheDetailsReady[] = | 42 const char kFunctionOnAppCacheDetailsReady[] = |
41 "appcache.onAppCacheDetailsReady"; | 43 "appcache.onAppCacheDetailsReady"; |
42 const char kFunctionOnFileDetailsReady[] = "appcache.onFileDetailsReady"; | 44 const char kFunctionOnFileDetailsReady[] = "appcache.onFileDetailsReady"; |
43 const char kFunctionOnFileDetailsFailed[] = "appcache.onFileDetailsFailed"; | 45 const char kFunctionOnFileDetailsFailed[] = "appcache.onFileDetailsFailed"; |
44 | 46 |
45 int64 ToInt64(const std::string& str) { | 47 int64_t ToInt64(const std::string& str) { |
46 int64 i = 0; | 48 int64_t i = 0; |
47 base::StringToInt64(str.c_str(), &i); | 49 base::StringToInt64(str.c_str(), &i); |
48 return i; | 50 return i; |
49 } | 51 } |
50 | 52 |
51 bool SortByResourceUrl(const AppCacheResourceInfo& lhs, | 53 bool SortByResourceUrl(const AppCacheResourceInfo& lhs, |
52 const AppCacheResourceInfo& rhs) { | 54 const AppCacheResourceInfo& rhs) { |
53 return lhs.url.spec() < rhs.url.spec(); | 55 return lhs.url.spec() < rhs.url.spec(); |
54 } | 56 } |
55 | 57 |
56 scoped_ptr<base::DictionaryValue> GetDictionaryValueForResponseEnquiry( | 58 scoped_ptr<base::DictionaryValue> GetDictionaryValueForResponseEnquiry( |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 return; | 266 return; |
265 preparing_response_ = true; | 267 preparing_response_ = true; |
266 appcache_service_->storage()->LoadResponseInfo( | 268 appcache_service_->storage()->LoadResponseInfo( |
267 GURL(response_enquiries_.front().manifest_url), | 269 GURL(response_enquiries_.front().manifest_url), |
268 response_enquiries_.front().group_id, | 270 response_enquiries_.front().group_id, |
269 response_enquiries_.front().response_id, this); | 271 response_enquiries_.front().response_id, this); |
270 } | 272 } |
271 | 273 |
272 void AppCacheInternalsUI::Proxy::OnResponseInfoLoaded( | 274 void AppCacheInternalsUI::Proxy::OnResponseInfoLoaded( |
273 AppCacheResponseInfo* response, | 275 AppCacheResponseInfo* response, |
274 int64 response_id) { | 276 int64_t response_id) { |
275 if (shutdown_called_) | 277 if (shutdown_called_) |
276 return; | 278 return; |
277 if (!appcache_service_) | 279 if (!appcache_service_) |
278 return; | 280 return; |
279 ResponseEnquiry response_enquiry = response_enquiries_.front(); | 281 ResponseEnquiry response_enquiry = response_enquiries_.front(); |
280 response_enquiries_.pop_front(); | 282 response_enquiries_.pop_front(); |
281 if (response) { | 283 if (response) { |
282 scoped_refptr<AppCacheResponseInfo> response_info = response; | 284 scoped_refptr<AppCacheResponseInfo> response_info = response; |
283 const int64 kLimit = 100 * 1000; | 285 const int64_t kLimit = 100 * 1000; |
284 int64 amount_to_read = | 286 int64_t amount_to_read = |
285 std::min(kLimit, response_info->response_data_size()); | 287 std::min(kLimit, response_info->response_data_size()); |
286 scoped_refptr<net::IOBuffer> response_data(new net::IOBuffer( | 288 scoped_refptr<net::IOBuffer> response_data(new net::IOBuffer( |
287 base::CheckedNumeric<size_t>(amount_to_read).ValueOrDie())); | 289 base::CheckedNumeric<size_t>(amount_to_read).ValueOrDie())); |
288 scoped_ptr<AppCacheResponseReader> reader( | 290 scoped_ptr<AppCacheResponseReader> reader( |
289 appcache_service_->storage()->CreateResponseReader( | 291 appcache_service_->storage()->CreateResponseReader( |
290 GURL(response_enquiry.manifest_url), response_enquiry.group_id, | 292 GURL(response_enquiry.manifest_url), response_enquiry.group_id, |
291 response_enquiry.response_id)); | 293 response_enquiry.response_id)); |
292 | 294 |
293 reader->ReadData( | 295 reader->ReadData( |
294 response_data.get(), amount_to_read, | 296 response_data.get(), amount_to_read, |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 const base::FilePath& partition_path) { | 501 const base::FilePath& partition_path) { |
500 for (const scoped_refptr<Proxy>& proxy : appcache_proxies_) { | 502 for (const scoped_refptr<Proxy>& proxy : appcache_proxies_) { |
501 if (proxy->partition_path_ == partition_path) | 503 if (proxy->partition_path_ == partition_path) |
502 return proxy.get(); | 504 return proxy.get(); |
503 } | 505 } |
504 NOTREACHED(); | 506 NOTREACHED(); |
505 return nullptr; | 507 return nullptr; |
506 } | 508 } |
507 | 509 |
508 } // namespace content | 510 } // namespace content |
OLD | NEW |