| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/view_appcache_internals_job.h" | 5 #include "content/browser/appcache/view_appcache_internals_job.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/base64.h" | 10 #include "base/base64.h" |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/format_macros.h" | 12 #include "base/format_macros.h" |
| 13 #include "base/i18n/time_formatting.h" | 13 #include "base/i18n/time_formatting.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "base/profiler/scoped_profile.h" |
| 16 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
| 17 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
| 18 #include "base/strings/stringprintf.h" | 19 #include "base/strings/stringprintf.h" |
| 19 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
| 20 #include "content/browser/appcache/appcache.h" | 21 #include "content/browser/appcache/appcache.h" |
| 21 #include "content/browser/appcache/appcache_group.h" | 22 #include "content/browser/appcache/appcache_group.h" |
| 22 #include "content/browser/appcache/appcache_policy.h" | 23 #include "content/browser/appcache/appcache_policy.h" |
| 23 #include "content/browser/appcache/appcache_response.h" | 24 #include "content/browser/appcache/appcache_response.h" |
| 24 #include "content/browser/appcache/appcache_service_impl.h" | 25 #include "content/browser/appcache/appcache_service_impl.h" |
| 25 #include "content/browser/appcache/appcache_storage.h" | 26 #include "content/browser/appcache/appcache_storage.h" |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 info_collection_.get(), | 353 info_collection_.get(), |
| 353 base::Bind(&MainPageJob::OnGotInfoComplete, | 354 base::Bind(&MainPageJob::OnGotInfoComplete, |
| 354 weak_factory_.GetWeakPtr())); | 355 weak_factory_.GetWeakPtr())); |
| 355 } | 356 } |
| 356 | 357 |
| 357 // Produces a page containing the listing | 358 // Produces a page containing the listing |
| 358 virtual int GetData(std::string* mime_type, | 359 virtual int GetData(std::string* mime_type, |
| 359 std::string* charset, | 360 std::string* charset, |
| 360 std::string* out, | 361 std::string* out, |
| 361 const net::CompletionCallback& callback) const override { | 362 const net::CompletionCallback& callback) const override { |
| 363 // TODO(vadimt): Remove ScopedProfile below once crbug.com/422489 is fixed. |
| 364 tracked_objects::ScopedProfile tracking_profile( |
| 365 FROM_HERE_WITH_EXPLICIT_FUNCTION("422489 MainPageJob::GetData")); |
| 366 |
| 362 mime_type->assign("text/html"); | 367 mime_type->assign("text/html"); |
| 363 charset->assign("UTF-8"); | 368 charset->assign("UTF-8"); |
| 364 | 369 |
| 365 out->clear(); | 370 out->clear(); |
| 366 EmitPageStart(out); | 371 EmitPageStart(out); |
| 367 if (!info_collection_.get()) { | 372 if (!info_collection_.get()) { |
| 368 out->append(kErrorMessage); | 373 out->append(kErrorMessage); |
| 369 } else if (info_collection_->infos_by_origin.empty()) { | 374 } else if (info_collection_->infos_by_origin.empty()) { |
| 370 out->append(kEmptyAppCachesMessage); | 375 out->append(kEmptyAppCachesMessage); |
| 371 } else { | 376 } else { |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 virtual void Start() override { | 479 virtual void Start() override { |
| 475 DCHECK(request_); | 480 DCHECK(request_); |
| 476 appcache_storage_->LoadOrCreateGroup(manifest_url_, this); | 481 appcache_storage_->LoadOrCreateGroup(manifest_url_, this); |
| 477 } | 482 } |
| 478 | 483 |
| 479 // Produces a page containing the entries listing. | 484 // Produces a page containing the entries listing. |
| 480 virtual int GetData(std::string* mime_type, | 485 virtual int GetData(std::string* mime_type, |
| 481 std::string* charset, | 486 std::string* charset, |
| 482 std::string* out, | 487 std::string* out, |
| 483 const net::CompletionCallback& callback) const override { | 488 const net::CompletionCallback& callback) const override { |
| 489 // TODO(vadimt): Remove ScopedProfile below once crbug.com/422489 is fixed. |
| 490 tracked_objects::ScopedProfile tracking_profile( |
| 491 FROM_HERE_WITH_EXPLICIT_FUNCTION("422489 ViewAppCacheJob::GetData")); |
| 492 |
| 484 mime_type->assign("text/html"); | 493 mime_type->assign("text/html"); |
| 485 charset->assign("UTF-8"); | 494 charset->assign("UTF-8"); |
| 486 out->clear(); | 495 out->clear(); |
| 487 EmitPageStart(out); | 496 EmitPageStart(out); |
| 488 if (appcache_info_.manifest_url.is_empty()) { | 497 if (appcache_info_.manifest_url.is_empty()) { |
| 489 out->append(kManifestNotFoundMessage); | 498 out->append(kManifestNotFoundMessage); |
| 490 } else { | 499 } else { |
| 491 GURL base_url = ClearQuery(request_->url()); | 500 GURL base_url = ClearQuery(request_->url()); |
| 492 EmitAppCacheInfo(base_url, appcache_service_, &appcache_info_, out); | 501 EmitAppCacheInfo(base_url, appcache_service_, &appcache_info_, out); |
| 493 EmitAppCacheResourceInfoVector(base_url, | 502 EmitAppCacheResourceInfoVector(base_url, |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 DCHECK(request_); | 559 DCHECK(request_); |
| 551 appcache_storage_->LoadResponseInfo( | 560 appcache_storage_->LoadResponseInfo( |
| 552 manifest_url_, group_id_, response_id_, this); | 561 manifest_url_, group_id_, response_id_, this); |
| 553 } | 562 } |
| 554 | 563 |
| 555 // Produces a page containing the response headers and data. | 564 // Produces a page containing the response headers and data. |
| 556 virtual int GetData(std::string* mime_type, | 565 virtual int GetData(std::string* mime_type, |
| 557 std::string* charset, | 566 std::string* charset, |
| 558 std::string* out, | 567 std::string* out, |
| 559 const net::CompletionCallback& callback) const override { | 568 const net::CompletionCallback& callback) const override { |
| 569 // TODO(vadimt): Remove ScopedProfile below once crbug.com/422489 is fixed. |
| 570 tracked_objects::ScopedProfile tracking_profile( |
| 571 FROM_HERE_WITH_EXPLICIT_FUNCTION("422489 ViewEntryJob::GetData")); |
| 572 |
| 560 mime_type->assign("text/html"); | 573 mime_type->assign("text/html"); |
| 561 charset->assign("UTF-8"); | 574 charset->assign("UTF-8"); |
| 562 out->clear(); | 575 out->clear(); |
| 563 EmitPageStart(out); | 576 EmitPageStart(out); |
| 564 EmitAnchor(entry_url_.spec(), entry_url_.spec(), out); | 577 EmitAnchor(entry_url_.spec(), entry_url_.spec(), out); |
| 565 out->append("<br/>\n"); | 578 out->append("<br/>\n"); |
| 566 if (response_info_.get()) { | 579 if (response_info_.get()) { |
| 567 if (response_info_->http_response_info()) | 580 if (response_info_->http_response_info()) |
| 568 EmitResponseHeaders(response_info_->http_response_info()->headers.get(), | 581 EmitResponseHeaders(response_info_->http_response_info()->headers.get(), |
| 569 out); | 582 out); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 return new ViewEntryJob(request, network_delegate, service, | 673 return new ViewEntryJob(request, network_delegate, service, |
| 661 DecodeBase64URL(tokens[0]), // manifest url | 674 DecodeBase64URL(tokens[0]), // manifest url |
| 662 DecodeBase64URL(tokens[1]), // entry url | 675 DecodeBase64URL(tokens[1]), // entry url |
| 663 response_id, group_id); | 676 response_id, group_id); |
| 664 } | 677 } |
| 665 | 678 |
| 666 return new RedirectToMainPageJob(request, network_delegate, service); | 679 return new RedirectToMainPageJob(request, network_delegate, service); |
| 667 } | 680 } |
| 668 | 681 |
| 669 } // namespace content | 682 } // namespace content |
| OLD | NEW |