| 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 "chrome/browser/image_decoder.h" | 5 #include "chrome/browser/image_decoder.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/thread_task_runner_handle.h" | 8 #include "base/thread_task_runner_handle.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 // static, Leaky to allow access from any thread. | 25 // static, Leaky to allow access from any thread. |
| 26 base::LazyInstance<ImageDecoder>::Leaky g_decoder = LAZY_INSTANCE_INITIALIZER; | 26 base::LazyInstance<ImageDecoder>::Leaky g_decoder = LAZY_INSTANCE_INITIALIZER; |
| 27 | 27 |
| 28 // How long to wait after the last request has been received before ending | 28 // How long to wait after the last request has been received before ending |
| 29 // batch mode. | 29 // batch mode. |
| 30 const int kBatchModeTimeoutSeconds = 5; | 30 const int kBatchModeTimeoutSeconds = 5; |
| 31 | 31 |
| 32 void OnDecodeImageDone( | 32 void OnDecodeImageDone( |
| 33 base::Callback<void(int)> fail_callback, | 33 base::Callback<void(int)> fail_callback, |
| 34 base::Callback<void(const SkBitmap&, int)> success_callback, | 34 base::Callback<void(const SkBitmap&, int)> success_callback, |
| 35 int request_id, skia::mojom::BitmapPtr image) { | 35 int request_id, blink::mojom::BitmapPtr image) { |
| 36 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 36 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 37 if (image) { | 37 if (image) { |
| 38 SkBitmap bitmap = image.To<SkBitmap>(); | 38 SkBitmap bitmap = image.To<SkBitmap>(); |
| 39 if (!bitmap.empty()) { | 39 if (!bitmap.empty()) { |
| 40 success_callback.Run(bitmap, request_id); | 40 success_callback.Run(bitmap, request_id); |
| 41 return; | 41 return; |
| 42 } | 42 } |
| 43 } | 43 } |
| 44 fail_callback.Run(request_id); | 44 fail_callback.Run(request_id); |
| 45 } | 45 } |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 auto it = image_request_id_map_.find(request_id); | 300 auto it = image_request_id_map_.find(request_id); |
| 301 if (it == image_request_id_map_.end()) | 301 if (it == image_request_id_map_.end()) |
| 302 return; | 302 return; |
| 303 image_request = it->second; | 303 image_request = it->second; |
| 304 image_request_id_map_.erase(it); | 304 image_request_id_map_.erase(it); |
| 305 } | 305 } |
| 306 | 306 |
| 307 DCHECK(image_request->task_runner()->RunsTasksOnCurrentThread()); | 307 DCHECK(image_request->task_runner()->RunsTasksOnCurrentThread()); |
| 308 image_request->OnDecodeImageFailed(); | 308 image_request->OnDecodeImageFailed(); |
| 309 } | 309 } |
| OLD | NEW |