Chromium Code Reviews| Index: content/test/test_navigation_url_loader_delegate.h |
| diff --git a/content/test/test_navigation_url_loader_delegate.h b/content/test/test_navigation_url_loader_delegate.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d89a422e2b40328e5a8ebe51426271543190e562 |
| --- /dev/null |
| +++ b/content/test/test_navigation_url_loader_delegate.h |
| @@ -0,0 +1,69 @@ |
| +// Copyright (c) 2016 The Chromium Authors. All rights reserved. |
|
mmenke
2016/04/08 15:19:13
new files shouldn't use the (c)
clamy
2016/04/08 16:03:17
Done.
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CONTENT_TEST_TEST_NAVIGATION_URL_LOADER_DELEGATE_H_ |
| +#define CONTENT_TEST_TEST_NAVIGATION_URL_LOADER_DELEGATE_H_ |
| + |
| +#include "base/memory/ref_counted.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/run_loop.h" |
|
mmenke
2016/04/08 15:19:13
Forward declare this, and move the include into th
clamy
2016/04/08 16:03:18
Done.
|
| +#include "base/time/time.h" |
| +#include "content/browser/loader/navigation_url_loader_delegate.h" |
| +#include "net/url_request/redirect_info.h" |
| + |
| +namespace content { |
| + |
| +class StreamHandle; |
| +struct ResourceResponse; |
| +// PlzNavigate |
|
mmenke
2016/04/08 15:19:12
nit: Add blank line before comment.
clamy
2016/04/08 16:03:18
Done.
|
| +// Test implementation of NavigationURLLoaderDelegate to monitor navigation |
| +// progress in the network stack. |
| +class TestNavigationURLLoaderDelegate : public NavigationURLLoaderDelegate { |
| + public: |
| + TestNavigationURLLoaderDelegate(); |
| + ~TestNavigationURLLoaderDelegate() override; |
| + |
| + const net::RedirectInfo& redirect_info() const { return redirect_info_; } |
| + ResourceResponse* redirect_response() const { |
| + return redirect_response_.get(); |
| + } |
| + ResourceResponse* response() const { return response_.get(); } |
| + StreamHandle* body() const { return body_.get(); } |
| + int net_error() const { return net_error_; } |
| + int on_request_handled_counter() const { return on_request_handled_counter_; } |
| + |
| + // Waits for various navigation events. |
|
mmenke
2016/04/08 15:19:13
Think it's important to note that the event we're
clamy
2016/04/08 16:03:17
Done.
|
| + void WaitForRequestRedirected(); |
| + void WaitForResponseStarted(); |
| + void WaitForRequestFailed(); |
| + void WaitForRequestStarted(); |
| + |
| + void ReleaseBody(); |
| + |
| + // NavigationURLLoaderDelegate implementation. |
| + void OnRequestRedirected( |
| + const net::RedirectInfo& redirect_info, |
| + const scoped_refptr<ResourceResponse>& response) override; |
| + void OnResponseStarted(const scoped_refptr<ResourceResponse>& response, |
| + scoped_ptr<StreamHandle> body) override; |
| + void OnRequestFailed(bool in_cache, int net_error) override; |
| + void OnRequestStarted(base::TimeTicks timestamp) override; |
| + |
| + private: |
| + net::RedirectInfo redirect_info_; |
| + scoped_refptr<ResourceResponse> redirect_response_; |
| + scoped_refptr<ResourceResponse> response_; |
| + scoped_ptr<StreamHandle> body_; |
|
mmenke
2016/04/08 15:19:13
"Streams" make me sad. None of the classes in con
clamy
2016/04/08 16:03:18
Acknowledged.
|
| + int net_error_; |
| + int on_request_handled_counter_; |
| + |
| + scoped_ptr<base::RunLoop> request_redirected_; |
| + scoped_ptr<base::RunLoop> response_started_; |
| + scoped_ptr<base::RunLoop> request_failed_; |
| + scoped_ptr<base::RunLoop> request_started_; |
|
mmenke
2016/04/08 15:19:13
DISALLOW_COPY_AND_ASSIGN, include base/macros.h
clamy
2016/04/08 16:03:18
Done.
|
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_TEST_TEST_NAVIGATION_URL_LOADER_DELEGATE_H |