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

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

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 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <functional> 10 #include <functional>
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 // timed out. 95 // timed out.
96 }; 96 };
97 97
98 // Whether the version has fetch handlers or not. 98 // Whether the version has fetch handlers or not.
99 enum class FetchHandlerExistence { 99 enum class FetchHandlerExistence {
100 UNKNOWN, // This version is a new version and not installed yet. 100 UNKNOWN, // This version is a new version and not installed yet.
101 EXISTS, 101 EXISTS,
102 DOES_NOT_EXIST, 102 DOES_NOT_EXIST,
103 }; 103 };
104 104
105 // Navigation Preload support status of the service worker.
106 enum class NavigationPreloadSupportStatus {
107 SUPPORTED,
108 NOT_SUPPORTED_FIELD_TRIAL_STOPPED,
109 NOT_SUPPORTED_DISABLED_BY_COMMAND_LINE,
110 NOT_SUPPORTED_NO_VALID_ORIGIN_TRIAL_TOKEN,
111 };
112
113 class Listener { 105 class Listener {
114 public: 106 public:
115 virtual void OnRunningStateChanged(ServiceWorkerVersion* version) {} 107 virtual void OnRunningStateChanged(ServiceWorkerVersion* version) {}
116 virtual void OnVersionStateChanged(ServiceWorkerVersion* version) {} 108 virtual void OnVersionStateChanged(ServiceWorkerVersion* version) {}
117 virtual void OnDevToolsRoutingIdChanged(ServiceWorkerVersion* version) {} 109 virtual void OnDevToolsRoutingIdChanged(ServiceWorkerVersion* version) {}
118 virtual void OnMainScriptHttpResponseInfoSet( 110 virtual void OnMainScriptHttpResponseInfoSet(
119 ServiceWorkerVersion* version) {} 111 ServiceWorkerVersion* version) {}
120 virtual void OnErrorReported(ServiceWorkerVersion* version, 112 virtual void OnErrorReported(ServiceWorkerVersion* version,
121 const base::string16& error_message, 113 const base::string16& error_message,
122 int line_number, 114 int line_number,
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 size_t GetExternalRequestCountForTest() const { 394 size_t GetExternalRequestCountForTest() const {
403 return external_request_uuid_to_request_id_.size(); 395 return external_request_uuid_to_request_id_.size();
404 } 396 }
405 397
406 // Returns the amount of time left until the request with the latest 398 // Returns the amount of time left until the request with the latest
407 // expiration time expires. 399 // expiration time expires.
408 base::TimeDelta remaining_timeout() const { 400 base::TimeDelta remaining_timeout() const {
409 return max_request_expiration_time_ - tick_clock_->NowTicks(); 401 return max_request_expiration_time_ - tick_clock_->NowTicks();
410 } 402 }
411 403
412 // Returns the Navigation Preload support status of the service worker.
413 // - Origin Trial: Have an effective token.
414 // Command line
415 // Default Enable Disabled
416 // Default A A B2
417 // Field trial Enabled A A B2
418 // Disabled B1 A B2
419 //
420 // - Origin Trial: No token.
421 // Command line
422 // Default Enable Disabled
423 // Default C A C
424 // Field trial Enabled C A C
425 // Disabled C A C
426 //
427 // * A = SUPPORTED
428 // B1 = NOT_SUPPORTED_FIELD_TRIAL_STOPPED
429 // B2 = NOT_SUPPORTED_DISABLED_BY_COMMAND_LINE
430 // C = NOT_SUPPORTED_NO_VALID_ORIGIN_TRIAL_TOKEN
431 //
432 // There are three types of behaviors:
433 // - A: Navigation Preload related methods and attributes are available in JS
434 // and work correctly.
435 // - B: Navigation Preload related methods and attributes are available in
436 // JS. But NavigationPreloadManager's enable, disable and setHeaderValue
437 // methods always return a rejected promise. And FetchEvent's
438 // preloadResponse attribute returns a promise which always resolve with
439 // undefined.
440 // - C: Navigation Preload related methods and attributes are not available
441 // in JS.
442 // This method returns SUPPORTED only for A case.
443 // blink::OriginTrials::serviceWorkerNavigationPreloadEnabled() returns true
444 // for both A and B case. So the methods and attributes are available in JS.
445 NavigationPreloadSupportStatus GetNavigationPreloadSupportStatus() const;
446
447 void CountFeature(uint32_t feature); 404 void CountFeature(uint32_t feature);
448 void set_used_features(const std::set<uint32_t>& used_features) { 405 void set_used_features(const std::set<uint32_t>& used_features) {
449 used_features_ = used_features; 406 used_features_ = used_features;
450 } 407 }
451 const std::set<uint32_t>& used_features() const { return used_features_; } 408 const std::set<uint32_t>& used_features() const { return used_features_; }
452 409
453 private: 410 private:
454 friend class base::RefCounted<ServiceWorkerVersion>; 411 friend class base::RefCounted<ServiceWorkerVersion>;
455 friend class ServiceWorkerMetrics; 412 friend class ServiceWorkerMetrics;
456 friend class ServiceWorkerReadFromCacheJobTest; 413 friend class ServiceWorkerReadFromCacheJobTest;
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 835
879 // At this point |this| can have been deleted, so don't do anything other 836 // At this point |this| can have been deleted, so don't do anything other
880 // than returning. 837 // than returning.
881 838
882 return true; 839 return true;
883 } 840 }
884 841
885 } // namespace content 842 } // namespace content
886 843
887 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ 844 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698