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

Side by Side Diff: content/public/test/cancelling_navigation_throttle.h

Issue 2834543003: [subresource_filter] SB throttle can send multiple speculative requests. (Closed)
Patch Set: Add NoRedirectSpeculation metric Created 3 years, 7 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
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_PUBLIC_TEST_CANCELLING_NAVIGATION_THROTTLE_H_
6 #define CONTENT_PUBLIC_TEST_CANCELLING_NAVIGATION_THROTTLE_H_
7
8 #include "base/macros.h"
9 #include "base/memory/weak_ptr.h"
10 #include "content/public/browser/navigation_throttle.h"
11
12 namespace content {
13
14 class NavigationHandle;
15
16 // This class can be used to cancel navigations synchronously or asynchronously
17 // at a specific time in the NavigationThrottle lifecycle.
18 //
19 // Consider using it in conjunction with NavigationSimulator.
20 // TODO(clamy): Check if this could be used in unit tests exercising
21 // NavigationThrottle code.
22 class CancellingNavigationThrottle : public NavigationThrottle {
23 public:
24 enum CancelTime {
25 WILL_START_REQUEST,
26 WILL_REDIRECT_REQUEST,
27 WILL_PROCESS_RESPONSE,
28 NEVER,
29 };
30
31 enum ResultSynchrony {
32 SYNCHRONOUS,
33 ASYNCHRONOUS,
34 };
35
36 CancellingNavigationThrottle(NavigationHandle* handle,
37 CancelTime cancel_time,
38 ResultSynchrony sync);
39 ~CancellingNavigationThrottle() override;
40
41 // NavigationThrottle:
42 NavigationThrottle::ThrottleCheckResult WillStartRequest() override;
43 NavigationThrottle::ThrottleCheckResult WillRedirectRequest() override;
44 NavigationThrottle::ThrottleCheckResult WillProcessResponse() override;
45 const char* GetNameForLogging() override;
46
47 private:
48 NavigationThrottle::ThrottleCheckResult ProcessState(bool should_cancel);
49 void MaybeCancel(bool cancel);
50
51 private:
52 const CancelTime cancel_time_;
53 const ResultSynchrony sync_;
54
55 base::WeakPtrFactory<CancellingNavigationThrottle> weak_ptr_factory_;
56
57 DISALLOW_COPY_AND_ASSIGN(CancellingNavigationThrottle);
58 };
59
60 } // namespace content
61
62 #endif // CONTENT_PUBLIC_TEST_CANCELLING_NAVIGATION_THROTTLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698