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

Unified Diff: headless/public/util/testing/generic_url_request_mocks.h

Issue 2815003003: Headless (breaking change): A better GenericURLRequestJob::Delegate API (Closed)
Patch Set: Changes for Sami Created 3 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 side-by-side diff with in-line comments
Download patch
Index: headless/public/util/testing/generic_url_request_mocks.h
diff --git a/headless/public/util/testing/generic_url_request_mocks.h b/headless/public/util/testing/generic_url_request_mocks.h
index 50c1d6054cccfb4628cc51de0c38d00cc0de61c4..218c3ce2e9382392396fc6ebc9f23f398f81e603 100644
--- a/headless/public/util/testing/generic_url_request_mocks.h
+++ b/headless/public/util/testing/generic_url_request_mocks.h
@@ -25,28 +25,25 @@ class HEADLESS_EXPORT MockGenericURLRequestJobDelegate
MockGenericURLRequestJobDelegate();
~MockGenericURLRequestJobDelegate() override;
- bool BlockOrRewriteRequest(
- const GURL& url,
- const std::string& devtools_id,
- const std::string& method,
- const std::string& referrer,
- GenericURLRequestJob::RewriteCallback callback) override;
-
- const GenericURLRequestJob::HttpResponse* MaybeMatchResource(
- const GURL& url,
- const std::string& devtools_id,
- const std::string& method,
- const net::HttpRequestHeaders& request_headers) override;
+ // GenericURLRequestJob::Delegate methods:
+ void OnPendingRequest(PendingRequest* pending_request) override;
+ void OnResourceLoadFailed(const Request* request, net::Error error) override;
+ void OnResourceLoadComplete(
+ const Request* request,
+ const GURL& final_url,
+ int http_response_code,
+ scoped_refptr<net::HttpResponseHeaders> response_headers,
+ const char* body,
+ size_t body_size) override;
- void OnResourceLoadComplete(const GURL& final_url,
- const std::string& devtools_id,
- const std::string& mime_type,
- int http_response_code) override;
+ using Policy = base::Callback<void(PendingRequest* pending_request)>;
- void SetShouldBlock(bool should_block) { should_block_ = should_block; }
+ void SetPolicy(Policy policy);
private:
- bool should_block_;
+ void ApplyPolicy(PendingRequest* pending_request);
+
+ Policy policy_;
scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
DISALLOW_COPY_AND_ASSIGN(MockGenericURLRequestJobDelegate);

Powered by Google App Engine
This is Rietveld 408576698