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

Side by Side Diff: headless/public/util/managed_dispatch_url_request_job.h

Issue 2248283008: Fix recursion bug in blocking a fetch and add a test (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unintentional change 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 unified diff | Download patch
OLDNEW
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_MANAGED_DISPATCH_URL_REQUEST_JOB_H_ 5 #ifndef HEADLESS_PUBLIC_UTIL_MANAGED_DISPATCH_URL_REQUEST_JOB_H_
6 #define HEADLESS_PUBLIC_UTIL_MANAGED_DISPATCH_URL_REQUEST_JOB_H_ 6 #define HEADLESS_PUBLIC_UTIL_MANAGED_DISPATCH_URL_REQUEST_JOB_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 #include "net/url_request/url_request.h" 10 #include "net/url_request/url_request.h"
11 #include "net/url_request/url_request_job.h" 11 #include "net/url_request/url_request_job.h"
12 12
13 namespace headless { 13 namespace headless {
14 class URLRequestDispatcher; 14 class URLRequestDispatcher;
15 15
16 // A ManagedDispatchURLRequestJob exists to allow a URLRequestDispatcher control 16 // A ManagedDispatchURLRequestJob exists to allow a URLRequestDispatcher control
17 // the order in which a set of fetches complete. Typically this is done to make 17 // the order in which a set of fetches complete. Typically this is done to make
18 // fetching deterministic. NOTE URLRequestDispatcher sub classes use 18 // fetching deterministic. NOTE URLRequestDispatcher sub classes use
19 // OnHeadersComplete and OnStartError to drive the URLRequestJob. 19 // OnHeadersComplete and OnStartError to drive the URLRequestJob.
20 class ManagedDispatchURLRequestJob : public net::URLRequestJob { 20 class ManagedDispatchURLRequestJob : public net::URLRequestJob {
21 public: 21 public:
22 ManagedDispatchURLRequestJob(net::URLRequest* request, 22 ManagedDispatchURLRequestJob(net::URLRequest* request,
23 net::NetworkDelegate* network_delegate, 23 net::NetworkDelegate* network_delegate,
24 URLRequestDispatcher* url_request_dispatcher); 24 URLRequestDispatcher* url_request_dispatcher);
25 25
26 ~ManagedDispatchURLRequestJob() override; 26 ~ManagedDispatchURLRequestJob() override;
27 27
28 // Tells the net::URLRequestJob that the data has been fetched and is ready to 28 // Tells the net::URLRequestJob that the data has been fetched and is ready to
29 // be consumed. 29 // be consumed.
30 // Virtual for FakeManagedDispatchURLRequestJob.
30 virtual void OnHeadersComplete(); 31 virtual void OnHeadersComplete();
31 32
32 // Tells the net::URLRequestJob that the fetch failed. 33 // Tells the net::URLRequestJob that the fetch failed.
34 // Virtual for FakeManagedDispatchURLRequestJob.
33 virtual void OnStartError(net::Error error); 35 virtual void OnStartError(net::Error error);
34 36
35 protected: 37 protected:
36 // net::URLRequestJob implementation: 38 // net::URLRequestJob implementation:
37 void Kill() override; 39 void Kill() override;
38 40
39 // Tell the dispatcher the request failed. 41 // Tell the dispatcher the request failed.
40 virtual void DispatchStartError(net::Error error); 42 virtual void DispatchStartError(net::Error error);
41 43
42 // Tell the dispatcher the data is ready for the net stack to consume. 44 // Tell the dispatcher the data is ready for the net stack to consume.
43 virtual void DispatchHeadersComplete(); 45 virtual void DispatchHeadersComplete();
44 46
45 URLRequestDispatcher* url_request_dispatcher_; // Not owned. 47 URLRequestDispatcher* url_request_dispatcher_; // Not owned.
46 48
47 private: 49 private:
48 // Derived classes should not use NotifyHeadersComplete or NotifyStartError 50 // Derived classes should not use NotifyHeadersComplete or NotifyStartError
49 // directly. Instead they should use DispatchHeadersComplete or 51 // directly. Instead they should use DispatchHeadersComplete or
50 // DispatchStartError. 52 // DispatchStartError.
51 using URLRequestJob::NotifyHeadersComplete; 53 using URLRequestJob::NotifyHeadersComplete;
52 using URLRequestJob::NotifyStartError; 54 using URLRequestJob::NotifyStartError;
53 55
54 DISALLOW_COPY_AND_ASSIGN(ManagedDispatchURLRequestJob); 56 DISALLOW_COPY_AND_ASSIGN(ManagedDispatchURLRequestJob);
55 }; 57 };
56 58
57 } // namespace headless 59 } // namespace headless
58 60
59 #endif // HEADLESS_PUBLIC_UTIL_MANAGED_DISPATCH_URL_REQUEST_JOB_H_ 61 #endif // HEADLESS_PUBLIC_UTIL_MANAGED_DISPATCH_URL_REQUEST_JOB_H_
OLDNEW
« no previous file with comments | « headless/public/util/generic_url_request_job_test.cc ('k') | headless/public/util/testing/generic_url_request_mocks.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698