| 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/image_fetcher_impl.h" | 5 #include "components/image_fetcher/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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 image_url, | 56 image_url, |
| 57 base::Bind(&ImageFetcherImpl::OnImageURLFetched, | 57 base::Bind(&ImageFetcherImpl::OnImageURLFetched, |
| 58 base::Unretained(this), image_url)); | 58 base::Unretained(this), image_url)); |
| 59 } else { | 59 } else { |
| 60 // Request in progress. Register as an interested callback. | 60 // Request in progress. Register as an interested callback. |
| 61 it->second.callbacks.push_back(callback); | 61 it->second.callbacks.push_back(callback); |
| 62 } | 62 } |
| 63 } | 63 } |
| 64 | 64 |
| 65 void ImageFetcherImpl::OnImageURLFetched(const GURL& image_url, | 65 void ImageFetcherImpl::OnImageURLFetched(const GURL& image_url, |
| 66 const std::string& image_data) { | 66 const std::string& image_data, |
| 67 int http_response_code) { |
| 67 // Inform the ImageFetcherDelegate. | 68 // Inform the ImageFetcherDelegate. |
| 68 if (delegate_) { | 69 if (delegate_) { |
| 69 auto it = pending_net_requests_.find(image_url); | 70 auto it = pending_net_requests_.find(image_url); |
| 70 DCHECK(it != pending_net_requests_.end()); | 71 DCHECK(it != pending_net_requests_.end()); |
| 71 delegate_->OnImageDataFetched(it->second.id, image_data); | 72 delegate_->OnImageDataFetched(it->second.id, image_data); |
| 72 } | 73 } |
| 73 | 74 |
| 74 image_decoder_->DecodeImage( | 75 image_decoder_->DecodeImage( |
| 75 image_data, | 76 image_data, |
| 76 base::Bind(&ImageFetcherImpl::OnImageDecoded, | 77 base::Bind(&ImageFetcherImpl::OnImageDecoded, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 92 // Inform the ImageFetcherDelegate. | 93 // Inform the ImageFetcherDelegate. |
| 93 if (delegate_) { | 94 if (delegate_) { |
| 94 delegate_->OnImageFetched(request->id, image); | 95 delegate_->OnImageFetched(request->id, image); |
| 95 } | 96 } |
| 96 | 97 |
| 97 // Erase the completed ImageRequest. | 98 // Erase the completed ImageRequest. |
| 98 pending_net_requests_.erase(image_iter); | 99 pending_net_requests_.erase(image_iter); |
| 99 } | 100 } |
| 100 | 101 |
| 101 } // namespace image_fetcher | 102 } // namespace image_fetcher |
| OLD | NEW |