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

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

Issue 2811063002: Enable ServiceWorkerNavigationPreload by default (Closed)
Patch Set: rebase 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 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>
11 #include <string> 11 #include <string>
12 12
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/debug/alias.h" 14 #include "base/debug/alias.h"
15 #include "base/feature_list.h"
16 #include "base/guid.h" 15 #include "base/guid.h"
17 #include "base/location.h" 16 #include "base/location.h"
18 #include "base/macros.h" 17 #include "base/macros.h"
19 #include "base/memory/ref_counted.h" 18 #include "base/memory/ref_counted.h"
20 #include "base/metrics/histogram_macros.h" 19 #include "base/metrics/histogram_macros.h"
21 #include "base/single_thread_task_runner.h" 20 #include "base/single_thread_task_runner.h"
22 #include "base/stl_util.h" 21 #include "base/stl_util.h"
23 #include "base/strings/string16.h" 22 #include "base/strings/string16.h"
24 #include "base/strings/utf_string_conversions.h" 23 #include "base/strings/utf_string_conversions.h"
25 #include "base/threading/thread_task_runner_handle.h" 24 #include "base/threading/thread_task_runner_handle.h"
(...skipping 11 matching lines...) Expand all
37 #include "content/browser/service_worker/service_worker_registration.h" 36 #include "content/browser/service_worker/service_worker_registration.h"
38 #include "content/common/origin_trials/trial_token_validator.h" 37 #include "content/common/origin_trials/trial_token_validator.h"
39 #include "content/common/service_worker/embedded_worker_messages.h" 38 #include "content/common/service_worker/embedded_worker_messages.h"
40 #include "content/common/service_worker/embedded_worker_start_params.h" 39 #include "content/common/service_worker/embedded_worker_start_params.h"
41 #include "content/common/service_worker/service_worker_messages.h" 40 #include "content/common/service_worker/service_worker_messages.h"
42 #include "content/common/service_worker/service_worker_utils.h" 41 #include "content/common/service_worker/service_worker_utils.h"
43 #include "content/public/browser/browser_thread.h" 42 #include "content/public/browser/browser_thread.h"
44 #include "content/public/browser/content_browser_client.h" 43 #include "content/public/browser/content_browser_client.h"
45 #include "content/public/browser/render_process_host.h" 44 #include "content/public/browser/render_process_host.h"
46 #include "content/public/common/content_client.h" 45 #include "content/public/common/content_client.h"
47 #include "content/public/common/content_features.h"
48 #include "content/public/common/content_switches.h" 46 #include "content/public/common/content_switches.h"
49 #include "content/public/common/result_codes.h" 47 #include "content/public/common/result_codes.h"
50 #include "net/http/http_response_headers.h" 48 #include "net/http/http_response_headers.h"
51 #include "net/http/http_response_info.h" 49 #include "net/http/http_response_info.h"
52 #include "third_party/WebKit/public/web/WebConsoleMessage.h" 50 #include "third_party/WebKit/public/web/WebConsoleMessage.h"
53 51
54 namespace content { 52 namespace content {
55 53
56 using StatusCallback = ServiceWorkerVersion::StatusCallback; 54 using StatusCallback = ServiceWorkerVersion::StatusCallback;
57 55
(...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 if (!request) 1052 if (!request)
1055 return; 1053 return;
1056 // Copy error callback before calling FinishRequest. 1054 // Copy error callback before calling FinishRequest.
1057 StatusCallback callback = request->error_callback; 1055 StatusCallback callback = request->error_callback;
1058 1056
1059 FinishRequest(request_id, status == SERVICE_WORKER_OK, dispatch_event_time); 1057 FinishRequest(request_id, status == SERVICE_WORKER_OK, dispatch_event_time);
1060 1058
1061 callback.Run(status); 1059 callback.Run(status);
1062 } 1060 }
1063 1061
1064 ServiceWorkerVersion::NavigationPreloadSupportStatus
1065 ServiceWorkerVersion::GetNavigationPreloadSupportStatus() const {
1066 // The origin trial of Navigation Preload started from M57. And the worker
1067 // entry in the database written by Chrome (>= M56) must have the
1068 // origin_trial_tokens field.
1069 const bool has_valid_token =
1070 origin_trial_tokens_ &&
1071 base::ContainsKey(*origin_trial_tokens_,
1072 "ServiceWorkerNavigationPreload");
1073 if (!has_valid_token) {
1074 if (base::FeatureList::GetInstance()->IsFeatureOverriddenFromCommandLine(
1075 features::kServiceWorkerNavigationPreload.name,
1076 base::FeatureList::OVERRIDE_ENABLE_FEATURE)) {
1077 return NavigationPreloadSupportStatus::SUPPORTED;
1078 } else {
1079 return NavigationPreloadSupportStatus::
1080 NOT_SUPPORTED_NO_VALID_ORIGIN_TRIAL_TOKEN;
1081 }
1082 }
1083 if (base::FeatureList::GetInstance()->IsFeatureOverriddenFromCommandLine(
1084 features::kServiceWorkerNavigationPreload.name,
1085 base::FeatureList::OVERRIDE_ENABLE_FEATURE)) {
1086 return NavigationPreloadSupportStatus::SUPPORTED;
1087 }
1088 if (base::FeatureList::GetInstance()->IsFeatureOverriddenFromCommandLine(
1089 features::kServiceWorkerNavigationPreload.name,
1090 base::FeatureList::OVERRIDE_DISABLE_FEATURE)) {
1091 return NavigationPreloadSupportStatus::
1092 NOT_SUPPORTED_DISABLED_BY_COMMAND_LINE;
1093 }
1094 if (base::FeatureList::IsEnabled(features::kServiceWorkerNavigationPreload)) {
1095 return NavigationPreloadSupportStatus::SUPPORTED;
1096 }
1097 return NavigationPreloadSupportStatus::NOT_SUPPORTED_FIELD_TRIAL_STOPPED;
1098 }
1099
1100 void ServiceWorkerVersion::CountFeature(uint32_t feature) { 1062 void ServiceWorkerVersion::CountFeature(uint32_t feature) {
1101 if (!used_features_.insert(feature).second) 1063 if (!used_features_.insert(feature).second)
1102 return; 1064 return;
1103 for (auto provider_host_by_uuid : controllee_map_) 1065 for (auto provider_host_by_uuid : controllee_map_)
1104 provider_host_by_uuid.second->CountFeature(feature); 1066 provider_host_by_uuid.second->CountFeature(feature);
1105 } 1067 }
1106 1068
1107 void ServiceWorkerVersion::OnOpenWindow(int request_id, GURL url) { 1069 void ServiceWorkerVersion::OnOpenWindow(int request_id, GURL url) {
1108 // Just abort if we are shutting down. 1070 // Just abort if we are shutting down.
1109 if (!context_) 1071 if (!context_)
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after
1878 1840
1879 void ServiceWorkerVersion::CleanUpExternalRequest( 1841 void ServiceWorkerVersion::CleanUpExternalRequest(
1880 const std::string& request_uuid, 1842 const std::string& request_uuid,
1881 ServiceWorkerStatusCode status) { 1843 ServiceWorkerStatusCode status) {
1882 if (status == SERVICE_WORKER_OK) 1844 if (status == SERVICE_WORKER_OK)
1883 return; 1845 return;
1884 external_request_uuid_to_request_id_.erase(request_uuid); 1846 external_request_uuid_to_request_id_.erase(request_uuid);
1885 } 1847 }
1886 1848
1887 } // namespace content 1849 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/service_worker/service_worker_version.h ('k') | content/child/runtime_features.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698