| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "mojo/services/network/url_loader_impl.h" | 5 #include "mojo/services/network/url_loader_impl.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 URLLoaderImpl::URLLoaderImpl(NetworkContext* context, | 261 URLLoaderImpl::URLLoaderImpl(NetworkContext* context, |
| 262 InterfaceRequest<URLLoader> request, | 262 InterfaceRequest<URLLoader> request, |
| 263 std::vector<URLLoaderInterceptorPtr> interceptors) | 263 std::vector<URLLoaderInterceptorPtr> interceptors) |
| 264 : context_(context), | 264 : context_(context), |
| 265 interceptors_(std::move(interceptors)), | 265 interceptors_(std::move(interceptors)), |
| 266 response_body_buffer_size_(0), | 266 response_body_buffer_size_(0), |
| 267 auto_follow_redirects_(true), | 267 auto_follow_redirects_(true), |
| 268 current_fetcher_id_(0), | 268 current_fetcher_id_(0), |
| 269 binding_(this, request.Pass()) { | 269 binding_(this, request.Pass()) { |
| 270 for (auto& interceptor : interceptors_) { | 270 for (auto& interceptor : interceptors_) { |
| 271 interceptor.set_connection_error_handler([this]() { OnConnectionError(); }); | 271 interceptor.set_connection_error_handler([this]() { delete this; }); |
| 272 } | 272 } |
| 273 interceptor_index_ = interceptors_.size() - 1; | 273 interceptor_index_ = interceptors_.size() - 1; |
| 274 binding_.set_connection_error_handler([this]() { OnConnectionError(); }); | 274 binding_.set_connection_error_handler([this]() { OnConnectionError(); }); |
| 275 context_->RegisterURLLoader(this); | 275 context_->RegisterURLLoader(this); |
| 276 } | 276 } |
| 277 | 277 |
| 278 URLLoaderImpl::~URLLoaderImpl() { | 278 URLLoaderImpl::~URLLoaderImpl() { |
| 279 context_->DeregisterURLLoader(this); | 279 context_->DeregisterURLLoader(this); |
| 280 } | 280 } |
| 281 | 281 |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 if ((*it)->id() == current_fetcher_id_) { | 576 if ((*it)->id() == current_fetcher_id_) { |
| 577 last_status_ = fetcher->QueryStatus(); | 577 last_status_ = fetcher->QueryStatus(); |
| 578 last_status_->is_loading = false; | 578 last_status_->is_loading = false; |
| 579 } | 579 } |
| 580 body_fetchers_.erase(it); | 580 body_fetchers_.erase(it); |
| 581 if (body_fetchers_.empty() and !binding_.is_bound()) | 581 if (body_fetchers_.empty() and !binding_.is_bound()) |
| 582 delete this; | 582 delete this; |
| 583 } | 583 } |
| 584 | 584 |
| 585 } // namespace mojo | 585 } // namespace mojo |
| OLD | NEW |