Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Unified Diff: headless/public/util/managed_dispatch_url_request_job.h

Issue 2260793002: Headless utility classes for making deterministic protocol handlers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing comments Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: headless/public/util/managed_dispatch_url_request_job.h
diff --git a/headless/public/util/managed_dispatch_url_request_job.h b/headless/public/util/managed_dispatch_url_request_job.h
new file mode 100644
index 0000000000000000000000000000000000000000..5e518b2edab44304e65d6640b52d5b1bea234c21
--- /dev/null
+++ b/headless/public/util/managed_dispatch_url_request_job.h
@@ -0,0 +1,59 @@
+// 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_MANAGED_DISPATCH_URL_REQUEST_JOB_H_
+#define HEADLESS_PUBLIC_UTIL_MANAGED_DISPATCH_URL_REQUEST_JOB_H_
+
+#include "base/macros.h"
+#include "net/base/net_errors.h"
+#include "net/url_request/url_request.h"
+#include "net/url_request/url_request_job.h"
+
+namespace headless {
+class URLRequestDispatcher;
+
+// A ManagedDispatchURLRequestJob exists to allow a URLRequestDispatcher control
+// the order in which a set of fetches complete. Typically this is done to make
+// fetching deterministic. NOTE URLRequestDispatcher sub classes use
+// OnHeadersComplete and OnStartError to drive the URLRequestJob.
+class ManagedDispatchURLRequestJob : public net::URLRequestJob {
+ public:
+ ManagedDispatchURLRequestJob(net::URLRequest* request,
+ net::NetworkDelegate* network_delegate,
+ URLRequestDispatcher* url_request_dispatcher);
+
+ ~ManagedDispatchURLRequestJob() override;
+
+ // Tells the net::URLRequestJob that the data has been fetched and is ready to
+ // be consumed.
+ virtual void OnHeadersComplete();
+
+ // Tells the net::URLRequestJob that the fetch failed.
+ virtual void OnStartError(net::Error error);
+
+ protected:
+ // net::URLRequestJob implementation:
+ void Kill() override;
+
+ // Tell the dispatcher the request failed.
+ virtual void DispatchStartError(net::Error error);
+
+ // Tell the dispatcher the data is ready for the net stack to consume.
+ virtual void DispatchHeadersComplete();
+
+ URLRequestDispatcher* url_request_dispatcher_; // Not owned.
+
+ private:
+ // Derived classes should not use NotifyHeadersComplete or NotifyStartError
+ // directly. Instead they should use DispatchHeadersComplete or
+ // DispatchStartError.
+ using URLRequestJob::NotifyHeadersComplete;
+ using URLRequestJob::NotifyStartError;
+
+ DISALLOW_COPY_AND_ASSIGN(ManagedDispatchURLRequestJob);
+};
+
+} // namespace headless
+
+#endif // HEADLESS_PUBLIC_UTIL_MANAGED_DISPATCH_URL_REQUEST_JOB_H_
« no previous file with comments | « headless/public/util/generic_url_request_job_test.cc ('k') | headless/public/util/managed_dispatch_url_request_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698