| 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> | 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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 response_enquiries_.push_back(response_enquiry); | 263 response_enquiries_.push_back(response_enquiry); |
| 264 HandleFileDetailsRequest(); | 264 HandleFileDetailsRequest(); |
| 265 } | 265 } |
| 266 | 266 |
| 267 void AppCacheInternalsUI::Proxy::HandleFileDetailsRequest() { | 267 void AppCacheInternalsUI::Proxy::HandleFileDetailsRequest() { |
| 268 if (preparing_response_ || !response_enquiries_.size() || !appcache_service_) | 268 if (preparing_response_ || !response_enquiries_.size() || !appcache_service_) |
| 269 return; | 269 return; |
| 270 preparing_response_ = true; | 270 preparing_response_ = true; |
| 271 appcache_service_->storage()->LoadResponseInfo( | 271 appcache_service_->storage()->LoadResponseInfo( |
| 272 GURL(response_enquiries_.front().manifest_url), | 272 GURL(response_enquiries_.front().manifest_url), |
| 273 response_enquiries_.front().group_id, | |
| 274 response_enquiries_.front().response_id, this); | 273 response_enquiries_.front().response_id, this); |
| 275 } | 274 } |
| 276 | 275 |
| 277 void AppCacheInternalsUI::Proxy::OnResponseInfoLoaded( | 276 void AppCacheInternalsUI::Proxy::OnResponseInfoLoaded( |
| 278 AppCacheResponseInfo* response, | 277 AppCacheResponseInfo* response, |
| 279 int64_t response_id) { | 278 int64_t response_id) { |
| 280 if (shutdown_called_) | 279 if (shutdown_called_) |
| 281 return; | 280 return; |
| 282 if (!appcache_service_) | 281 if (!appcache_service_) |
| 283 return; | 282 return; |
| 284 ResponseEnquiry response_enquiry = response_enquiries_.front(); | 283 ResponseEnquiry response_enquiry = response_enquiries_.front(); |
| 285 response_enquiries_.pop_front(); | 284 response_enquiries_.pop_front(); |
| 286 if (response) { | 285 if (response) { |
| 287 scoped_refptr<AppCacheResponseInfo> response_info = response; | 286 scoped_refptr<AppCacheResponseInfo> response_info = response; |
| 288 const int64_t kLimit = 100 * 1000; | 287 const int64_t kLimit = 100 * 1000; |
| 289 int64_t amount_to_read = | 288 int64_t amount_to_read = |
| 290 std::min(kLimit, response_info->response_data_size()); | 289 std::min(kLimit, response_info->response_data_size()); |
| 291 scoped_refptr<net::IOBuffer> response_data(new net::IOBuffer( | 290 scoped_refptr<net::IOBuffer> response_data(new net::IOBuffer( |
| 292 base::CheckedNumeric<size_t>(amount_to_read).ValueOrDie())); | 291 base::CheckedNumeric<size_t>(amount_to_read).ValueOrDie())); |
| 293 std::unique_ptr<AppCacheResponseReader> reader( | 292 std::unique_ptr<AppCacheResponseReader> reader( |
| 294 appcache_service_->storage()->CreateResponseReader( | 293 appcache_service_->storage()->CreateResponseReader( |
| 295 GURL(response_enquiry.manifest_url), response_enquiry.group_id, | 294 GURL(response_enquiry.manifest_url), response_enquiry.response_id)); |
| 296 response_enquiry.response_id)); | |
| 297 | 295 |
| 298 reader->ReadData( | 296 reader->ReadData( |
| 299 response_data.get(), amount_to_read, | 297 response_data.get(), amount_to_read, |
| 300 base::Bind(&Proxy::OnResponseDataReadComplete, this, response_enquiry, | 298 base::Bind(&Proxy::OnResponseDataReadComplete, this, response_enquiry, |
| 301 response_info, base::Passed(&reader), response_data)); | 299 response_info, base::Passed(&reader), response_data)); |
| 302 } else { | 300 } else { |
| 303 OnResponseDataReadComplete(response_enquiry, nullptr, nullptr, nullptr, -1); | 301 OnResponseDataReadComplete(response_enquiry, nullptr, nullptr, nullptr, -1); |
| 304 } | 302 } |
| 305 } | 303 } |
| 306 | 304 |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 const base::FilePath& partition_path) { | 502 const base::FilePath& partition_path) { |
| 505 for (const scoped_refptr<Proxy>& proxy : appcache_proxies_) { | 503 for (const scoped_refptr<Proxy>& proxy : appcache_proxies_) { |
| 506 if (proxy->partition_path_ == partition_path) | 504 if (proxy->partition_path_ == partition_path) |
| 507 return proxy.get(); | 505 return proxy.get(); |
| 508 } | 506 } |
| 509 NOTREACHED(); | 507 NOTREACHED(); |
| 510 return nullptr; | 508 return nullptr; |
| 511 } | 509 } |
| 512 | 510 |
| 513 } // namespace content | 511 } // namespace content |
| OLD | NEW |