| 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/profiler/scoped_tracker.h" |
| 17 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
| 18 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
| 19 #include "base/strings/stringprintf.h" | 19 #include "base/strings/stringprintf.h" |
| 20 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
| 21 #include "content/browser/appcache/appcache.h" | 21 #include "content/browser/appcache/appcache.h" |
| 22 #include "content/browser/appcache/appcache_group.h" | 22 #include "content/browser/appcache/appcache_group.h" |
| 23 #include "content/browser/appcache/appcache_policy.h" | 23 #include "content/browser/appcache/appcache_policy.h" |
| 24 #include "content/browser/appcache/appcache_response.h" | 24 #include "content/browser/appcache/appcache_response.h" |
| 25 #include "content/browser/appcache/appcache_service_impl.h" | 25 #include "content/browser/appcache/appcache_service_impl.h" |
| 26 #include "content/browser/appcache/appcache_storage.h" | 26 #include "content/browser/appcache/appcache_storage.h" |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 info_collection_.get(), | 351 info_collection_.get(), |
| 352 base::Bind(&MainPageJob::OnGotInfoComplete, | 352 base::Bind(&MainPageJob::OnGotInfoComplete, |
| 353 weak_factory_.GetWeakPtr())); | 353 weak_factory_.GetWeakPtr())); |
| 354 } | 354 } |
| 355 | 355 |
| 356 // Produces a page containing the listing | 356 // Produces a page containing the listing |
| 357 int GetData(std::string* mime_type, | 357 int GetData(std::string* mime_type, |
| 358 std::string* charset, | 358 std::string* charset, |
| 359 std::string* out, | 359 std::string* out, |
| 360 const net::CompletionCallback& callback) const override { | 360 const net::CompletionCallback& callback) const override { |
| 361 // TODO(vadimt): Remove ScopedProfile below once crbug.com/422489 is fixed. | 361 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422489 is fixed. |
| 362 tracked_objects::ScopedProfile tracking_profile( | 362 tracked_objects::ScopedTracker tracking_profile( |
| 363 FROM_HERE_WITH_EXPLICIT_FUNCTION("422489 MainPageJob::GetData")); | 363 FROM_HERE_WITH_EXPLICIT_FUNCTION("422489 MainPageJob::GetData")); |
| 364 | 364 |
| 365 mime_type->assign("text/html"); | 365 mime_type->assign("text/html"); |
| 366 charset->assign("UTF-8"); | 366 charset->assign("UTF-8"); |
| 367 | 367 |
| 368 out->clear(); | 368 out->clear(); |
| 369 EmitPageStart(out); | 369 EmitPageStart(out); |
| 370 if (!info_collection_.get()) { | 370 if (!info_collection_.get()) { |
| 371 out->append(kErrorMessage); | 371 out->append(kErrorMessage); |
| 372 } else if (info_collection_->infos_by_origin.empty()) { | 372 } else if (info_collection_->infos_by_origin.empty()) { |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 void Start() override { | 476 void Start() override { |
| 477 DCHECK(request_); | 477 DCHECK(request_); |
| 478 appcache_storage_->LoadOrCreateGroup(manifest_url_, this); | 478 appcache_storage_->LoadOrCreateGroup(manifest_url_, this); |
| 479 } | 479 } |
| 480 | 480 |
| 481 // Produces a page containing the entries listing. | 481 // Produces a page containing the entries listing. |
| 482 int GetData(std::string* mime_type, | 482 int GetData(std::string* mime_type, |
| 483 std::string* charset, | 483 std::string* charset, |
| 484 std::string* out, | 484 std::string* out, |
| 485 const net::CompletionCallback& callback) const override { | 485 const net::CompletionCallback& callback) const override { |
| 486 // TODO(vadimt): Remove ScopedProfile below once crbug.com/422489 is fixed. | 486 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422489 is fixed. |
| 487 tracked_objects::ScopedProfile tracking_profile( | 487 tracked_objects::ScopedTracker tracking_profile( |
| 488 FROM_HERE_WITH_EXPLICIT_FUNCTION("422489 ViewAppCacheJob::GetData")); | 488 FROM_HERE_WITH_EXPLICIT_FUNCTION("422489 ViewAppCacheJob::GetData")); |
| 489 | 489 |
| 490 mime_type->assign("text/html"); | 490 mime_type->assign("text/html"); |
| 491 charset->assign("UTF-8"); | 491 charset->assign("UTF-8"); |
| 492 out->clear(); | 492 out->clear(); |
| 493 EmitPageStart(out); | 493 EmitPageStart(out); |
| 494 if (appcache_info_.manifest_url.is_empty()) { | 494 if (appcache_info_.manifest_url.is_empty()) { |
| 495 out->append(kManifestNotFoundMessage); | 495 out->append(kManifestNotFoundMessage); |
| 496 } else { | 496 } else { |
| 497 GURL base_url = ClearQuery(request_->url()); | 497 GURL base_url = ClearQuery(request_->url()); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 DCHECK(request_); | 555 DCHECK(request_); |
| 556 appcache_storage_->LoadResponseInfo( | 556 appcache_storage_->LoadResponseInfo( |
| 557 manifest_url_, group_id_, response_id_, this); | 557 manifest_url_, group_id_, response_id_, this); |
| 558 } | 558 } |
| 559 | 559 |
| 560 // Produces a page containing the response headers and data. | 560 // Produces a page containing the response headers and data. |
| 561 int GetData(std::string* mime_type, | 561 int GetData(std::string* mime_type, |
| 562 std::string* charset, | 562 std::string* charset, |
| 563 std::string* out, | 563 std::string* out, |
| 564 const net::CompletionCallback& callback) const override { | 564 const net::CompletionCallback& callback) const override { |
| 565 // TODO(vadimt): Remove ScopedProfile below once crbug.com/422489 is fixed. | 565 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422489 is fixed. |
| 566 tracked_objects::ScopedProfile tracking_profile( | 566 tracked_objects::ScopedTracker tracking_profile( |
| 567 FROM_HERE_WITH_EXPLICIT_FUNCTION("422489 ViewEntryJob::GetData")); | 567 FROM_HERE_WITH_EXPLICIT_FUNCTION("422489 ViewEntryJob::GetData")); |
| 568 | 568 |
| 569 mime_type->assign("text/html"); | 569 mime_type->assign("text/html"); |
| 570 charset->assign("UTF-8"); | 570 charset->assign("UTF-8"); |
| 571 out->clear(); | 571 out->clear(); |
| 572 EmitPageStart(out); | 572 EmitPageStart(out); |
| 573 EmitAnchor(entry_url_.spec(), entry_url_.spec(), out); | 573 EmitAnchor(entry_url_.spec(), entry_url_.spec(), out); |
| 574 out->append("<br/>\n"); | 574 out->append("<br/>\n"); |
| 575 if (response_info_.get()) { | 575 if (response_info_.get()) { |
| 576 if (response_info_->http_response_info()) | 576 if (response_info_->http_response_info()) |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 return new ViewEntryJob(request, network_delegate, service, | 667 return new ViewEntryJob(request, network_delegate, service, |
| 668 DecodeBase64URL(tokens[0]), // manifest url | 668 DecodeBase64URL(tokens[0]), // manifest url |
| 669 DecodeBase64URL(tokens[1]), // entry url | 669 DecodeBase64URL(tokens[1]), // entry url |
| 670 response_id, group_id); | 670 response_id, group_id); |
| 671 } | 671 } |
| 672 | 672 |
| 673 return new RedirectToMainPageJob(request, network_delegate, service); | 673 return new RedirectToMainPageJob(request, network_delegate, service); |
| 674 } | 674 } |
| 675 | 675 |
| 676 } // namespace content | 676 } // namespace content |
| OLD | NEW |