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

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

Issue 2627023002: Introduce Origin-Trial for Service Worker Navigation Preload (Closed)
Patch Set: s/an/a Created 3 years, 11 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 // timed out. 93 // timed out.
94 }; 94 };
95 95
96 // Whether the version has fetch handlers or not. 96 // Whether the version has fetch handlers or not.
97 enum class FetchHandlerExistence { 97 enum class FetchHandlerExistence {
98 UNKNOWN, // This version is a new version and not installed yet. 98 UNKNOWN, // This version is a new version and not installed yet.
99 EXISTS, 99 EXISTS,
100 DOES_NOT_EXIST, 100 DOES_NOT_EXIST,
101 }; 101 };
102 102
103 // Navigation Preload support status of the service worker.
104 enum class NavigationPreloadSupportStatus {
105 SUPPORTED,
106 NOT_SUPPORTED_FIELD_TRIAL_STOPPED,
107 NOT_SUPPORTED_DISABLED_BY_COMMAND_LINE,
108 NOT_SUPPORTED_NO_VALID_ORIGIN_TRIAL_TOKEN,
109 };
110
103 class Listener { 111 class Listener {
104 public: 112 public:
105 virtual void OnRunningStateChanged(ServiceWorkerVersion* version) {} 113 virtual void OnRunningStateChanged(ServiceWorkerVersion* version) {}
106 virtual void OnVersionStateChanged(ServiceWorkerVersion* version) {} 114 virtual void OnVersionStateChanged(ServiceWorkerVersion* version) {}
107 virtual void OnDevToolsRoutingIdChanged(ServiceWorkerVersion* version) {} 115 virtual void OnDevToolsRoutingIdChanged(ServiceWorkerVersion* version) {}
108 virtual void OnMainScriptHttpResponseInfoSet( 116 virtual void OnMainScriptHttpResponseInfoSet(
109 ServiceWorkerVersion* version) {} 117 ServiceWorkerVersion* version) {}
110 virtual void OnErrorReported(ServiceWorkerVersion* version, 118 virtual void OnErrorReported(ServiceWorkerVersion* version,
111 const base::string16& error_message, 119 const base::string16& error_message,
112 int line_number, 120 int line_number,
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 // mojom::ServiceWorkerEventDispatcher, once all simple events got dispatched 428 // mojom::ServiceWorkerEventDispatcher, once all simple events got dispatched
421 // through mojo, OnSimpleEventResponse function could be removed. 429 // through mojo, OnSimpleEventResponse function could be removed.
422 void OnSimpleEventFinished(int request_id, 430 void OnSimpleEventFinished(int request_id,
423 ServiceWorkerStatusCode status, 431 ServiceWorkerStatusCode status,
424 base::Time dispatch_event_time); 432 base::Time dispatch_event_time);
425 433
426 void NotifyMainScriptRequestHandlerCreated(); 434 void NotifyMainScriptRequestHandlerCreated();
427 void NotifyMainScriptJobCreated( 435 void NotifyMainScriptJobCreated(
428 ServiceWorkerContextRequestHandler::CreateJobStatus status); 436 ServiceWorkerContextRequestHandler::CreateJobStatus status);
429 437
438 // Returns the Navigation Preload support status of the service worker.
439 // - Origin Trial: Have an effective token.
440 // Command line
441 // Default Enable Disabled
442 // Default B1 A B2
443 // Field trial Enabled A A B2
444 // Disabled B1 A B2
445 //
446 // - Origin Trial: No token.
447 // Command line
448 // Default Enable Disabled
449 // Default C A C
450 // Field trial Enabled C A C
451 // Disabled C A C
452 //
453 // * A = SUPPORTED
454 // B1 = NOT_SUPPORTED_FIELD_TRIAL_STOPPED
455 // B2 = NOT_SUPPORTED_DISABLED_BY_COMMAND_LINE
456 // C = NOT_SUPPORTED_NO_VALID_ORIGIN_TRIAL_TOKEN
457 //
458 // There are three types of behaviors:
459 // - A: Navigation Preload related methods and attributes are available in JS
460 // and work correctly.
461 // - B: Navigation Preload related methods and attributes are available in
462 // JS. But NavigationPreloadManager's enable, disable and setHeaderValue
463 // methods always return a rejected promise. And FetchEvent's
464 // preloadResponse attribute returns a promise which always resolve with
465 // undefined.
466 // - C: Navigation Preload related methods and attributes are not available
467 // in JS.
468 // This method returns SUPPORTED only for A case.
469 // blink::OriginTrials::serviceWorkerNavigationPreloadEnabled() returns true
470 // for both A and B case. So the methods and attributes are available in JS.
471 NavigationPreloadSupportStatus GetNavigationPreloadSupportStatus() const;
472
430 private: 473 private:
431 friend class base::RefCounted<ServiceWorkerVersion>; 474 friend class base::RefCounted<ServiceWorkerVersion>;
432 friend class ServiceWorkerMetrics; 475 friend class ServiceWorkerMetrics;
433 friend class ServiceWorkerReadFromCacheJobTest; 476 friend class ServiceWorkerReadFromCacheJobTest;
434 friend class ServiceWorkerStallInStoppingTest; 477 friend class ServiceWorkerStallInStoppingTest;
435 friend class ServiceWorkerURLRequestJobTest; 478 friend class ServiceWorkerURLRequestJobTest;
436 friend class ServiceWorkerVersionBrowserTest; 479 friend class ServiceWorkerVersionBrowserTest;
437 friend class ServiceWorkerVersionTest; 480 friend class ServiceWorkerVersionTest;
438 481
439 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerControlleeRequestHandlerTest, 482 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerControlleeRequestHandlerTest,
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 900
858 // At this point |this| can have been deleted, so don't do anything other 901 // At this point |this| can have been deleted, so don't do anything other
859 // than returning. 902 // than returning.
860 903
861 return true; 904 return true;
862 } 905 }
863 906
864 } // namespace content 907 } // namespace content
865 908
866 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ 909 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698