Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(190)

Side by Side Diff: content/renderer/service_worker/service_worker_context_client.cc

Issue 2837943006: [WIP] Support PerformanceResourceTiming for Service Worker Navigation Preload (Closed)
Patch Set: clean up Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/renderer/service_worker/service_worker_context_client.h" 5 #include "content/renderer/service_worker/service_worker_context_client.h"
6 6
7 #include <map> 7 #include <map>
8 #include <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 ServiceWorkerContextClient* client = 414 ServiceWorkerContextClient* client =
415 ServiceWorkerContextClient::ThreadSpecificInstance(); 415 ServiceWorkerContextClient::ThreadSpecificInstance();
416 if (!client) 416 if (!client)
417 return; 417 return;
418 response_ = base::MakeUnique<blink::WebURLResponse>(); 418 response_ = base::MakeUnique<blink::WebURLResponse>();
419 WebURLLoaderImpl::PopulateURLResponse(url_, response_head, response_.get(), 419 WebURLLoaderImpl::PopulateURLResponse(url_, response_head, response_.get(),
420 false /* report_security_info */); 420 false /* report_security_info */);
421 client->OnNavigationPreloadResponse(fetch_event_id_, std::move(response_), 421 client->OnNavigationPreloadResponse(fetch_event_id_, std::move(response_),
422 nullptr); 422 nullptr);
423 // This will delete |this|. 423 // This will delete |this|.
424 client->OnNavigationPreloadComplete(fetch_event_id_); 424 client->OnNavigationPreloadComplete(
425 fetch_event_id_, response_head.response_start,
426 response_head.encoded_data_length, 0 /* encoded_body_length */,
427 0 /* decoded_body_length */);
425 } 428 }
426 429
427 void OnDataDownloaded(int64_t data_length, 430 void OnDataDownloaded(int64_t data_length,
428 int64_t encoded_data_length) override { 431 int64_t encoded_data_length) override {
429 NOTREACHED(); 432 NOTREACHED();
430 } 433 }
431 434
432 void OnUploadProgress(int64_t current_position, 435 void OnUploadProgress(int64_t current_position,
433 int64_t total_size, 436 int64_t total_size,
434 OnUploadProgressCallback ack_callback) override { 437 OnUploadProgressCallback ack_callback) override {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 if (!client) 480 if (!client)
478 return; 481 return;
479 if (response_) { 482 if (response_) {
480 // When the response body from the server is empty, OnComplete() is called 483 // When the response body from the server is empty, OnComplete() is called
481 // without OnStartLoadingResponseBody(). 484 // without OnStartLoadingResponseBody().
482 DCHECK(!body_.is_valid()); 485 DCHECK(!body_.is_valid());
483 client->OnNavigationPreloadResponse(fetch_event_id_, std::move(response_), 486 client->OnNavigationPreloadResponse(fetch_event_id_, std::move(response_),
484 nullptr); 487 nullptr);
485 } 488 }
486 // This will delete |this|. 489 // This will delete |this|.
487 client->OnNavigationPreloadComplete(fetch_event_id_); 490 client->OnNavigationPreloadComplete(
491 fetch_event_id_, status.completion_time, status.encoded_data_length,
492 status.encoded_body_length, status.decoded_body_length);
488 } 493 }
489 494
490 private: 495 private:
491 void MaybeReportResponseToClient() { 496 void MaybeReportResponseToClient() {
492 if (!response_ || !body_.is_valid()) 497 if (!response_ || !body_.is_valid())
493 return; 498 return;
494 ServiceWorkerContextClient* client = 499 ServiceWorkerContextClient* client =
495 ServiceWorkerContextClient::ThreadSpecificInstance(); 500 ServiceWorkerContextClient::ThreadSpecificInstance();
496 if (!client) 501 if (!client)
497 return; 502 return;
(...skipping 1131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1629 } 1634 }
1630 1635
1631 void ServiceWorkerContextClient::OnNavigationPreloadError( 1636 void ServiceWorkerContextClient::OnNavigationPreloadError(
1632 int fetch_event_id, 1637 int fetch_event_id,
1633 std::unique_ptr<blink::WebServiceWorkerError> error) { 1638 std::unique_ptr<blink::WebServiceWorkerError> error) {
1634 proxy_->OnNavigationPreloadError(fetch_event_id, std::move(error)); 1639 proxy_->OnNavigationPreloadError(fetch_event_id, std::move(error));
1635 context_->preload_requests.Remove(fetch_event_id); 1640 context_->preload_requests.Remove(fetch_event_id);
1636 } 1641 }
1637 1642
1638 void ServiceWorkerContextClient::OnNavigationPreloadComplete( 1643 void ServiceWorkerContextClient::OnNavigationPreloadComplete(
1639 int fetch_event_id) { 1644 int fetch_event_id,
1645 base::TimeTicks completion_time,
1646 int64_t encoded_data_length,
1647 int64_t encoded_body_length,
1648 int64_t decoded_body_length) {
1649 proxy_->OnNavigationPreloadComplete(
1650 fetch_event_id, (completion_time - base::TimeTicks()).InSecondsF(),
1651 encoded_data_length, encoded_body_length, decoded_body_length);
1640 context_->preload_requests.Remove(fetch_event_id); 1652 context_->preload_requests.Remove(fetch_event_id);
1641 } 1653 }
1642 1654
1643 base::WeakPtr<ServiceWorkerContextClient> 1655 base::WeakPtr<ServiceWorkerContextClient>
1644 ServiceWorkerContextClient::GetWeakPtr() { 1656 ServiceWorkerContextClient::GetWeakPtr() {
1645 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); 1657 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread());
1646 DCHECK(context_); 1658 DCHECK(context_);
1647 return context_->weak_factory.GetWeakPtr(); 1659 return context_->weak_factory.GetWeakPtr();
1648 } 1660 }
1649 1661
1650 } // namespace content 1662 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698