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

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

Issue 2518523003: Limit timeout for foreign fetch events when triggered by another service worker. (Closed)
Patch Set: don't intercept worker main resource fetches Created 4 years 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 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> 8 #include <memory>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/optional.h"
14 #include "base/time/time.h"
13 #include "content/browser/service_worker/service_worker_metrics.h" 15 #include "content/browser/service_worker/service_worker_metrics.h"
14 #include "content/common/content_export.h" 16 #include "content/common/content_export.h"
15 #include "content/common/service_worker/service_worker_event_dispatcher.mojom.h" 17 #include "content/common/service_worker/service_worker_event_dispatcher.mojom.h"
16 #include "content/common/service_worker/service_worker_status_code.h" 18 #include "content/common/service_worker/service_worker_status_code.h"
17 #include "content/common/service_worker/service_worker_types.h" 19 #include "content/common/service_worker/service_worker_types.h"
18 #include "content/common/url_loader.mojom.h" 20 #include "content/common/url_loader.mojom.h"
19 #include "content/common/url_loader_factory.mojom.h" 21 #include "content/common/url_loader_factory.mojom.h"
20 #include "content/public/common/resource_type.h" 22 #include "content/public/common/resource_type.h"
21 #include "net/log/net_log_with_source.h" 23 #include "net/log/net_log_with_source.h"
22 24
(...skipping 11 matching lines...) Expand all
34 using FetchCallback = 36 using FetchCallback =
35 base::Callback<void(ServiceWorkerStatusCode, 37 base::Callback<void(ServiceWorkerStatusCode,
36 ServiceWorkerFetchEventResult, 38 ServiceWorkerFetchEventResult,
37 const ServiceWorkerResponse&, 39 const ServiceWorkerResponse&,
38 const scoped_refptr<ServiceWorkerVersion>&)>; 40 const scoped_refptr<ServiceWorkerVersion>&)>;
39 41
40 ServiceWorkerFetchDispatcher( 42 ServiceWorkerFetchDispatcher(
41 std::unique_ptr<ServiceWorkerFetchRequest> request, 43 std::unique_ptr<ServiceWorkerFetchRequest> request,
42 ServiceWorkerVersion* version, 44 ServiceWorkerVersion* version,
43 ResourceType resource_type, 45 ResourceType resource_type,
46 const base::Optional<base::TimeDelta>& timeout,
44 const net::NetLogWithSource& net_log, 47 const net::NetLogWithSource& net_log,
45 const base::Closure& prepare_callback, 48 const base::Closure& prepare_callback,
46 const FetchCallback& fetch_callback); 49 const FetchCallback& fetch_callback);
47 ~ServiceWorkerFetchDispatcher(); 50 ~ServiceWorkerFetchDispatcher();
48 51
49 // If appropriate, starts the navigation preload request and creates 52 // If appropriate, starts the navigation preload request and creates
50 // |preload_handle_|. 53 // |preload_handle_|.
51 void MaybeStartNavigationPreload(net::URLRequest* original_request); 54 void MaybeStartNavigationPreload(net::URLRequest* original_request);
52 55
53 // Dispatches a fetch event to the |version| given in ctor, and fires 56 // Dispatches a fetch event to the |version| given in ctor, and fires
(...skipping 20 matching lines...) Expand all
74 const ServiceWorkerResponse& response); 77 const ServiceWorkerResponse& response);
75 78
76 ServiceWorkerMetrics::EventType GetEventType() const; 79 ServiceWorkerMetrics::EventType GetEventType() const;
77 80
78 scoped_refptr<ServiceWorkerVersion> version_; 81 scoped_refptr<ServiceWorkerVersion> version_;
79 net::NetLogWithSource net_log_; 82 net::NetLogWithSource net_log_;
80 base::Closure prepare_callback_; 83 base::Closure prepare_callback_;
81 FetchCallback fetch_callback_; 84 FetchCallback fetch_callback_;
82 std::unique_ptr<ServiceWorkerFetchRequest> request_; 85 std::unique_ptr<ServiceWorkerFetchRequest> request_;
83 ResourceType resource_type_; 86 ResourceType resource_type_;
87 base::Optional<base::TimeDelta> timeout_;
84 bool did_complete_; 88 bool did_complete_;
85 mojom::URLLoaderFactoryPtr url_loader_factory_; 89 mojom::URLLoaderFactoryPtr url_loader_factory_;
86 std::unique_ptr<mojom::URLLoader> url_loader_; 90 std::unique_ptr<mojom::URLLoader> url_loader_;
87 std::unique_ptr<mojom::URLLoaderClient> url_loader_client_; 91 std::unique_ptr<mojom::URLLoaderClient> url_loader_client_;
88 mojom::FetchEventPreloadHandlePtr preload_handle_; 92 mojom::FetchEventPreloadHandlePtr preload_handle_;
89 93
90 base::WeakPtrFactory<ServiceWorkerFetchDispatcher> weak_factory_; 94 base::WeakPtrFactory<ServiceWorkerFetchDispatcher> weak_factory_;
91 95
92 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerFetchDispatcher); 96 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerFetchDispatcher);
93 }; 97 };
94 98
95 } // namespace content 99 } // namespace content
96 100
97 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_FETCH_DISPATCHER_H_ 101 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_FETCH_DISPATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698