| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 HEADLESS_PUBLIC_UTIL_URL_REQUEST_DISPATCHER_H_ | 5 #ifndef HEADLESS_PUBLIC_UTIL_URL_REQUEST_DISPATCHER_H_ |
| 6 #define HEADLESS_PUBLIC_UTIL_URL_REQUEST_DISPATCHER_H_ | 6 #define HEADLESS_PUBLIC_UTIL_URL_REQUEST_DISPATCHER_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
| 10 | 10 |
| 11 namespace headless { | 11 namespace headless { |
| 12 class ManagedDispatchURLRequestJob; | 12 class ManagedDispatchURLRequestJob; |
| 13 class NavigationRequest; |
| 13 | 14 |
| 14 // Interface to abstract and potentially reorder (for determinism) calls to | 15 // Interface to abstract and potentially reorder (for determinism) calls to |
| 15 // ManagedDispatchUrlRequestJob::OnHeadersComplete and | 16 // ManagedDispatchUrlRequestJob::OnHeadersComplete and |
| 16 // ManagedDispatchUrlRequestJob::NotifyStartError. | 17 // ManagedDispatchUrlRequestJob::NotifyStartError. |
| 17 class URLRequestDispatcher { | 18 class URLRequestDispatcher { |
| 18 public: | 19 public: |
| 19 URLRequestDispatcher() {} | 20 URLRequestDispatcher() {} |
| 20 virtual ~URLRequestDispatcher() {} | 21 virtual ~URLRequestDispatcher() {} |
| 21 | 22 |
| 22 // Tells us a URLRequestJob was created. Can be called from any thread. | 23 // Tells us a URLRequestJob was created. Can be called from any thread. |
| 23 virtual void JobCreated(ManagedDispatchURLRequestJob* job) = 0; | 24 virtual void JobCreated(ManagedDispatchURLRequestJob* job) = 0; |
| 24 | 25 |
| 25 // Tells us a URLRequestJob got killed. Can be called from any thread. | 26 // Tells us a URLRequestJob got killed. Can be called from any thread. |
| 26 virtual void JobKilled(ManagedDispatchURLRequestJob* job) = 0; | 27 virtual void JobKilled(ManagedDispatchURLRequestJob* job) = 0; |
| 27 | 28 |
| 28 // Tells us a URLRequestJob failed. Can be called from any thread. | 29 // Tells us a URLRequestJob failed. Can be called from any thread. |
| 29 virtual void JobFailed(ManagedDispatchURLRequestJob* job, | 30 virtual void JobFailed(ManagedDispatchURLRequestJob* job, |
| 30 net::Error error) = 0; | 31 net::Error error) = 0; |
| 31 | 32 |
| 32 // Tells us a URLRequestJob has fetched the data and is ready for the net | 33 // Tells us a URLRequestJob has fetched the data and is ready for the net |
| 33 // stack to consume it. Can be called from any thread. | 34 // stack to consume it. Can be called from any thread. |
| 34 virtual void DataReady(ManagedDispatchURLRequestJob* job) = 0; | 35 virtual void DataReady(ManagedDispatchURLRequestJob* job) = 0; |
| 35 | 36 |
| 36 // Tells us the job has finished. Can be called from any thread. | 37 // Tells us the job has finished. Can be called from any thread. |
| 37 virtual void JobDeleted(ManagedDispatchURLRequestJob* job) = 0; | 38 virtual void JobDeleted(ManagedDispatchURLRequestJob* job) = 0; |
| 38 | 39 |
| 40 // Tells us a navigation has been requested. Can be called from any thread. |
| 41 virtual void NavigationRequested( |
| 42 std::unique_ptr<NavigationRequest> navigation_request) = 0; |
| 43 |
| 39 private: | 44 private: |
| 40 DISALLOW_COPY_AND_ASSIGN(URLRequestDispatcher); | 45 DISALLOW_COPY_AND_ASSIGN(URLRequestDispatcher); |
| 41 }; | 46 }; |
| 42 | 47 |
| 43 } // namespace headless | 48 } // namespace headless |
| 44 | 49 |
| 45 #endif // HEADLESS_PUBLIC_UTIL_URL_REQUEST_DISPATCHER_H_ | 50 #endif // HEADLESS_PUBLIC_UTIL_URL_REQUEST_DISPATCHER_H_ |
| OLD | NEW |