| 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" |
| 18 | 22 |
| 19 namespace net { | 23 namespace net { |
| 20 class URLRequest; | 24 class URLRequest; |
| 21 } // namespace net | 25 } // namespace net |
| 22 | 26 |
| 23 namespace content { | 27 namespace content { |
| 24 | 28 |
| 25 class ServiceWorkerVersion; | 29 class ServiceWorkerVersion; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 41 const base::Closure& prepare_callback, | 45 const base::Closure& prepare_callback, |
| 42 const FetchCallback& fetch_callback); | 46 const FetchCallback& fetch_callback); |
| 43 ~ServiceWorkerFetchDispatcher(); | 47 ~ServiceWorkerFetchDispatcher(); |
| 44 | 48 |
| 45 // If appropriate, starts the navigation preload request and creates | 49 // If appropriate, starts the navigation preload request and creates |
| 46 // |preload_handle_|. | 50 // |preload_handle_|. |
| 47 void MaybeStartNavigationPreload( | 51 void MaybeStartNavigationPreload( |
| 48 net::URLRequest* original_request, | 52 net::URLRequest* original_request, |
| 49 const MojoURLLoaderFactoryGetter& url_loader_factory_getter); | 53 const MojoURLLoaderFactoryGetter& url_loader_factory_getter); |
| 50 | 54 |
| 51 // Dispatches a fetch event to the |version| given in ctor, and fires | 55 // Dispatches a fecth event to the |version| given in ctor, and fires |
| 52 // |fetch_callback| (also given in ctor) when finishes. It runs | 56 // |fetch_callback| (also given in ctor) when finishes. It runs |
| 53 // |prepare_callback| as an intermediate step once the version is activated | 57 // |prepare_callback| as an intermediate step once the version is activated |
| 54 // and running. | 58 // and running. |
| 55 void Run(); | 59 void Run(); |
| 56 | 60 |
| 57 private: | 61 private: |
| 58 class ResponseCallback; | 62 class ResponseCallback; |
| 59 | 63 |
| 60 void DidWaitForActivation(); | 64 void DidWaitForActivation(); |
| 61 void StartWorker(); | 65 void StartWorker(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 73 | 77 |
| 74 ServiceWorkerMetrics::EventType GetEventType() const; | 78 ServiceWorkerMetrics::EventType GetEventType() const; |
| 75 | 79 |
| 76 scoped_refptr<ServiceWorkerVersion> version_; | 80 scoped_refptr<ServiceWorkerVersion> version_; |
| 77 net::NetLogWithSource net_log_; | 81 net::NetLogWithSource net_log_; |
| 78 base::Closure prepare_callback_; | 82 base::Closure prepare_callback_; |
| 79 FetchCallback fetch_callback_; | 83 FetchCallback fetch_callback_; |
| 80 std::unique_ptr<ServiceWorkerFetchRequest> request_; | 84 std::unique_ptr<ServiceWorkerFetchRequest> request_; |
| 81 ResourceType resource_type_; | 85 ResourceType resource_type_; |
| 82 bool did_complete_; | 86 bool did_complete_; |
| 87 mojom::URLLoaderFactoryPtr url_loader_factory_; |
| 88 std::unique_ptr<mojom::URLLoader> url_loader_; |
| 89 std::unique_ptr<mojom::URLLoaderClient> url_loader_client_; |
| 83 mojom::FetchEventPreloadHandlePtr preload_handle_; | 90 mojom::FetchEventPreloadHandlePtr preload_handle_; |
| 84 | 91 |
| 85 base::WeakPtrFactory<ServiceWorkerFetchDispatcher> weak_factory_; | 92 base::WeakPtrFactory<ServiceWorkerFetchDispatcher> weak_factory_; |
| 86 | 93 |
| 87 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerFetchDispatcher); | 94 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerFetchDispatcher); |
| 88 }; | 95 }; |
| 89 | 96 |
| 90 } // namespace content | 97 } // namespace content |
| 91 | 98 |
| 92 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_FETCH_DISPATCHER_H_ | 99 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_FETCH_DISPATCHER_H_ |
| OLD | NEW |