Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | |
|
mmenke
2016/04/08 15:19:12
--(c)
clamy
2016/04/08 16:03:17
Done.
| |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "content/test/test_navigation_url_loader_delegate.h" | |
| 6 | |
| 7 #include "content/public/browser/stream_handle.h" | |
| 8 #include "content/public/common/resource_response.h" | |
| 9 #include "testing/gtest/include/gtest/gtest.h" | |
| 10 | |
| 11 namespace content { | |
| 12 | |
| 13 TestNavigationURLLoaderDelegate::TestNavigationURLLoaderDelegate() | |
| 14 : net_error_(0), on_request_handled_counter_(0) {} | |
| 15 | |
| 16 TestNavigationURLLoaderDelegate::~TestNavigationURLLoaderDelegate() {} | |
| 17 | |
| 18 void TestNavigationURLLoaderDelegate::WaitForRequestRedirected() { | |
| 19 request_redirected_.reset(new base::RunLoop); | |
| 20 request_redirected_->Run(); | |
| 21 request_redirected_.reset(); | |
| 22 } | |
| 23 | |
| 24 void TestNavigationURLLoaderDelegate::WaitForResponseStarted() { | |
| 25 response_started_.reset(new base::RunLoop); | |
| 26 response_started_->Run(); | |
| 27 response_started_.reset(); | |
| 28 } | |
| 29 | |
| 30 void TestNavigationURLLoaderDelegate::WaitForRequestFailed() { | |
| 31 request_failed_.reset(new base::RunLoop); | |
| 32 request_failed_->Run(); | |
| 33 request_failed_.reset(); | |
| 34 } | |
| 35 | |
| 36 void TestNavigationURLLoaderDelegate::WaitForRequestStarted() { | |
| 37 request_started_.reset(new base::RunLoop); | |
| 38 request_started_->Run(); | |
| 39 request_started_.reset(); | |
| 40 } | |
| 41 | |
| 42 void TestNavigationURLLoaderDelegate::ReleaseBody() { | |
| 43 body_.reset(); | |
| 44 } | |
| 45 | |
| 46 void TestNavigationURLLoaderDelegate::OnRequestRedirected( | |
| 47 const net::RedirectInfo& redirect_info, | |
| 48 const scoped_refptr<ResourceResponse>& response) { | |
| 49 redirect_info_ = redirect_info; | |
| 50 redirect_response_ = response; | |
| 51 ASSERT_TRUE(request_redirected_); | |
| 52 request_redirected_->Quit(); | |
| 53 } | |
| 54 | |
| 55 void TestNavigationURLLoaderDelegate::OnResponseStarted( | |
| 56 const scoped_refptr<ResourceResponse>& response, | |
| 57 scoped_ptr<StreamHandle> body) { | |
| 58 response_ = response; | |
| 59 body_ = std::move(body); | |
| 60 ASSERT_TRUE(response_started_); | |
| 61 response_started_->Quit(); | |
| 62 } | |
| 63 | |
| 64 void TestNavigationURLLoaderDelegate::OnRequestFailed(bool in_cache, | |
| 65 int net_error) { | |
| 66 net_error_ = net_error; | |
| 67 if (request_failed_) | |
| 68 request_failed_->Quit(); | |
| 69 } | |
| 70 | |
| 71 void TestNavigationURLLoaderDelegate::OnRequestStarted( | |
| 72 base::TimeTicks timestamp) { | |
| 73 ASSERT_FALSE(timestamp.is_null()); | |
| 74 ++on_request_handled_counter_; | |
| 75 if (request_started_) | |
| 76 request_started_->Quit(); | |
| 77 } | |
| 78 | |
| 79 } // namespace content | |
| OLD | NEW |