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