| 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_LOADER_NAVIGATION_URL_LOADER_IMPL_CORE_H_ | 5 #ifndef CONTENT_BROWSER_LOADER_NAVIGATION_URL_LOADER_IMPL_CORE_H_ |
| 6 #define CONTENT_BROWSER_LOADER_NAVIGATION_URL_LOADER_IMPL_CORE_H_ | 6 #define CONTENT_BROWSER_LOADER_NAVIGATION_URL_LOADER_IMPL_CORE_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "content/browser/loader/navigation_url_loader_impl.h" | 12 #include "content/browser/loader/navigation_url_loader_impl.h" |
| 13 | 13 |
| 14 namespace net { | 14 namespace net { |
| 15 class URLRequest; | 15 class URLRequest; |
| 16 struct RedirectInfo; | 16 struct RedirectInfo; |
| 17 } | 17 } |
| 18 | 18 |
| 19 namespace content { | 19 namespace content { |
| 20 | 20 |
| 21 class FrameTreeNode; | 21 class FrameTreeNode; |
| 22 class NavigationResourceHandler; | 22 class NavigationResourceHandler; |
| 23 class ResourceContext; | 23 class ResourceContext; |
| 24 class ResourceHandler; | 24 class ResourceHandler; |
| 25 class ResourceRequestBody; | 25 class ResourceRequestBody; |
| 26 class ServiceWorkerContext; |
| 27 class ServiceWorkerContextWrapper; |
| 28 class ServiceWorkerProviderHost; |
| 26 class StreamHandle; | 29 class StreamHandle; |
| 27 struct ResourceResponse; | 30 struct ResourceResponse; |
| 28 | 31 |
| 29 // The IO-thread counterpart to the NavigationURLLoaderImpl. It lives on the IO | 32 // The IO-thread counterpart to the NavigationURLLoaderImpl. It lives on the IO |
| 30 // thread and is owned by the UI-thread NavigationURLLoaderImpl. | 33 // thread and is owned by the UI-thread NavigationURLLoaderImpl. |
| 31 // NavigationURLLoaderImplCore interacts with the ResourceDispatcherHost stack | 34 // NavigationURLLoaderImplCore interacts with the ResourceDispatcherHost stack |
| 32 // and forwards signals back to the loader on the UI thread. | 35 // and forwards signals back to the loader on the UI thread. |
| 33 class NavigationURLLoaderImplCore { | 36 class NavigationURLLoaderImplCore { |
| 34 public: | 37 public: |
| 35 // Creates a new NavigationURLLoaderImplCore that forwards signals back to | 38 // Creates a new NavigationURLLoaderImplCore that forwards signals back to |
| 36 // |loader| on the UI thread. | 39 // |loader| on the UI thread. |
| 37 explicit NavigationURLLoaderImplCore( | 40 explicit NavigationURLLoaderImplCore( |
| 38 const base::WeakPtr<NavigationURLLoaderImpl>& loader); | 41 const base::WeakPtr<NavigationURLLoaderImpl>& loader, |
| 42 ServiceWorkerContext* service_worker_context); |
| 39 ~NavigationURLLoaderImplCore(); | 43 ~NavigationURLLoaderImplCore(); |
| 40 | 44 |
| 41 // Starts the request. | 45 // Starts the request. |
| 42 void Start(ResourceContext* resource_context, | 46 void Start(ResourceContext* resource_context, |
| 43 int frame_tree_node_id, | 47 int frame_tree_node_id, |
| 44 scoped_ptr<NavigationRequestInfo> request_info); | 48 scoped_ptr<NavigationRequestInfo> request_info); |
| 45 | 49 |
| 46 // Follows the current pending redirect. | 50 // Follows the current pending redirect. |
| 47 void FollowRedirect(); | 51 void FollowRedirect(); |
| 48 | 52 |
| 49 void set_resource_handler(NavigationResourceHandler* resource_handler) { | 53 void set_resource_handler(NavigationResourceHandler* resource_handler) { |
| 50 resource_handler_ = resource_handler; | 54 resource_handler_ = resource_handler; |
| 51 } | 55 } |
| 52 | 56 |
| 57 ServiceWorkerProviderHost* service_worker_provider_host() { |
| 58 return service_worker_provider_host_.get(); |
| 59 } |
| 60 void SetServiceWorkerProviderHost(scoped_ptr<ServiceWorkerProviderHost>); |
| 61 |
| 53 // Notifies |loader_| on the UI thread that the request was redirected. | 62 // Notifies |loader_| on the UI thread that the request was redirected. |
| 54 void NotifyRequestRedirected(const net::RedirectInfo& redirect_info, | 63 void NotifyRequestRedirected(const net::RedirectInfo& redirect_info, |
| 55 ResourceResponse* response); | 64 ResourceResponse* response); |
| 56 | 65 |
| 57 // Notifies |loader_| on the UI thread that the response started. | 66 // Notifies |loader_| on the UI thread that the response started. |
| 58 void NotifyResponseStarted(ResourceResponse* response, | 67 void NotifyResponseStarted(ResourceResponse* response, |
| 59 scoped_ptr<StreamHandle> body); | 68 scoped_ptr<StreamHandle> body); |
| 60 | 69 |
| 61 // Notifies |loader_| on the UI thread that the request failed. | 70 // Notifies |loader_| on the UI thread that the request failed. |
| 62 void NotifyRequestFailed(bool in_cache, int net_error); | 71 void NotifyRequestFailed(bool in_cache, int net_error); |
| 63 | 72 |
| 64 private: | 73 private: |
| 65 base::WeakPtr<NavigationURLLoaderImpl> loader_; | 74 base::WeakPtr<NavigationURLLoaderImpl> loader_; |
| 75 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_; |
| 66 NavigationResourceHandler* resource_handler_; | 76 NavigationResourceHandler* resource_handler_; |
| 77 scoped_ptr<ServiceWorkerProviderHost> service_worker_provider_host_; |
| 67 | 78 |
| 68 DISALLOW_COPY_AND_ASSIGN(NavigationURLLoaderImplCore); | 79 DISALLOW_COPY_AND_ASSIGN(NavigationURLLoaderImplCore); |
| 69 }; | 80 }; |
| 70 | 81 |
| 71 } // namespace content | 82 } // namespace content |
| 72 | 83 |
| 73 #endif // CONTENT_BROWSER_LOADER_NAVIGATION_URL_LOADER_IMPL_CORE_H_ | 84 #endif // CONTENT_BROWSER_LOADER_NAVIGATION_URL_LOADER_IMPL_CORE_H_ |
| OLD | NEW |