| 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_H_ | 5 #ifndef CONTENT_BROWSER_LOADER_NAVIGATION_URL_LOADER_IMPL_H_ |
| 6 #define CONTENT_BROWSER_LOADER_NAVIGATION_URL_LOADER_IMPL_H_ | 6 #define CONTENT_BROWSER_LOADER_NAVIGATION_URL_LOADER_IMPL_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "content/browser/loader/navigation_url_loader.h" | 14 #include "content/browser/loader/navigation_url_loader.h" |
| 15 #include "mojo/public/cpp/system/data_pipe.h" |
| 15 | 16 |
| 16 namespace net { | 17 namespace net { |
| 17 struct RedirectInfo; | 18 struct RedirectInfo; |
| 18 } | 19 } |
| 19 | 20 |
| 20 namespace content { | 21 namespace content { |
| 21 | 22 |
| 22 class AppCacheNavigationHandle; | 23 class AppCacheNavigationHandle; |
| 23 class NavigationURLLoaderImplCore; | 24 class NavigationURLLoaderImplCore; |
| 24 class NavigationData; | 25 class NavigationData; |
| 25 class ServiceWorkerNavigationHandle; | 26 class ServiceWorkerNavigationHandle; |
| 26 class StreamHandle; | |
| 27 struct GlobalRequestID; | 27 struct GlobalRequestID; |
| 28 struct ResourceResponse; | 28 struct ResourceResponse; |
| 29 struct SSLStatus; | 29 struct SSLStatus; |
| 30 | 30 |
| 31 class NavigationURLLoaderImpl : public NavigationURLLoader { | 31 class NavigationURLLoaderImpl : public NavigationURLLoader { |
| 32 public: | 32 public: |
| 33 // The caller is responsible for ensuring that |delegate| outlives the loader. | 33 // The caller is responsible for ensuring that |delegate| outlives the loader. |
| 34 NavigationURLLoaderImpl(ResourceContext* resource_context, | 34 NavigationURLLoaderImpl(ResourceContext* resource_context, |
| 35 StoragePartition* storage_partition, | 35 StoragePartition* storage_partition, |
| 36 std::unique_ptr<NavigationRequestInfo> request_info, | 36 std::unique_ptr<NavigationRequestInfo> request_info, |
| 37 std::unique_ptr<NavigationUIData> navigation_ui_data, | 37 std::unique_ptr<NavigationUIData> navigation_ui_data, |
| 38 ServiceWorkerNavigationHandle* service_worker_handle, | 38 ServiceWorkerNavigationHandle* service_worker_handle, |
| 39 AppCacheNavigationHandle* appcache_handle, | 39 AppCacheNavigationHandle* appcache_handle, |
| 40 NavigationURLLoaderDelegate* delegate); | 40 NavigationURLLoaderDelegate* delegate); |
| 41 ~NavigationURLLoaderImpl() override; | 41 ~NavigationURLLoaderImpl() override; |
| 42 | 42 |
| 43 // NavigationURLLoader implementation. | 43 // NavigationURLLoader implementation. |
| 44 void FollowRedirect() override; | 44 void FollowRedirect() override; |
| 45 void ProceedWithResponse() override; | 45 void ProceedWithResponse() override; |
| 46 | 46 |
| 47 private: | 47 private: |
| 48 friend class NavigationURLLoaderImplCore; | 48 friend class NavigationURLLoaderImplCore; |
| 49 | 49 |
| 50 // Notifies the delegate of a redirect. | 50 // Notifies the delegate of a redirect. |
| 51 void NotifyRequestRedirected(const net::RedirectInfo& redirect_info, | 51 void NotifyRequestRedirected(const net::RedirectInfo& redirect_info, |
| 52 const scoped_refptr<ResourceResponse>& response); | 52 const scoped_refptr<ResourceResponse>& response); |
| 53 | 53 |
| 54 // Notifies the delegate that the response has started. | 54 // Notifies the delegate that the response has started. |
| 55 void NotifyResponseStarted(const scoped_refptr<ResourceResponse>& response, | 55 void NotifyResponseStarted(const scoped_refptr<ResourceResponse>& response, |
| 56 std::unique_ptr<StreamHandle> body, | 56 mojo::ScopedDataPipeConsumerHandle consumer_handle, |
| 57 const SSLStatus& ssl_status, | 57 const SSLStatus& ssl_status, |
| 58 std::unique_ptr<NavigationData> navigation_data, | 58 std::unique_ptr<NavigationData> navigation_data, |
| 59 const GlobalRequestID& request_id, | 59 const GlobalRequestID& request_id, |
| 60 bool is_download, | 60 bool is_download, |
| 61 bool is_stream); | 61 bool is_stream); |
| 62 | 62 |
| 63 // Notifies the delegate the request failed to return a response. | 63 // Notifies the delegate the request failed to return a response. |
| 64 void NotifyRequestFailed(bool in_cache, int net_error); | 64 void NotifyRequestFailed(bool in_cache, int net_error); |
| 65 | 65 |
| 66 // Notifies the delegate the begin navigation request was handled and a | 66 // Notifies the delegate the begin navigation request was handled and a |
| 67 // potential first network request is about to be made. | 67 // potential first network request is about to be made. |
| 68 void NotifyRequestStarted(base::TimeTicks timestamp); | 68 void NotifyRequestStarted(base::TimeTicks timestamp); |
| 69 | 69 |
| 70 NavigationURLLoaderDelegate* delegate_; | 70 NavigationURLLoaderDelegate* delegate_; |
| 71 | 71 |
| 72 // |core_| is deleted on the IO thread in a subsequent task when the | 72 // |core_| is deleted on the IO thread in a subsequent task when the |
| 73 // NavigationURLLoaderImpl goes out of scope. | 73 // NavigationURLLoaderImpl goes out of scope. |
| 74 NavigationURLLoaderImplCore* core_; | 74 NavigationURLLoaderImplCore* core_; |
| 75 | 75 |
| 76 base::WeakPtrFactory<NavigationURLLoaderImpl> weak_factory_; | 76 base::WeakPtrFactory<NavigationURLLoaderImpl> weak_factory_; |
| 77 | 77 |
| 78 DISALLOW_COPY_AND_ASSIGN(NavigationURLLoaderImpl); | 78 DISALLOW_COPY_AND_ASSIGN(NavigationURLLoaderImpl); |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 } // namespace content | 81 } // namespace content |
| 82 | 82 |
| 83 #endif // CONTENT_BROWSER_LOADER_NAVIGATION_URL_LOADER_IMPL_H_ | 83 #endif // CONTENT_BROWSER_LOADER_NAVIGATION_URL_LOADER_IMPL_H_ |
| OLD | NEW |