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

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

Issue 2118243002: [proof-of-concept] SW thread independent of the main thread Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 3 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 "base/callback.h" 8 #include "base/callback.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "content/browser/service_worker/service_worker_metrics.h" 11 #include "content/browser/service_worker/service_worker_metrics.h"
12 #include "content/common/content_export.h" 12 #include "content/common/content_export.h"
13 #include "content/common/service_worker/service_worker_status_code.h" 13 #include "content/common/service_worker/service_worker_status_code.h"
14 #include "content/common/service_worker/service_worker_types.h" 14 #include "content/common/service_worker/service_worker_types.h"
15 #include "content/public/common/resource_type.h" 15 #include "content/public/common/resource_type.h"
16 #include "net/log/net_log.h" 16 #include "net/log/net_log.h"
17 #include "mojo/public/cpp/bindings/string.h"
18 #include "mojo/public/cpp/bindings/struct_ptr.h"
17 19
20 namespace blink {
21 namespace mojom {
22 class ServiceWorkerResponse;
23 }
24 }
18 namespace content { 25 namespace content {
19 26
20 class ServiceWorkerVersion; 27 class ServiceWorkerVersion;
21 28
22 // A helper class to dispatch fetch event to a service worker. 29 // A helper class to dispatch fetch event to a service worker.
23 class CONTENT_EXPORT ServiceWorkerFetchDispatcher { 30 class CONTENT_EXPORT ServiceWorkerFetchDispatcher {
24 public: 31 public:
25 typedef base::Callback<void(ServiceWorkerStatusCode, 32 typedef base::Callback<void(ServiceWorkerStatusCode,
26 ServiceWorkerFetchEventResult, 33 ServiceWorkerFetchEventResult,
27 const ServiceWorkerResponse&, 34 const ServiceWorkerResponse&,
(...skipping 25 matching lines...) Expand all
53 void DispatchFetchEvent(); 60 void DispatchFetchEvent();
54 void DidFailToDispatch(ServiceWorkerStatusCode status); 61 void DidFailToDispatch(ServiceWorkerStatusCode status);
55 void DidFail(ServiceWorkerStatusCode status); 62 void DidFail(ServiceWorkerStatusCode status);
56 void DidFinish(int request_id, 63 void DidFinish(int request_id,
57 ServiceWorkerFetchEventResult fetch_result, 64 ServiceWorkerFetchEventResult fetch_result,
58 const ServiceWorkerResponse& response); 65 const ServiceWorkerResponse& response);
59 void Complete(ServiceWorkerStatusCode status, 66 void Complete(ServiceWorkerStatusCode status,
60 ServiceWorkerFetchEventResult fetch_result, 67 ServiceWorkerFetchEventResult fetch_result,
61 const ServiceWorkerResponse& response); 68 const ServiceWorkerResponse& response);
62 69
70 void OnFetchEventCallback(
71 bool handled,
72 mojo::StructPtr<blink::mojom::ServiceWorkerResponse> response);
73
63 ServiceWorkerMetrics::EventType GetEventType() const; 74 ServiceWorkerMetrics::EventType GetEventType() const;
64 75
65 scoped_refptr<ServiceWorkerVersion> version_; 76 scoped_refptr<ServiceWorkerVersion> version_;
66 net::BoundNetLog net_log_; 77 net::BoundNetLog net_log_;
67 base::Closure prepare_callback_; 78 base::Closure prepare_callback_;
68 FetchCallback fetch_callback_; 79 FetchCallback fetch_callback_;
69 std::unique_ptr<ServiceWorkerFetchRequest> request_; 80 std::unique_ptr<ServiceWorkerFetchRequest> request_;
70 ResourceType resource_type_; 81 ResourceType resource_type_;
71 bool did_complete_; 82 bool did_complete_;
72 base::WeakPtrFactory<ServiceWorkerFetchDispatcher> weak_factory_; 83 base::WeakPtrFactory<ServiceWorkerFetchDispatcher> weak_factory_;
73 84
74 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerFetchDispatcher); 85 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerFetchDispatcher);
75 }; 86 };
76 87
77 } // namespace content 88 } // namespace content
78 89
79 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_FETCH_DISPATCHER_H_ 90 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_FETCH_DISPATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698