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

Side by Side Diff: headless/public/util/testing/generic_url_request_mocks.cc

Issue 2248283008: Fix recursion bug in blocking a fetch and add a test (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unintentional change Created 4 years, 4 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
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
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
OLDNEW
« no previous file with comments | « headless/public/util/testing/generic_url_request_mocks.h ('k') | headless/public/util/url_fetcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698