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

Unified Diff: content/browser/service_worker/service_worker_fetch_dispatcher.cc

Issue 2466843002: Cancel the request when URLLoader is gone (Closed)
Patch Set: fix Created 4 years, 1 month 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/browser/loader/url_loader_factory_impl_unittest.cc ('k') | content/common/url_loader.mojom » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/service_worker/service_worker_fetch_dispatcher.cc
diff --git a/content/browser/service_worker/service_worker_fetch_dispatcher.cc b/content/browser/service_worker/service_worker_fetch_dispatcher.cc
index 64aaa7c8cef5a6a879251a07a93c748ab0a5f163..d1ad9a6ae096483f74cb42a6707f26fa85fea8c5 100644
--- a/content/browser/service_worker/service_worker_fetch_dispatcher.cc
+++ b/content/browser/service_worker/service_worker_fetch_dispatcher.cc
@@ -46,13 +46,19 @@ class DelegatingURLLoader final : public mojom::URLLoader {
~DelegatingURLLoader() override {}
void FollowRedirect() override { loader_->FollowRedirect(); }
- void Cancel() override { loader_->Cancel(); }
mojom::URLLoaderPtr CreateInterfacePtrAndBind() {
- return binding_.CreateInterfacePtrAndBind();
+ auto p = binding_.CreateInterfacePtrAndBind();
+ // This unretained pointer is safe, because |binding_| is owned by |this|
+ // and the callback will never be called after |this| is destroyed.
+ binding_.set_connection_error_handler(
+ base::Bind(&DelegatingURLLoader::Cancel, base::Unretained(this)));
+ return p;
}
private:
+ void Cancel() { loader_ = nullptr; }
horo 2016/11/09 10:02:08 Please add comments. // Called when the mojom::
yhirano 2016/11/11 04:22:22 Done.
+
mojo::Binding<mojom::URLLoader> binding_;
mojom::URLLoaderAssociatedPtr loader_;
« no previous file with comments | « content/browser/loader/url_loader_factory_impl_unittest.cc ('k') | content/common/url_loader.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698