Chromium Code Reviews| 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_; |