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

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

Issue 2376403004: Store Origin-Trial tokens to ServiceWorkerDataBase (Closed)
Patch Set: incorporated chasej's comment Created 4 years, 2 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_version.h" 5 #include "content/browser/service_worker/service_worker_version.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <limits> 9 #include <limits>
10 #include <map> 10 #include <map>
(...skipping 16 matching lines...) Expand all
27 #include "content/browser/message_port_message_filter.h" 27 #include "content/browser/message_port_message_filter.h"
28 #include "content/browser/message_port_service.h" 28 #include "content/browser/message_port_service.h"
29 #include "content/browser/service_worker/embedded_worker_instance.h" 29 #include "content/browser/service_worker/embedded_worker_instance.h"
30 #include "content/browser/service_worker/embedded_worker_registry.h" 30 #include "content/browser/service_worker/embedded_worker_registry.h"
31 #include "content/browser/service_worker/embedded_worker_status.h" 31 #include "content/browser/service_worker/embedded_worker_status.h"
32 #include "content/browser/service_worker/service_worker_client_utils.h" 32 #include "content/browser/service_worker/service_worker_client_utils.h"
33 #include "content/browser/service_worker/service_worker_context_core.h" 33 #include "content/browser/service_worker/service_worker_context_core.h"
34 #include "content/browser/service_worker/service_worker_context_wrapper.h" 34 #include "content/browser/service_worker/service_worker_context_wrapper.h"
35 #include "content/browser/service_worker/service_worker_metrics.h" 35 #include "content/browser/service_worker/service_worker_metrics.h"
36 #include "content/browser/service_worker/service_worker_registration.h" 36 #include "content/browser/service_worker/service_worker_registration.h"
37 #include "content/common/origin_trials/trial_token_validator.h"
37 #include "content/common/service_worker/embedded_worker_messages.h" 38 #include "content/common/service_worker/embedded_worker_messages.h"
38 #include "content/common/service_worker/embedded_worker_start_params.h" 39 #include "content/common/service_worker/embedded_worker_start_params.h"
39 #include "content/common/service_worker/service_worker_messages.h" 40 #include "content/common/service_worker/service_worker_messages.h"
40 #include "content/common/service_worker/service_worker_type_converters.h" 41 #include "content/common/service_worker/service_worker_type_converters.h"
41 #include "content/common/service_worker/service_worker_utils.h" 42 #include "content/common/service_worker/service_worker_utils.h"
42 #include "content/public/browser/browser_thread.h" 43 #include "content/public/browser/browser_thread.h"
43 #include "content/public/browser/content_browser_client.h" 44 #include "content/public/browser/content_browser_client.h"
44 #include "content/public/browser/render_process_host.h" 45 #include "content/public/browser/render_process_host.h"
45 #include "content/public/common/content_client.h" 46 #include "content/public/common/content_client.h"
46 #include "content/public/common/content_switches.h" 47 #include "content/public/common/content_switches.h"
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 else 694 else
694 embedded_worker_->Stop(); 695 embedded_worker_->Stop();
695 } 696 }
696 if (!context_) 697 if (!context_)
697 return; 698 return;
698 std::vector<ServiceWorkerDatabase::ResourceRecord> resources; 699 std::vector<ServiceWorkerDatabase::ResourceRecord> resources;
699 script_cache_map_.GetResources(&resources); 700 script_cache_map_.GetResources(&resources);
700 context_->storage()->PurgeResources(resources); 701 context_->storage()->PurgeResources(resources);
701 } 702 }
702 703
704 void ServiceWorkerVersion::SetValidOriginTrialTokens(
705 const TrialTokenValidator::FeatureToTokensMap& tokens) {
706 origin_trial_tokens_ =
707 TrialTokenValidator::GetValidTokens(url::Origin(scope()), tokens);
708 }
709
703 void ServiceWorkerVersion::SetDevToolsAttached(bool attached) { 710 void ServiceWorkerVersion::SetDevToolsAttached(bool attached) {
704 embedded_worker()->set_devtools_attached(attached); 711 embedded_worker()->set_devtools_attached(attached);
705 if (stop_when_devtools_detached_ && !attached) { 712 if (stop_when_devtools_detached_ && !attached) {
706 DCHECK_EQ(REDUNDANT, status()); 713 DCHECK_EQ(REDUNDANT, status());
707 if (running_status() == EmbeddedWorkerStatus::STARTING || 714 if (running_status() == EmbeddedWorkerStatus::STARTING ||
708 running_status() == EmbeddedWorkerStatus::RUNNING) { 715 running_status() == EmbeddedWorkerStatus::RUNNING) {
709 embedded_worker_->Stop(); 716 embedded_worker_->Stop();
710 } 717 }
711 return; 718 return;
712 } 719 }
(...skipping 21 matching lines...) Expand all
734 741
735 // Reactivate request timeouts, setting them all to the same expiration time. 742 // Reactivate request timeouts, setting them all to the same expiration time.
736 SetAllRequestExpirations( 743 SetAllRequestExpirations(
737 base::TimeTicks::Now() + 744 base::TimeTicks::Now() +
738 base::TimeDelta::FromMinutes(kRequestTimeoutMinutes)); 745 base::TimeDelta::FromMinutes(kRequestTimeoutMinutes));
739 } 746 }
740 747
741 void ServiceWorkerVersion::SetMainScriptHttpResponseInfo( 748 void ServiceWorkerVersion::SetMainScriptHttpResponseInfo(
742 const net::HttpResponseInfo& http_info) { 749 const net::HttpResponseInfo& http_info) {
743 main_script_http_info_.reset(new net::HttpResponseInfo(http_info)); 750 main_script_http_info_.reset(new net::HttpResponseInfo(http_info));
751
752 // Updates |origin_trial_tokens_| if it is not set yet. This happens when:
753 // 1) The worer is a new one.
754 // OR
755 // 2) The worker is an existing one but the entry in ServiceWorkerDatabase
756 // was written by old version Chrome, so |origin_trial_tokens| wasn't set
757 // in the entry.
falken 2016/10/07 03:35:22 same nits as above
horo 2016/10/07 05:33:32 Done.
758 if (!origin_trial_tokens_) {
759 origin_trial_tokens_ = TrialTokenValidator::GetValidTokensFromHeaders(
760 url::Origin(scope()), http_info.headers.get());
761 }
762
744 FOR_EACH_OBSERVER(Listener, listeners_, 763 FOR_EACH_OBSERVER(Listener, listeners_,
745 OnMainScriptHttpResponseInfoSet(this)); 764 OnMainScriptHttpResponseInfoSet(this));
746 } 765 }
747 766
748 void ServiceWorkerVersion::SimulatePingTimeoutForTesting() { 767 void ServiceWorkerVersion::SimulatePingTimeoutForTesting() {
749 ping_controller_->SimulateTimeoutForTesting(); 768 ping_controller_->SimulateTimeoutForTesting();
750 } 769 }
751 770
752 const net::HttpResponseInfo* 771 const net::HttpResponseInfo*
753 ServiceWorkerVersion::GetMainScriptHttpResponseInfo() { 772 ServiceWorkerVersion::GetMainScriptHttpResponseInfo() {
(...skipping 1041 matching lines...) Expand 10 before | Expand all | Expand 10 after
1795 ServiceWorkerMetrics::RecordTimeBetweenEvents(base::TimeTicks::Now() - 1814 ServiceWorkerMetrics::RecordTimeBetweenEvents(base::TimeTicks::Now() -
1796 idle_time_); 1815 idle_time_);
1797 } 1816 }
1798 1817
1799 void ServiceWorkerVersion::FinishStartWorker(ServiceWorkerStatusCode status) { 1818 void ServiceWorkerVersion::FinishStartWorker(ServiceWorkerStatusCode status) {
1800 start_worker_first_purpose_ = base::nullopt; 1819 start_worker_first_purpose_ = base::nullopt;
1801 RunCallbacks(this, &start_callbacks_, status); 1820 RunCallbacks(this, &start_callbacks_, status);
1802 } 1821 }
1803 1822
1804 } // namespace content 1823 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698