| 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 "components/image_fetcher/core/image_fetcher_impl.h" | 5 #include "components/image_fetcher/core/image_fetcher_impl.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "net/base/load_flags.h" | 10 #include "net/base/load_flags.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 ImageRequest request; | 59 ImageRequest request; |
| 60 request.id = id; | 60 request.id = id; |
| 61 request.callbacks.push_back(callback); | 61 request.callbacks.push_back(callback); |
| 62 pending_net_requests_[image_url].swap(&request); | 62 pending_net_requests_[image_url].swap(&request); |
| 63 | 63 |
| 64 image_data_fetcher_->FetchImageData( | 64 image_data_fetcher_->FetchImageData( |
| 65 image_url, base::Bind(&ImageFetcherImpl::OnImageURLFetched, | 65 image_url, base::Bind(&ImageFetcherImpl::OnImageURLFetched, |
| 66 base::Unretained(this), image_url)); | 66 base::Unretained(this), image_url)); |
| 67 } else { | 67 } else { |
| 68 // Request in progress. Register as an interested callback. | 68 // Request in progress. Register as an interested callback. |
| 69 // TODO(treib,markusheintz): We're not guaranteed that the ID also matches. |
| 70 // We probably have to store them all. |
| 69 it->second.callbacks.push_back(callback); | 71 it->second.callbacks.push_back(callback); |
| 70 } | 72 } |
| 71 } | 73 } |
| 72 | 74 |
| 73 void ImageFetcherImpl::OnImageURLFetched(const GURL& image_url, | 75 void ImageFetcherImpl::OnImageURLFetched(const GURL& image_url, |
| 74 const std::string& image_data, | 76 const std::string& image_data, |
| 75 const RequestMetadata& metadata) { | 77 const RequestMetadata& metadata) { |
| 76 // Inform the ImageFetcherDelegate. | 78 // Inform the ImageFetcherDelegate. |
| 77 if (delegate_) { | 79 if (delegate_) { |
| 78 auto it = pending_net_requests_.find(image_url); | 80 auto it = pending_net_requests_.find(image_url); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 106 | 108 |
| 107 // Erase the completed ImageRequest. | 109 // Erase the completed ImageRequest. |
| 108 pending_net_requests_.erase(image_iter); | 110 pending_net_requests_.erase(image_iter); |
| 109 } | 111 } |
| 110 | 112 |
| 111 ImageDecoder* ImageFetcherImpl::GetImageDecoder() { | 113 ImageDecoder* ImageFetcherImpl::GetImageDecoder() { |
| 112 return image_decoder_.get(); | 114 return image_decoder_.get(); |
| 113 } | 115 } |
| 114 | 116 |
| 115 } // namespace image_fetcher | 117 } // namespace image_fetcher |
| OLD | NEW |