| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/renderer/fetchers/multi_resolution_image_resource_fetcher.h" | 5 #include "content/renderer/fetchers/multi_resolution_image_resource_fetcher.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "content/child/image_decoder.h" | 9 #include "content/child/image_decoder.h" |
| 10 #include "content/public/renderer/resource_fetcher.h" | 10 #include "content/public/renderer/resource_fetcher.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 const Callback& callback) | 27 const Callback& callback) |
| 28 : callback_(callback), | 28 : callback_(callback), |
| 29 id_(id), | 29 id_(id), |
| 30 http_status_code_(0), | 30 http_status_code_(0), |
| 31 image_url_(image_url) { | 31 image_url_(image_url) { |
| 32 fetcher_.reset(ResourceFetcher::Create(image_url)); | 32 fetcher_.reset(ResourceFetcher::Create(image_url)); |
| 33 fetcher_->Start( | 33 fetcher_->Start( |
| 34 frame, | 34 frame, |
| 35 request_context, | 35 request_context, |
| 36 WebURLRequest::FrameTypeNone, | 36 WebURLRequest::FrameTypeNone, |
| 37 ResourceFetcher::PLATFORM_LOADER, |
| 37 base::Bind(&MultiResolutionImageResourceFetcher::OnURLFetchComplete, | 38 base::Bind(&MultiResolutionImageResourceFetcher::OnURLFetchComplete, |
| 38 base::Unretained(this))); | 39 base::Unretained(this))); |
| 39 } | 40 } |
| 40 | 41 |
| 41 MultiResolutionImageResourceFetcher::~MultiResolutionImageResourceFetcher() { | 42 MultiResolutionImageResourceFetcher::~MultiResolutionImageResourceFetcher() { |
| 42 } | 43 } |
| 43 | 44 |
| 44 void MultiResolutionImageResourceFetcher::OnURLFetchComplete( | 45 void MultiResolutionImageResourceFetcher::OnURLFetchComplete( |
| 45 const WebURLResponse& response, | 46 const WebURLResponse& response, |
| 46 const std::string& data) { | 47 const std::string& data) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 57 // If we get here, it means no image from server or couldn't decode the | 58 // If we get here, it means no image from server or couldn't decode the |
| 58 // response as an image. The delegate will see an empty vector. | 59 // response as an image. The delegate will see an empty vector. |
| 59 | 60 |
| 60 // Take a reference to the callback as running the callback may lead to our | 61 // Take a reference to the callback as running the callback may lead to our |
| 61 // destruction. | 62 // destruction. |
| 62 Callback callback = callback_; | 63 Callback callback = callback_; |
| 63 callback.Run(this, bitmaps); | 64 callback.Run(this, bitmaps); |
| 64 } | 65 } |
| 65 | 66 |
| 66 } // namespace content | 67 } // namespace content |
| OLD | NEW |