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