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

Unified Diff: content/test/weburl_loader_mock.cc

Issue 1743783002: Use WeakPtr and do not use pointer equality in WebURLLoaderMockFactory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Loader_URLTestHelpers
Patch Set: Rebase. Created 4 years, 10 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
« no previous file with comments | « content/test/weburl_loader_mock.h ('k') | content/test/weburl_loader_mock_factory.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/test/weburl_loader_mock.cc
diff --git a/content/test/weburl_loader_mock.cc b/content/test/weburl_loader_mock.cc
index 62922e2a0a0b0d46bf30a4ffe0b6c7ecade5d589..424cb18fb688b63800383ed8fa9f38f2bca56c2e 100644
--- a/content/test/weburl_loader_mock.cc
+++ b/content/test/weburl_loader_mock.cc
@@ -46,7 +46,7 @@ void WebURLLoaderMock::ServeAsynchronousRequest(
// didReceiveResponse() and didReceiveData() might end up getting ::cancel()
// to be called which will make the ResourceLoader to delete |this|.
- base::WeakPtr<WebURLLoaderMock> self(weak_factory_.GetWeakPtr());
+ base::WeakPtr<WebURLLoaderMock> self(GetWeakPtr());
delegate->didReceiveResponse(client_, this, response);
if (!self)
@@ -84,7 +84,7 @@ blink::WebURLRequest WebURLLoaderMock::ServeRedirect(
request.skipServiceWorker(),
&newRequest);
- base::WeakPtr<WebURLLoaderMock> self(weak_factory_.GetWeakPtr());
+ base::WeakPtr<WebURLLoaderMock> self(GetWeakPtr());
client_->willFollowRedirect(this, newRequest, redirectResponse);
@@ -120,6 +120,7 @@ void WebURLLoaderMock::loadSynchronously(const blink::WebURLRequest& request,
void WebURLLoaderMock::loadAsynchronously(const blink::WebURLRequest& request,
blink::WebURLLoaderClient* client) {
+ CHECK(client);
if (factory_->IsMockedURL(request.url())) {
client_ = client;
factory_->LoadAsynchronouly(request, this);
@@ -154,3 +155,7 @@ void WebURLLoaderMock::setLoadingTaskRunner(blink::WebTaskRunner*) {
// In principle this is NOTIMPLEMENTED(), but if we put that here it floods
// the console during webkit unit tests, so we leave the function empty.
}
+
+base::WeakPtr<WebURLLoaderMock> WebURLLoaderMock::GetWeakPtr() {
+ return weak_factory_.GetWeakPtr();
+}
« no previous file with comments | « content/test/weburl_loader_mock.h ('k') | content/test/weburl_loader_mock_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698