| 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 "chrome/browser/bitmap_fetcher.h" | 5 #include "chrome/browser/bitmap_fetcher.h" |
| 6 | 6 |
| 7 #include "content/public/browser/browser_thread.h" | 7 #include "content/public/browser/browser_thread.h" |
| 8 #include "net/url_request/url_fetcher.h" | 8 #include "net/url_request/url_fetcher.h" |
| 9 #include "net/url_request/url_request_context_getter.h" | 9 #include "net/url_request/url_request_context_getter.h" |
| 10 #include "net/url_request/url_request_status.h" | 10 #include "net/url_request/url_request_status.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 void BitmapFetcher::OnURLFetchDownloadProgress(const net::URLFetcher* source, | 60 void BitmapFetcher::OnURLFetchDownloadProgress(const net::URLFetcher* source, |
| 61 int64 current, | 61 int64 current, |
| 62 int64 total) { | 62 int64 total) { |
| 63 // Do nothing here. | 63 // Do nothing here. |
| 64 } | 64 } |
| 65 | 65 |
| 66 // Methods inherited from ImageDecoder::Delegate. | 66 // Methods inherited from ImageDecoder::Delegate. |
| 67 | 67 |
| 68 void BitmapFetcher::OnImageDecoded(const ImageDecoder* decoder, | 68 void BitmapFetcher::OnImageDecoded(const ImageDecoder* decoder, |
| 69 const SkBitmap& decoded_image) { | 69 const SkBitmap& decoded_image) { |
| 70 // Make a copy of the bitmap which we pass back to the UI thread. | |
| 71 scoped_ptr<SkBitmap> bitmap(new SkBitmap()); | |
| 72 decoded_image.deepCopyTo(bitmap.get()); | |
| 73 | |
| 74 // Report success. | 70 // Report success. |
| 75 delegate_->OnFetchComplete(url_, bitmap.get()); | 71 delegate_->OnFetchComplete(url_, &decoded_image); |
| 76 } | 72 } |
| 77 | 73 |
| 78 void BitmapFetcher::OnDecodeImageFailed(const ImageDecoder* decoder) { | 74 void BitmapFetcher::OnDecodeImageFailed(const ImageDecoder* decoder) { |
| 79 ReportFailure(); | 75 ReportFailure(); |
| 80 } | 76 } |
| 81 | 77 |
| 82 void BitmapFetcher::ReportFailure() { | 78 void BitmapFetcher::ReportFailure() { |
| 83 delegate_->OnFetchComplete(url_, NULL); | 79 delegate_->OnFetchComplete(url_, NULL); |
| 84 } | 80 } |
| 85 | 81 |
| 86 } // namespace chrome | 82 } // namespace chrome |
| OLD | NEW |