Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_FETCH_DISPATCHER_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_FETCH_DISPATCHER_H_ |
| 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_FETCH_DISPATCHER_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_FETCH_DISPATCHER_H_ |
| 7 | 7 |
| 8 #include <memory> | |
| 9 | |
| 8 #include "base/callback.h" | 10 #include "base/callback.h" |
| 9 #include "base/macros.h" | 11 #include "base/macros.h" |
| 10 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 11 #include "content/browser/service_worker/service_worker_metrics.h" | 13 #include "content/browser/service_worker/service_worker_metrics.h" |
| 12 #include "content/common/content_export.h" | 14 #include "content/common/content_export.h" |
| 13 #include "content/common/service_worker/fetch_event_dispatcher.mojom.h" | 15 #include "content/common/service_worker/fetch_event_dispatcher.mojom.h" |
| 14 #include "content/common/service_worker/service_worker_status_code.h" | 16 #include "content/common/service_worker/service_worker_status_code.h" |
| 15 #include "content/common/service_worker/service_worker_types.h" | 17 #include "content/common/service_worker/service_worker_types.h" |
| 18 #include "content/common/url_loader.mojom.h" | |
| 19 #include "content/common/url_loader_factory.mojom.h" | |
| 16 #include "content/public/common/resource_type.h" | 20 #include "content/public/common/resource_type.h" |
| 17 #include "net/log/net_log_with_source.h" | 21 #include "net/log/net_log_with_source.h" |
| 22 #include "services/service_manager/public/cpp/interface_provider.h" | |
| 23 #include "services/service_manager/public/cpp/interface_registry.h" | |
| 18 | 24 |
| 19 namespace net { | 25 namespace net { |
| 20 class URLRequest; | 26 class URLRequest; |
| 21 } // namespace net | 27 } // namespace net |
| 22 | 28 |
| 23 namespace content { | 29 namespace content { |
| 24 | 30 |
| 25 class ServiceWorkerVersion; | 31 class ServiceWorkerVersion; |
| 26 | 32 |
| 27 // A helper class to dispatch fetch event to a service worker. | 33 // A helper class to dispatch fetch event to a service worker. |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 41 const base::Closure& prepare_callback, | 47 const base::Closure& prepare_callback, |
| 42 const FetchCallback& fetch_callback); | 48 const FetchCallback& fetch_callback); |
| 43 ~ServiceWorkerFetchDispatcher(); | 49 ~ServiceWorkerFetchDispatcher(); |
| 44 | 50 |
| 45 // If appropriate, starts the navigation preload request and creates | 51 // If appropriate, starts the navigation preload request and creates |
| 46 // |preload_handle_|. | 52 // |preload_handle_|. |
| 47 void MaybeStartNavigationPreload( | 53 void MaybeStartNavigationPreload( |
| 48 net::URLRequest* original_request, | 54 net::URLRequest* original_request, |
| 49 const MojoURLLoaderFactoryGetter& url_loader_factory_getter); | 55 const MojoURLLoaderFactoryGetter& url_loader_factory_getter); |
| 50 | 56 |
| 51 // Dispatches a fetch event to the |version| given in ctor, and fires | 57 // Dispatches a fecth event to the |version| given in ctor, and fires |
| 52 // |fetch_callback| (also given in ctor) when finishes. It runs | 58 // |fetch_callback| (also given in ctor) when finishes. It runs |
| 53 // |prepare_callback| as an intermediate step once the version is activated | 59 // |prepare_callback| as an intermediate step once the version is activated |
| 54 // and running. | 60 // and running. |
| 55 void Run(); | 61 void Run(); |
| 56 | 62 |
| 57 private: | 63 private: |
| 58 class ResponseCallback; | 64 class ResponseCallback; |
| 59 | 65 |
| 60 void DidWaitForActivation(); | 66 void DidWaitForActivation(); |
| 61 void StartWorker(); | 67 void StartWorker(); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 73 | 79 |
| 74 ServiceWorkerMetrics::EventType GetEventType() const; | 80 ServiceWorkerMetrics::EventType GetEventType() const; |
| 75 | 81 |
| 76 scoped_refptr<ServiceWorkerVersion> version_; | 82 scoped_refptr<ServiceWorkerVersion> version_; |
| 77 net::NetLogWithSource net_log_; | 83 net::NetLogWithSource net_log_; |
| 78 base::Closure prepare_callback_; | 84 base::Closure prepare_callback_; |
| 79 FetchCallback fetch_callback_; | 85 FetchCallback fetch_callback_; |
| 80 std::unique_ptr<ServiceWorkerFetchRequest> request_; | 86 std::unique_ptr<ServiceWorkerFetchRequest> request_; |
| 81 ResourceType resource_type_; | 87 ResourceType resource_type_; |
| 82 bool did_complete_; | 88 bool did_complete_; |
| 89 mojom::URLLoaderFactoryPtr url_loader_factory_; | |
| 90 std::unique_ptr<mojom::URLLoader> url_loader_; | |
| 91 std::unique_ptr<mojom::URLLoaderClient> url_loader_client_; | |
|
horo
2016/10/28 03:01:28
As I talked offline, you must keep |url_loader_cli
yhirano
2016/11/01 10:10:31
Done.
| |
| 92 service_manager::InterfaceRegistry interface_registry_; | |
| 93 service_manager::InterfaceProvider interface_provider_; | |
| 83 mojom::FetchEventPreloadHandlePtr preload_handle_; | 94 mojom::FetchEventPreloadHandlePtr preload_handle_; |
| 84 | 95 |
| 85 base::WeakPtrFactory<ServiceWorkerFetchDispatcher> weak_factory_; | 96 base::WeakPtrFactory<ServiceWorkerFetchDispatcher> weak_factory_; |
| 86 | 97 |
| 87 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerFetchDispatcher); | 98 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerFetchDispatcher); |
| 88 }; | 99 }; |
| 89 | 100 |
| 90 } // namespace content | 101 } // namespace content |
| 91 | 102 |
| 92 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_FETCH_DISPATCHER_H_ | 103 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_FETCH_DISPATCHER_H_ |
| OLD | NEW |