This source file includes following definitions.
- image_url_
- OnURLFetchComplete
#include "content/renderer/fetchers/multi_resolution_image_resource_fetcher.h"
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "content/child/image_decoder.h"
#include "content/public/renderer/resource_fetcher.h"
#include "third_party/WebKit/public/platform/WebURLResponse.h"
#include "third_party/WebKit/public/web/WebFrame.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/gfx/size.h"
using blink::WebFrame;
using blink::WebURLRequest;
using blink::WebURLResponse;
namespace content {
MultiResolutionImageResourceFetcher::MultiResolutionImageResourceFetcher(
const GURL& image_url,
WebFrame* frame,
int id,
WebURLRequest::TargetType target_type,
const Callback& callback)
: callback_(callback),
id_(id),
http_status_code_(0),
image_url_(image_url) {
fetcher_.reset(ResourceFetcher::Create(image_url));
fetcher_->Start(
frame, target_type,
base::Bind(&MultiResolutionImageResourceFetcher::OnURLFetchComplete,
base::Unretained(this)));
}
MultiResolutionImageResourceFetcher::~MultiResolutionImageResourceFetcher() {
}
void MultiResolutionImageResourceFetcher::OnURLFetchComplete(
const WebURLResponse& response,
const std::string& data) {
std::vector<SkBitmap> bitmaps;
if (!response.isNull()) {
http_status_code_ = response.httpStatusCode();
GURL url(response.url());
if (http_status_code_ == 200 || url.SchemeIsFile()) {
bitmaps = ImageDecoder::DecodeAll(
reinterpret_cast<const unsigned char*>(data.data()), data.size());
}
}
Callback callback = callback_;
callback.Run(this, bitmaps);
}
}