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

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

Issue 2684533002: [WIP] Mojofy respondwith
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 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/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/optional.h" 14 #include "base/optional.h"
15 #include "base/time/time.h" 15 #include "base/time/time.h"
16 #include "content/browser/service_worker/service_worker_metrics.h" 16 #include "content/browser/service_worker/service_worker_metrics.h"
17 #include "content/common/content_export.h" 17 #include "content/common/content_export.h"
18 #include "content/common/service_worker/service_worker_event_dispatcher.mojom.h" 18 #include "content/common/service_worker/service_worker_event_dispatcher.mojom.h"
19 #include "content/common/service_worker/service_worker_status_code.h" 19 #include "content/common/service_worker/service_worker_status_code.h"
20 #include "content/common/service_worker/service_worker_types.h" 20 #include "content/common/service_worker/service_worker_types.h"
21 #include "content/common/url_loader.mojom.h" 21 #include "content/common/url_loader.mojom.h"
22 #include "content/common/url_loader_factory.mojom.h" 22 #include "content/common/url_loader_factory.mojom.h"
23 #include "content/public/common/resource_type.h" 23 #include "content/public/common/resource_type.h"
24 #include "mojo/public/cpp/system/data_pipe.h"
24 #include "net/log/net_log_with_source.h" 25 #include "net/log/net_log_with_source.h"
25 26
26 namespace net { 27 namespace net {
27 class URLRequest; 28 class URLRequest;
28 } // namespace net 29 } // namespace net
29 30
30 namespace content { 31 namespace content {
31 32
32 class ServiceWorkerVersion; 33 class ServiceWorkerVersion;
33 34
34 // A helper class to dispatch fetch event to a service worker. 35 // A helper class to dispatch fetch event to a service worker.
35 class CONTENT_EXPORT ServiceWorkerFetchDispatcher { 36 class CONTENT_EXPORT ServiceWorkerFetchDispatcher {
36 public: 37 public:
37 using FetchCallback = 38 using FetchCallback =
38 base::Callback<void(ServiceWorkerStatusCode, 39 base::Callback<void(ServiceWorkerStatusCode,
39 ServiceWorkerFetchEventResult, 40 ServiceWorkerFetchEventResult,
40 const ServiceWorkerResponse&, 41 const ServiceWorkerResponse&,
42 mojo::ScopedDataPipeConsumerHandle stream,
41 const scoped_refptr<ServiceWorkerVersion>&)>; 43 const scoped_refptr<ServiceWorkerVersion>&)>;
42 44
43 ServiceWorkerFetchDispatcher( 45 ServiceWorkerFetchDispatcher(
44 std::unique_ptr<ServiceWorkerFetchRequest> request, 46 std::unique_ptr<ServiceWorkerFetchRequest> request,
45 ServiceWorkerVersion* version, 47 ServiceWorkerVersion* version,
46 ResourceType resource_type, 48 ResourceType resource_type,
47 const base::Optional<base::TimeDelta>& timeout, 49 const base::Optional<base::TimeDelta>& timeout,
48 const net::NetLogWithSource& net_log, 50 const net::NetLogWithSource& net_log,
49 const base::Closure& prepare_callback, 51 const base::Closure& prepare_callback,
50 const FetchCallback& fetch_callback); 52 const FetchCallback& fetch_callback);
(...skipping 17 matching lines...) Expand all
68 70
69 void DidWaitForActivation(); 71 void DidWaitForActivation();
70 void StartWorker(); 72 void StartWorker();
71 void DidStartWorker(); 73 void DidStartWorker();
72 void DidFailToStartWorker(ServiceWorkerStatusCode status); 74 void DidFailToStartWorker(ServiceWorkerStatusCode status);
73 void DispatchFetchEvent(); 75 void DispatchFetchEvent();
74 void DidFailToDispatch(ServiceWorkerStatusCode status); 76 void DidFailToDispatch(ServiceWorkerStatusCode status);
75 void DidFail(ServiceWorkerStatusCode status); 77 void DidFail(ServiceWorkerStatusCode status);
76 void DidFinish(int request_id, 78 void DidFinish(int request_id,
77 ServiceWorkerFetchEventResult fetch_result, 79 ServiceWorkerFetchEventResult fetch_result,
78 const ServiceWorkerResponse& response); 80 const ServiceWorkerResponse& response,
81 mojo::ScopedDataPipeConsumerHandle stream);
79 void Complete(ServiceWorkerStatusCode status, 82 void Complete(ServiceWorkerStatusCode status,
80 ServiceWorkerFetchEventResult fetch_result, 83 ServiceWorkerFetchEventResult fetch_result,
81 const ServiceWorkerResponse& response); 84 const ServiceWorkerResponse& response,
85 mojo::ScopedDataPipeConsumerHandle stream);
82 86
83 static void OnFetchEventFinished( 87 static void OnFetchEventFinished(
84 ServiceWorkerVersion* version, 88 ServiceWorkerVersion* version,
85 int event_finish_id, 89 int event_finish_id,
86 scoped_refptr<URLLoaderAssets> url_loader_assets, 90 scoped_refptr<URLLoaderAssets> url_loader_assets,
87 ServiceWorkerStatusCode status, 91 ServiceWorkerStatusCode status,
88 base::Time dispatch_event_time); 92 base::Time dispatch_event_time);
89 93
90 ServiceWorkerMetrics::EventType GetEventType() const; 94 ServiceWorkerMetrics::EventType GetEventType() const;
91 95
(...skipping 11 matching lines...) Expand all
103 mojom::FetchEventPreloadHandlePtr preload_handle_; 107 mojom::FetchEventPreloadHandlePtr preload_handle_;
104 108
105 base::WeakPtrFactory<ServiceWorkerFetchDispatcher> weak_factory_; 109 base::WeakPtrFactory<ServiceWorkerFetchDispatcher> weak_factory_;
106 110
107 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerFetchDispatcher); 111 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerFetchDispatcher);
108 }; 112 };
109 113
110 } // namespace content 114 } // namespace content
111 115
112 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_FETCH_DISPATCHER_H_ 116 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_FETCH_DISPATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698