| 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 #ifndef CHROME_BROWSER_IMAGE_DECODER_H_ | 5 #ifndef CHROME_BROWSER_IMAGE_DECODER_H_ |
| 6 #define CHROME_BROWSER_IMAGE_DECODER_H_ | 6 #define CHROME_BROWSER_IMAGE_DECODER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> |
| 9 #include <string> | 10 #include <string> |
| 10 #include <vector> | 11 #include <vector> |
| 11 | 12 |
| 12 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
| 13 #include "base/macros.h" | 14 #include "base/macros.h" |
| 14 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/sequence_checker.h" | 17 #include "base/sequence_checker.h" |
| 17 #include "base/sequenced_task_runner.h" | 18 #include "base/sequenced_task_runner.h" |
| 18 #include "base/synchronization/lock.h" | 19 #include "base/synchronization/lock.h" |
| 19 #include "base/timer/timer.h" | 20 #include "base/timer/timer.h" |
| 20 #include "build/build_config.h" | 21 #include "build/build_config.h" |
| 22 #include "chrome/common/image_decoder.mojom.h" |
| 21 #include "content/public/browser/utility_process_host.h" | 23 #include "content/public/browser/utility_process_host.h" |
| 22 #include "content/public/browser/utility_process_host_client.h" | 24 #include "content/public/browser/utility_process_host_client.h" |
| 23 | 25 |
| 24 class SkBitmap; | 26 class SkBitmap; |
| 25 | 27 |
| 26 // This is a helper class for decoding images safely in a utility process. To | 28 // This is a helper class for decoding images safely in a utility process. To |
| 27 // use this, call ImageDecoder::Start(...) or | 29 // use this, call ImageDecoder::Start(...) or |
| 28 // ImageDecoder::StartWithOptions(...) on any thread. | 30 // ImageDecoder::StartWithOptions(...) on any thread. |
| 29 // | 31 // |
| 30 // Internally, most of the work happens on the IO thread, and then | 32 // Internally, most of the work happens on the IO thread, and then |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 RequestMap image_request_id_map_; | 149 RequestMap image_request_id_map_; |
| 148 | 150 |
| 149 // Protects |image_request_id_map_| and |image_request_id_counter_|. | 151 // Protects |image_request_id_map_| and |image_request_id_counter_|. |
| 150 base::Lock map_lock_; | 152 base::Lock map_lock_; |
| 151 | 153 |
| 152 // The UtilityProcessHost requests are sent to. | 154 // The UtilityProcessHost requests are sent to. |
| 153 base::WeakPtr<content::UtilityProcessHost> utility_process_host_; | 155 base::WeakPtr<content::UtilityProcessHost> utility_process_host_; |
| 154 | 156 |
| 155 // Calls StopBatchMode() after |kBatchModeTimeoutSeconds| have elapsed, | 157 // Calls StopBatchMode() after |kBatchModeTimeoutSeconds| have elapsed, |
| 156 // unless a new decoding request resets the timer. | 158 // unless a new decoding request resets the timer. |
| 157 scoped_ptr<base::DelayTimer> batch_mode_timer_; | 159 std::unique_ptr<base::DelayTimer> batch_mode_timer_; |
| 160 |
| 161 // Mojo service connection. Must always be bound/reset and used on the IO |
| 162 // thread. |
| 163 mojom::ImageDecoderPtr decoder_; |
| 158 | 164 |
| 159 DISALLOW_COPY_AND_ASSIGN(ImageDecoder); | 165 DISALLOW_COPY_AND_ASSIGN(ImageDecoder); |
| 160 }; | 166 }; |
| 161 | 167 |
| 162 #endif // CHROME_BROWSER_IMAGE_DECODER_H_ | 168 #endif // CHROME_BROWSER_IMAGE_DECODER_H_ |
| OLD | NEW |