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

Side by Side Diff: content/test/test_navigation_url_loader_delegate.h

Issue 1863573003: PlzNavigate: make all ResourceDispatcherHostTests pass (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed mmenke's comments Created 4 years, 8 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 2016 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_TEST_TEST_NAVIGATION_URL_LOADER_DELEGATE_H_
6 #define CONTENT_TEST_TEST_NAVIGATION_URL_LOADER_DELEGATE_H_
7
8 #include "base/macros.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/time/time.h"
12 #include "content/browser/loader/navigation_url_loader_delegate.h"
13 #include "net/url_request/redirect_info.h"
14
15 namespace base {
16 class RunLoop;
17 }
18
19 namespace content {
20
21 class StreamHandle;
22 struct ResourceResponse;
23
24 // PlzNavigate
25 // Test implementation of NavigationURLLoaderDelegate to monitor navigation
26 // progress in the network stack.
27 class TestNavigationURLLoaderDelegate : public NavigationURLLoaderDelegate {
28 public:
29 TestNavigationURLLoaderDelegate();
30 ~TestNavigationURLLoaderDelegate() override;
31
32 const net::RedirectInfo& redirect_info() const { return redirect_info_; }
33 ResourceResponse* redirect_response() const {
34 return redirect_response_.get();
35 }
36 ResourceResponse* response() const { return response_.get(); }
37 StreamHandle* body() const { return body_.get(); }
38 int net_error() const { return net_error_; }
39 int on_request_handled_counter() const { return on_request_handled_counter_; }
40
41 // Waits for various navigation events.
42 // Note: if the event already happened, this will fail.
nasko 2016/04/08 17:13:05 nit: "this will fail" < what is "this"? How would
clamy 2016/04/11 11:47:38 The functions will hang. Corrected the comment.
43 void WaitForRequestRedirected();
44 void WaitForResponseStarted();
45 void WaitForRequestFailed();
46 void WaitForRequestStarted();
47
48 void ReleaseBody();
49
50 // NavigationURLLoaderDelegate implementation.
51 void OnRequestRedirected(
52 const net::RedirectInfo& redirect_info,
53 const scoped_refptr<ResourceResponse>& response) override;
54 void OnResponseStarted(const scoped_refptr<ResourceResponse>& response,
55 scoped_ptr<StreamHandle> body) override;
56 void OnRequestFailed(bool in_cache, int net_error) override;
57 void OnRequestStarted(base::TimeTicks timestamp) override;
58
59 private:
60 net::RedirectInfo redirect_info_;
61 scoped_refptr<ResourceResponse> redirect_response_;
62 scoped_refptr<ResourceResponse> response_;
63 scoped_ptr<StreamHandle> body_;
64 int net_error_;
65 int on_request_handled_counter_;
66
67 scoped_ptr<base::RunLoop> request_redirected_;
68 scoped_ptr<base::RunLoop> response_started_;
69 scoped_ptr<base::RunLoop> request_failed_;
70 scoped_ptr<base::RunLoop> request_started_;
71
72 DISALLOW_COPY_AND_ASSIGN(TestNavigationURLLoaderDelegate);
73 };
74
75 } // namespace content
76
77 #endif // CONTENT_TEST_TEST_NAVIGATION_URL_LOADER_DELEGATE_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698