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

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

Issue 2687083002: Headless: make URLRequestDispatcher aware of navigations (Closed)
Patch Set: Address nits Created 3 years, 10 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
« no previous file with comments | « headless/app/shell_navigation_request.cc ('k') | headless/public/util/deterministic_dispatcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: headless/public/util/deterministic_dispatcher.h
diff --git a/headless/public/util/deterministic_dispatcher.h b/headless/public/util/deterministic_dispatcher.h
index 0fea383b9cc42e747b8daa65ad1ca3bf0193c649..56c7c7e6390f3204a05377d93592fca673ca0c9e 100644
--- a/headless/public/util/deterministic_dispatcher.h
+++ b/headless/public/util/deterministic_dispatcher.h
@@ -20,8 +20,8 @@ namespace headless {
class ManagedDispatchURLRequestJob;
-// The purpose of this class is to queue up calls to OnHeadersComplete and
-// OnStartError and dispatch them in order of URLRequestJob creation. This
+// The purpose of this class is to queue up navigations and calls to
+// OnHeadersComplete / OnStartError and dispatch them in order of creation. This
// helps make renders deterministic at the cost of slower page loads.
class DeterministicDispatcher : public URLRequestDispatcher {
public:
@@ -36,17 +36,34 @@ class DeterministicDispatcher : public URLRequestDispatcher {
void JobFailed(ManagedDispatchURLRequestJob* job, net::Error error) override;
void DataReady(ManagedDispatchURLRequestJob* job) override;
void JobDeleted(ManagedDispatchURLRequestJob* job) override;
+ void NavigationRequested(
+ std::unique_ptr<NavigationRequest> navigation_request) override;
private:
+ void MaybeDispatchNavigationJobLocked();
void MaybeDispatchJobLocked();
void MaybeDispatchJobOnIOThreadTask();
+ void NavigationDoneTask();
scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner_;
// Protects all members below.
base::Lock lock_;
- std::deque<ManagedDispatchURLRequestJob*> pending_requests_;
+ // TODO(alexclarke): Use std::variant when c++17 is allowed in chromium.
+ struct Request {
+ Request();
+ explicit Request(ManagedDispatchURLRequestJob* url_request);
+ explicit Request(std::unique_ptr<NavigationRequest> navigation_request);
+ ~Request();
+
+ Request& operator=(Request&& other);
+
+ ManagedDispatchURLRequestJob* url_request; // NOT OWNED
+ std::unique_ptr<NavigationRequest> navigation_request;
+ };
+
+ std::deque<Request> pending_requests_;
using StatusMap = std::map<ManagedDispatchURLRequestJob*, net::Error>;
StatusMap ready_status_map_;
@@ -54,6 +71,7 @@ class DeterministicDispatcher : public URLRequestDispatcher {
// Whether or not a MaybeDispatchJobOnIoThreadTask has been posted on the
// |io_thread_task_runner_|
bool dispatch_pending_;
+ bool navigation_in_progress_;
base::WeakPtrFactory<DeterministicDispatcher> weak_ptr_factory_;
« no previous file with comments | « headless/app/shell_navigation_request.cc ('k') | headless/public/util/deterministic_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698