| 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 | 15 |
| 16 namespace net { | 16 namespace net { |
| 17 struct RedirectInfo; | 17 struct RedirectInfo; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace content { | 20 namespace content { |
| 21 | 21 |
| 22 class NavigationURLLoaderImplCore; | 22 class NavigationURLLoaderImplCore; |
| 23 class NavigationData; |
| 23 class ServiceWorkerNavigationHandle; | 24 class ServiceWorkerNavigationHandle; |
| 24 class StreamHandle; | 25 class StreamHandle; |
| 25 struct ResourceResponse; | 26 struct ResourceResponse; |
| 26 | 27 |
| 27 class NavigationURLLoaderImpl : public NavigationURLLoader { | 28 class NavigationURLLoaderImpl : public NavigationURLLoader { |
| 28 public: | 29 public: |
| 29 // The caller is responsible for ensuring that |delegate| outlives the loader. | 30 // The caller is responsible for ensuring that |delegate| outlives the loader. |
| 30 NavigationURLLoaderImpl(BrowserContext* browser_context, | 31 NavigationURLLoaderImpl(BrowserContext* browser_context, |
| 31 std::unique_ptr<NavigationRequestInfo> request_info, | 32 std::unique_ptr<NavigationRequestInfo> request_info, |
| 32 ServiceWorkerNavigationHandle* service_worker_handle, | 33 ServiceWorkerNavigationHandle* service_worker_handle, |
| 33 NavigationURLLoaderDelegate* delegate); | 34 NavigationURLLoaderDelegate* delegate); |
| 34 ~NavigationURLLoaderImpl() override; | 35 ~NavigationURLLoaderImpl() override; |
| 35 | 36 |
| 36 // NavigationURLLoader implementation. | 37 // NavigationURLLoader implementation. |
| 37 void FollowRedirect() override; | 38 void FollowRedirect() override; |
| 38 void ProceedWithResponse() override; | 39 void ProceedWithResponse() override; |
| 39 | 40 |
| 40 private: | 41 private: |
| 41 friend class NavigationURLLoaderImplCore; | 42 friend class NavigationURLLoaderImplCore; |
| 42 | 43 |
| 43 // Notifies the delegate of a redirect. | 44 // Notifies the delegate of a redirect. |
| 44 void NotifyRequestRedirected(const net::RedirectInfo& redirect_info, | 45 void NotifyRequestRedirected(const net::RedirectInfo& redirect_info, |
| 45 const scoped_refptr<ResourceResponse>& response); | 46 const scoped_refptr<ResourceResponse>& response); |
| 46 | 47 |
| 47 // Notifies the delegate that the response has started. | 48 // Notifies the delegate that the response has started. |
| 48 void NotifyResponseStarted(const scoped_refptr<ResourceResponse>& response, | 49 void NotifyResponseStarted(const scoped_refptr<ResourceResponse>& response, |
| 49 std::unique_ptr<StreamHandle> body); | 50 std::unique_ptr<StreamHandle> body, |
| 51 std::unique_ptr<NavigationData> navigation_data); |
| 50 | 52 |
| 51 // Notifies the delegate the request failed to return a response. | 53 // Notifies the delegate the request failed to return a response. |
| 52 void NotifyRequestFailed(bool in_cache, int net_error); | 54 void NotifyRequestFailed(bool in_cache, int net_error); |
| 53 | 55 |
| 54 // Notifies the delegate the begin navigation request was handled and a | 56 // Notifies the delegate the begin navigation request was handled and a |
| 55 // potential first network request is about to be made. | 57 // potential first network request is about to be made. |
| 56 void NotifyRequestStarted(base::TimeTicks timestamp); | 58 void NotifyRequestStarted(base::TimeTicks timestamp); |
| 57 | 59 |
| 58 NavigationURLLoaderDelegate* delegate_; | 60 NavigationURLLoaderDelegate* delegate_; |
| 59 | 61 |
| 60 // |core_| is deleted on the IO thread in a subsequent task when the | 62 // |core_| is deleted on the IO thread in a subsequent task when the |
| 61 // NavigationURLLoaderImpl goes out of scope. | 63 // NavigationURLLoaderImpl goes out of scope. |
| 62 NavigationURLLoaderImplCore* core_; | 64 NavigationURLLoaderImplCore* core_; |
| 63 | 65 |
| 64 base::WeakPtrFactory<NavigationURLLoaderImpl> weak_factory_; | 66 base::WeakPtrFactory<NavigationURLLoaderImpl> weak_factory_; |
| 65 | 67 |
| 66 DISALLOW_COPY_AND_ASSIGN(NavigationURLLoaderImpl); | 68 DISALLOW_COPY_AND_ASSIGN(NavigationURLLoaderImpl); |
| 67 }; | 69 }; |
| 68 | 70 |
| 69 } // namespace content | 71 } // namespace content |
| 70 | 72 |
| 71 #endif // CONTENT_BROWSER_LOADER_NAVIGATION_URL_LOADER_IMPL_H_ | 73 #endif // CONTENT_BROWSER_LOADER_NAVIGATION_URL_LOADER_IMPL_H_ |
| OLD | NEW |