Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2108)

Unified Diff: chrome/browser/bitmap_fetcher.cc

Issue 319623003: [AiS] ImageService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix signed/unsigned conflict. Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/bitmap_fetcher.cc
diff --git a/chrome/browser/bitmap_fetcher.cc b/chrome/browser/bitmap_fetcher.cc
deleted file mode 100644
index f04751a8356d592b58cc46565f325442fd6dad65..0000000000000000000000000000000000000000
--- a/chrome/browser/bitmap_fetcher.cc
+++ /dev/null
@@ -1,82 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/bitmap_fetcher.h"
-
-#include "content/public/browser/browser_thread.h"
-#include "net/url_request/url_fetcher.h"
-#include "net/url_request/url_request_context_getter.h"
-#include "net/url_request/url_request_status.h"
-
-namespace chrome {
-
-BitmapFetcher::BitmapFetcher(const GURL& url,
- BitmapFetcherDelegate* delegate)
- : url_(url),
- delegate_(delegate) {
-}
-
-BitmapFetcher::~BitmapFetcher() {}
-
-void BitmapFetcher::Start(net::URLRequestContextGetter* request_context,
- const std::string& referrer,
- net::URLRequest::ReferrerPolicy referrer_policy,
- int load_flags) {
- if (url_fetcher_ != NULL)
- return;
-
- url_fetcher_.reset(net::URLFetcher::Create(url_, net::URLFetcher::GET, this));
- url_fetcher_->SetRequestContext(request_context);
- url_fetcher_->SetReferrer(referrer);
- url_fetcher_->SetReferrerPolicy(referrer_policy);
- url_fetcher_->SetLoadFlags(load_flags);
- url_fetcher_->Start();
-}
-
-// Methods inherited from URLFetcherDelegate.
-
-void BitmapFetcher::OnURLFetchComplete(const net::URLFetcher* source) {
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
-
- if (source->GetStatus().status() != net::URLRequestStatus::SUCCESS) {
- ReportFailure();
- return;
- }
-
- std::string image_data;
- source->GetResponseAsString(&image_data);
- image_decoder_ =
- new ImageDecoder(this, image_data, ImageDecoder::DEFAULT_CODEC);
-
- // Call start to begin decoding. The ImageDecoder will call OnImageDecoded
- // with the data when it is done.
- scoped_refptr<base::MessageLoopProxy> task_runner =
- content::BrowserThread::GetMessageLoopProxyForThread(
- content::BrowserThread::UI);
- image_decoder_->Start(task_runner);
-}
-
-void BitmapFetcher::OnURLFetchDownloadProgress(const net::URLFetcher* source,
- int64 current,
- int64 total) {
- // Do nothing here.
-}
-
-// Methods inherited from ImageDecoder::Delegate.
-
-void BitmapFetcher::OnImageDecoded(const ImageDecoder* decoder,
- const SkBitmap& decoded_image) {
- // Report success.
- delegate_->OnFetchComplete(url_, &decoded_image);
-}
-
-void BitmapFetcher::OnDecodeImageFailed(const ImageDecoder* decoder) {
- ReportFailure();
-}
-
-void BitmapFetcher::ReportFailure() {
- delegate_->OnFetchComplete(url_, NULL);
-}
-
-} // namespace chrome

Powered by Google App Engine
This is Rietveld 408576698