| 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 #include "headless/public/util/testing/generic_url_request_mocks.h" | 5 #include "headless/public/util/testing/generic_url_request_mocks.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 | 8 |
| 9 namespace net { | 9 namespace net { |
| 10 class URLRequestJob; | 10 class URLRequestJob; |
| 11 } // namespace net | 11 } // namespace net |
| 12 | 12 |
| 13 namespace headless { | 13 namespace headless { |
| 14 | 14 |
| 15 // MockGenericURLRequestJobDelegate | 15 // MockGenericURLRequestJobDelegate |
| 16 MockGenericURLRequestJobDelegate::MockGenericURLRequestJobDelegate() {} | 16 MockGenericURLRequestJobDelegate::MockGenericURLRequestJobDelegate() |
| 17 : should_block_(false) {} |
| 17 MockGenericURLRequestJobDelegate::~MockGenericURLRequestJobDelegate() {} | 18 MockGenericURLRequestJobDelegate::~MockGenericURLRequestJobDelegate() {} |
| 18 | 19 |
| 19 bool MockGenericURLRequestJobDelegate::BlockOrRewriteRequest( | 20 bool MockGenericURLRequestJobDelegate::BlockOrRewriteRequest( |
| 20 const GURL& url, | 21 const GURL& url, |
| 21 const std::string& referrer, | 22 const std::string& referrer, |
| 22 GenericURLRequestJob::RewriteCallback callback) { | 23 GenericURLRequestJob::RewriteCallback callback) { |
| 23 return false; | 24 if (should_block_) |
| 25 callback(GenericURLRequestJob::RewriteResult::kDeny, GURL()); |
| 26 return should_block_; |
| 24 } | 27 } |
| 25 | 28 |
| 26 const GenericURLRequestJob::HttpResponse* | 29 const GenericURLRequestJob::HttpResponse* |
| 27 MockGenericURLRequestJobDelegate::MaybeMatchResource( | 30 MockGenericURLRequestJobDelegate::MaybeMatchResource( |
| 28 const GURL& url, | 31 const GURL& url, |
| 29 const net::HttpRequestHeaders& request_headers) { | 32 const net::HttpRequestHeaders& request_headers) { |
| 30 return nullptr; | 33 return nullptr; |
| 31 } | 34 } |
| 32 | 35 |
| 33 void MockGenericURLRequestJobDelegate::OnResourceLoadComplete( | 36 void MockGenericURLRequestJobDelegate::OnResourceLoadComplete( |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 int bytes_read) {} | 161 int bytes_read) {} |
| 159 const std::string& MockURLRequestDelegate::response_data() const { | 162 const std::string& MockURLRequestDelegate::response_data() const { |
| 160 return response_data_; | 163 return response_data_; |
| 161 } | 164 } |
| 162 | 165 |
| 163 const net::IOBufferWithSize* MockURLRequestDelegate::metadata() const { | 166 const net::IOBufferWithSize* MockURLRequestDelegate::metadata() const { |
| 164 return nullptr; | 167 return nullptr; |
| 165 } | 168 } |
| 166 | 169 |
| 167 } // namespace headless | 170 } // namespace headless |
| OLD | NEW |