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_REQUEST_HANDLER_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REQUEST_HANDLER_H_ |
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REQUEST_HANDLER_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REQUEST_HANDLER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/supports_user_data.h" | 10 #include "base/supports_user_data.h" |
(...skipping 13 matching lines...) Expand all Loading... | |
24 } | 24 } |
25 | 25 |
26 namespace storage { | 26 namespace storage { |
27 class BlobStorageContext; | 27 class BlobStorageContext; |
28 } | 28 } |
29 | 29 |
30 namespace content { | 30 namespace content { |
31 | 31 |
32 class ResourceContext; | 32 class ResourceContext; |
33 class ResourceRequestBody; | 33 class ResourceRequestBody; |
34 class NavigationURLLoaderImplCore; | |
34 class ServiceWorkerContextCore; | 35 class ServiceWorkerContextCore; |
35 class ServiceWorkerContextWrapper; | 36 class ServiceWorkerContextWrapper; |
36 class ServiceWorkerProviderHost; | 37 class ServiceWorkerProviderHost; |
37 struct ResourceResponseInfo; | 38 struct ResourceResponseInfo; |
38 | 39 |
39 // Abstract base class for routing network requests to ServiceWorkers. | 40 // Abstract base class for routing network requests to ServiceWorkers. |
40 // Created one per URLRequest and attached to each request. | 41 // Created one per URLRequest and attached to each request. |
41 class CONTENT_EXPORT ServiceWorkerRequestHandler | 42 class CONTENT_EXPORT ServiceWorkerRequestHandler |
42 : public base::SupportsUserData::Data { | 43 : public base::SupportsUserData::Data { |
43 public: | 44 public: |
44 // Attaches a newly created handler if the given |request| needs to | 45 // Attaches a newly created handler if the given |request| needs to |
45 // be handled by ServiceWorker. | 46 // be handled by ServiceWorker. |
46 // TODO(kinuko): While utilizing UserData to attach data to URLRequest | 47 // TODO(kinuko): While utilizing UserData to attach data to URLRequest |
47 // has some precedence, it might be better to attach this handler in a more | 48 // has some precedence, it might be better to attach this handler in a more |
48 // explicit way within content layer, e.g. have ResourceRequestInfoImpl | 49 // explicit way within content layer, e.g. have ResourceRequestInfoImpl |
49 // own it. | 50 // own it. |
50 static void InitializeHandler( | 51 static void InitializeHandler( |
51 net::URLRequest* request, | 52 net::URLRequest* request, |
52 ServiceWorkerContextWrapper* context_wrapper, | 53 ServiceWorkerContextWrapper* context_wrapper, |
53 storage::BlobStorageContext* blob_storage_context, | 54 storage::BlobStorageContext* blob_storage_context, |
54 int process_id, | 55 int process_id, |
55 int provider_id, | 56 int provider_id, |
56 bool skip_service_worker, | 57 bool skip_service_worker, |
57 FetchRequestMode request_mode, | 58 FetchRequestMode request_mode, |
58 FetchCredentialsMode credentials_mode, | 59 FetchCredentialsMode credentials_mode, |
59 FetchRedirectMode redirect_mode, | 60 FetchRedirectMode redirect_mode, |
60 ResourceType resource_type, | 61 ResourceType resource_type, |
61 RequestContextType request_context_type, | 62 RequestContextType request_context_type, |
62 RequestContextFrameType frame_type, | 63 RequestContextFrameType frame_type, |
63 scoped_refptr<ResourceRequestBody> body); | 64 scoped_refptr<ResourceRequestBody> body, |
65 NavigationURLLoaderImplCore* loader); | |
64 | 66 |
65 // Returns the handler attached to |request|. This may return NULL | 67 // Returns the handler attached to |request|. This may return NULL |
66 // if no handler is attached. | 68 // if no handler is attached. |
67 static ServiceWorkerRequestHandler* GetHandler( | 69 static ServiceWorkerRequestHandler* GetHandler( |
68 net::URLRequest* request); | 70 net::URLRequest* request); |
69 | 71 |
70 // Creates a protocol interceptor for ServiceWorker. | 72 // Creates a protocol interceptor for ServiceWorker. |
71 static scoped_ptr<net::URLRequestInterceptor> CreateInterceptor( | 73 static scoped_ptr<net::URLRequestInterceptor> CreateInterceptor( |
72 ResourceContext* resource_context); | 74 ResourceContext* resource_context); |
73 | 75 |
(...skipping 14 matching lines...) Expand all Loading... | |
88 virtual void GetExtraResponseInfo( | 90 virtual void GetExtraResponseInfo( |
89 ResourceResponseInfo* response_info) const = 0; | 91 ResourceResponseInfo* response_info) const = 0; |
90 | 92 |
91 // Methods to support cross site navigations. | 93 // Methods to support cross site navigations. |
92 void PrepareForCrossSiteTransfer(int old_process_id); | 94 void PrepareForCrossSiteTransfer(int old_process_id); |
93 void CompleteCrossSiteTransfer(int new_process_id, | 95 void CompleteCrossSiteTransfer(int new_process_id, |
94 int new_provider_id); | 96 int new_provider_id); |
95 void MaybeCompleteCrossSiteTransferInOldProcess( | 97 void MaybeCompleteCrossSiteTransferInOldProcess( |
96 int old_process_id); | 98 int old_process_id); |
97 | 99 |
100 // PlzNavigate: | |
101 // Methods to handle the dummy SWProviderHost created for browser-initiated | |
102 // navigations. | |
michaeln
2015/09/16 00:56:42
These public methods may not be needed if the xfer
Fabrice (no longer in Chrome)
2015/09/30 17:32:07
Done.
| |
103 scoped_ptr<ServiceWorkerProviderHost> TakeBrowserProviderHost(); | |
104 void SetBrowserProviderHost( | |
105 scoped_ptr<ServiceWorkerProviderHost> provider_host); | |
106 | |
98 ServiceWorkerContextCore* context() const { return context_.get(); } | 107 ServiceWorkerContextCore* context() const { return context_.get(); } |
99 | 108 |
100 protected: | 109 protected: |
101 ServiceWorkerRequestHandler( | 110 ServiceWorkerRequestHandler( |
102 base::WeakPtr<ServiceWorkerContextCore> context, | 111 base::WeakPtr<ServiceWorkerContextCore> context, |
103 base::WeakPtr<ServiceWorkerProviderHost> provider_host, | 112 base::WeakPtr<ServiceWorkerProviderHost> provider_host, |
104 base::WeakPtr<storage::BlobStorageContext> blob_storage_context, | 113 base::WeakPtr<storage::BlobStorageContext> blob_storage_context, |
105 ResourceType resource_type); | 114 ResourceType resource_type); |
106 | 115 |
107 base::WeakPtr<ServiceWorkerContextCore> context_; | 116 base::WeakPtr<ServiceWorkerContextCore> context_; |
108 base::WeakPtr<ServiceWorkerProviderHost> provider_host_; | 117 base::WeakPtr<ServiceWorkerProviderHost> provider_host_; |
109 base::WeakPtr<storage::BlobStorageContext> blob_storage_context_; | 118 base::WeakPtr<storage::BlobStorageContext> blob_storage_context_; |
110 ResourceType resource_type_; | 119 ResourceType resource_type_; |
111 | 120 |
112 private: | 121 private: |
113 scoped_ptr<ServiceWorkerProviderHost> host_for_cross_site_transfer_; | 122 // This host is used for cross-site transfers. |
123 // PlzNavigate: | |
124 // This host is used for browser-initiated navigations. | |
125 scoped_ptr<ServiceWorkerProviderHost> temporary_host_; | |
michaeln
2015/09/16 00:56:42
its good to annotate with // PlzNavigate, picking
Fabrice (no longer in Chrome)
2015/09/30 17:32:07
This has been removed.
| |
114 int old_process_id_; | 126 int old_process_id_; |
115 int old_provider_id_; | 127 int old_provider_id_; |
116 | 128 |
117 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRequestHandler); | 129 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRequestHandler); |
118 }; | 130 }; |
119 | 131 |
120 } // namespace content | 132 } // namespace content |
121 | 133 |
122 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REQUEST_HANDLER_H_ | 134 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REQUEST_HANDLER_H_ |
OLD | NEW |