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_DETERMINISTIC_DISPATCHER_H_ | 5 #ifndef HEADLESS_PUBLIC_UTIL_DETERMINISTIC_DISPATCHER_H_ |
6 #define HEADLESS_PUBLIC_UTIL_DETERMINISTIC_DISPATCHER_H_ | 6 #define HEADLESS_PUBLIC_UTIL_DETERMINISTIC_DISPATCHER_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <map> | 9 #include <map> |
10 | 10 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
15 #include "base/synchronization/lock.h" | 15 #include "base/synchronization/lock.h" |
| 16 #include "headless/public/headless_export.h" |
16 #include "headless/public/util/url_request_dispatcher.h" | 17 #include "headless/public/util/url_request_dispatcher.h" |
17 #include "net/base/net_errors.h" | 18 #include "net/base/net_errors.h" |
18 | 19 |
19 namespace headless { | 20 namespace headless { |
20 | 21 |
21 class ManagedDispatchURLRequestJob; | 22 class ManagedDispatchURLRequestJob; |
22 | 23 |
23 // The purpose of this class is to queue up navigations and calls to | 24 // The purpose of this class is to queue up navigations and calls to |
24 // OnHeadersComplete / OnStartError and dispatch them in order of creation. This | 25 // OnHeadersComplete / OnStartError and dispatch them in order of creation. This |
25 // helps make renders deterministic at the cost of slower page loads. | 26 // helps make renders deterministic at the cost of slower page loads. |
26 class DeterministicDispatcher : public URLRequestDispatcher { | 27 class HEADLESS_EXPORT DeterministicDispatcher : public URLRequestDispatcher { |
27 public: | 28 public: |
28 explicit DeterministicDispatcher( | 29 explicit DeterministicDispatcher( |
29 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner); | 30 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner); |
30 | 31 |
31 ~DeterministicDispatcher() override; | 32 ~DeterministicDispatcher() override; |
32 | 33 |
33 // UrlRequestDispatcher implementation: | 34 // UrlRequestDispatcher implementation: |
34 void JobCreated(ManagedDispatchURLRequestJob* job) override; | 35 void JobCreated(ManagedDispatchURLRequestJob* job) override; |
35 void JobKilled(ManagedDispatchURLRequestJob* job) override; | 36 void JobKilled(ManagedDispatchURLRequestJob* job) override; |
36 void JobFailed(ManagedDispatchURLRequestJob* job, net::Error error) override; | 37 void JobFailed(ManagedDispatchURLRequestJob* job, net::Error error) override; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 bool navigation_in_progress_; | 75 bool navigation_in_progress_; |
75 | 76 |
76 base::WeakPtrFactory<DeterministicDispatcher> weak_ptr_factory_; | 77 base::WeakPtrFactory<DeterministicDispatcher> weak_ptr_factory_; |
77 | 78 |
78 DISALLOW_COPY_AND_ASSIGN(DeterministicDispatcher); | 79 DISALLOW_COPY_AND_ASSIGN(DeterministicDispatcher); |
79 }; | 80 }; |
80 | 81 |
81 } // namespace headless | 82 } // namespace headless |
82 | 83 |
83 #endif // HEADLESS_PUBLIC_UTIL_DETERMINISTIC_DISPATCHER_H_ | 84 #endif // HEADLESS_PUBLIC_UTIL_DETERMINISTIC_DISPATCHER_H_ |
OLD | NEW |