Index: headless/public/util/url_request_dispatcher.h |
diff --git a/headless/public/util/url_request_dispatcher.h b/headless/public/util/url_request_dispatcher.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..1f34509a3a53ecbedd252eebe313680dd4871f4b |
--- /dev/null |
+++ b/headless/public/util/url_request_dispatcher.h |
@@ -0,0 +1,45 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef HEADLESS_PUBLIC_UTIL_URL_REQUEST_DISPATCHER_H_ |
+#define HEADLESS_PUBLIC_UTIL_URL_REQUEST_DISPATCHER_H_ |
+ |
+#include "base/macros.h" |
+#include "net/base/net_errors.h" |
+ |
+namespace headless { |
+class ManagedDispatchURLRequestJob; |
+ |
+// Interface to abstract and potentially reorder (for determinism) calls to |
+// ManagedDispatchUrlRequestJob::OnHeadersComplete and |
+// ManagedDispatchUrlRequestJob::NotifyStartError. |
+class URLRequestDispatcher { |
+ public: |
+ URLRequestDispatcher() {} |
+ virtual ~URLRequestDispatcher() {} |
+ |
+ // Tells us a URLRequestJob was created. Can be called from any thread. |
+ virtual void JobCreated(ManagedDispatchURLRequestJob* job) = 0; |
+ |
+ // Tells us a URLRequestJob got killed. Can be called from any thread. |
+ virtual void JobKilled(ManagedDispatchURLRequestJob* job) = 0; |
+ |
+ // Tells us a URLRequestJob failed. Can be called from any thread. |
+ virtual void JobFailed(ManagedDispatchURLRequestJob* job, |
+ net::Error error) = 0; |
+ |
+ // Tells us a URLRequestJob has fetched the data and is ready for the net |
+ // stack to consume it. Can be called from any thread. |
+ virtual void DataReady(ManagedDispatchURLRequestJob* job) = 0; |
+ |
+ // Tells us the job has finished. Can be called from any thread. |
+ virtual void JobDeleted(ManagedDispatchURLRequestJob* job) = 0; |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(URLRequestDispatcher); |
+}; |
+ |
+} // namespace headless |
+ |
+#endif // HEADLESS_PUBLIC_UTIL_URL_REQUEST_DISPATCHER_H_ |