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