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

Side by Side Diff: content/browser/service_worker/service_worker_write_to_cache_job.cc

Issue 1283273002: Service Worker: Change last update check location and HTTP cache bypass rule (2/2) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add comments. Created 5 years, 3 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 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/service_worker/service_worker_write_to_cache_job.h" 5 #include "content/browser/service_worker/service_worker_write_to_cache_job.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/trace_event/trace_event.h" 10 #include "base/trace_event/trace_event.h"
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 bool* defer) { 616 bool* defer) {
617 DCHECK_EQ(net_request_, request); 617 DCHECK_EQ(net_request_, request);
618 TRACE_EVENT0("ServiceWorker", 618 TRACE_EVENT0("ServiceWorker",
619 "ServiceWorkerWriteToCacheJob::OnBeforeNetworkStart"); 619 "ServiceWorkerWriteToCacheJob::OnBeforeNetworkStart");
620 NotifyBeforeNetworkStart(defer); 620 NotifyBeforeNetworkStart(defer);
621 } 621 }
622 622
623 void ServiceWorkerWriteToCacheJob::OnResponseStarted( 623 void ServiceWorkerWriteToCacheJob::OnResponseStarted(
624 net::URLRequest* request) { 624 net::URLRequest* request) {
625 DCHECK_EQ(net_request_, request); 625 DCHECK_EQ(net_request_, request);
626 if (!context_) {
627 AsyncNotifyDoneHelper(
628 net::URLRequestStatus(net::URLRequestStatus::FAILED, net::ERR_FAILED),
629 kFetchScriptError);
630 return;
631 }
632
626 if (!request->status().is_success()) { 633 if (!request->status().is_success()) {
627 AsyncNotifyDoneHelper(request->status(), kFetchScriptError); 634 AsyncNotifyDoneHelper(request->status(), kFetchScriptError);
628 return; 635 return;
629 } 636 }
630 if (request->GetResponseCode() / 100 != 2) { 637 if (request->GetResponseCode() / 100 != 2) {
631 std::string error_message = 638 std::string error_message =
632 base::StringPrintf(kBadHTTPResponseError, request->GetResponseCode()); 639 base::StringPrintf(kBadHTTPResponseError, request->GetResponseCode());
633 AsyncNotifyDoneHelper(net::URLRequestStatus(net::URLRequestStatus::FAILED, 640 AsyncNotifyDoneHelper(net::URLRequestStatus(net::URLRequestStatus::FAILED,
634 net::ERR_INVALID_RESPONSE), 641 net::ERR_INVALID_RESPONSE),
635 error_message); 642 error_message);
636 // TODO(michaeln): Instead of error'ing immediately, send the net 643 // TODO(michaeln): Instead of error'ing immediately, send the net
637 // response to our consumer, just don't cache it? 644 // response to our consumer, just don't cache it?
638 return; 645 return;
639 } 646 }
647
648 // Update |last_update_check| only when the request bypassed the browser
649 // cache.
650 if (request->response_info().network_accessed) {
michaeln 2015/09/11 18:59:26 I'm not sure this matters, but... I don't think n
jungkees 2015/09/22 01:23:40 Sorry for getting back late. You are right. What
651 ServiceWorkerRegistration* registration =
652 context_->GetLiveRegistration(version_->registration_id());
653 DCHECK(registration); // We're registering or updating so must be there.
654
655 registration->set_last_update_check(base::Time::Now());
michaeln 2015/09/10 20:26:45 I think this logic that applies to the register/up
jungkees 2015/09/11 04:28:14 I see. The reason I put this code here is to updat
656 context_->storage()->UpdateLastUpdateCheckTime(registration);
michaeln 2015/09/10 20:26:45 I'm not sure i understand this change? 1) The wri
jungkees 2015/09/11 04:28:14 This is expected behavior as per the current spec
michaeln 2015/09/11 18:59:26 Seems odd to update the time even if the job is ab
jungkees 2015/09/22 01:23:40 Indeed.
657 }
658
640 // OnSSLCertificateError is not called when the HTTPS connection is reused. 659 // OnSSLCertificateError is not called when the HTTPS connection is reused.
641 // So we check cert_status here. 660 // So we check cert_status here.
642 if (net::IsCertStatusError(request->ssl_info().cert_status)) { 661 if (net::IsCertStatusError(request->ssl_info().cert_status)) {
643 const net::HttpNetworkSession::Params* session_params = 662 const net::HttpNetworkSession::Params* session_params =
644 request->context()->GetNetworkSessionParams(); 663 request->context()->GetNetworkSessionParams();
645 if (!session_params || !session_params->ignore_certificate_errors) { 664 if (!session_params || !session_params->ignore_certificate_errors) {
646 AsyncNotifyDoneHelper(net::URLRequestStatus(net::URLRequestStatus::FAILED, 665 AsyncNotifyDoneHelper(net::URLRequestStatus(net::URLRequestStatus::FAILED,
647 net::ERR_INSECURE_RESPONSE), 666 net::ERR_INSECURE_RESPONSE),
648 kSSLError); 667 kSSLError);
649 return; 668 return;
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 DCHECK(!did_notify_finished_); 835 DCHECK(!did_notify_finished_);
817 int size = -1; 836 int size = -1;
818 if (status.is_success()) 837 if (status.is_success())
819 size = writer_ ? writer_->amount_written() : 0; 838 size = writer_ ? writer_->amount_written() : 0;
820 version_->script_cache_map()->NotifyFinishedCaching(url_, size, status, 839 version_->script_cache_map()->NotifyFinishedCaching(url_, size, status,
821 status_message); 840 status_message);
822 did_notify_finished_ = true; 841 did_notify_finished_ = true;
823 } 842 }
824 843
825 } // namespace content 844 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698