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 <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" |
14 #include "base/sequence_checker.h" | 15 #include "base/sequence_checker.h" |
15 #include "base/sequenced_task_runner.h" | 16 #include "base/sequenced_task_runner.h" |
16 #include "base/synchronization/lock.h" | 17 #include "base/synchronization/lock.h" |
17 #include "base/timer/timer.h" | 18 #include "base/timer/timer.h" |
18 #include "content/public/browser/utility_process_host.h" | 19 #include "content/public/browser/utility_process_host.h" |
19 #include "content/public/browser/utility_process_host_client.h" | 20 #include "content/public/browser/utility_process_host_client.h" |
20 | 21 |
21 class SkBitmap; | 22 class SkBitmap; |
22 | 23 |
| 24 namespace image_decoder { |
| 25 class ImageDecoder; |
| 26 } |
| 27 |
| 28 namespace mojo { |
| 29 template <typename T> class InterfacePtr; |
| 30 } |
| 31 |
23 // This is a helper class for decoding images safely in a utility process. To | 32 // This is a helper class for decoding images safely in a utility process. To |
24 // use this, call ImageDecoder::Start(...) or | 33 // use this, call ImageDecoder::Start(...) or |
25 // ImageDecoder::StartWithOptions(...) on any thread. | 34 // ImageDecoder::StartWithOptions(...) on any thread. |
26 // | 35 // |
27 // Internally, most of the work happens on the IO thread, and then | 36 // Internally, most of the work happens on the IO thread, and then |
28 // the callback (ImageRequest::OnImageDecoded or | 37 // the callback (ImageRequest::OnImageDecoded or |
29 // ImageRequest::OnDecodeImageFailed) is posted back to the |task_runner_| | 38 // ImageRequest::OnDecodeImageFailed) is posted back to the |task_runner_| |
30 // associated with the ImageRequest. | 39 // associated with the ImageRequest. |
31 // The Cancel() method runs on whichever thread called it. |map_lock_| is used | 40 // The Cancel() method runs on whichever thread called it. |map_lock_| is used |
32 // to protect the data that is accessed from multiple threads. | 41 // to protect the data that is accessed from multiple threads. |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 // Protects |image_request_id_map_| and |image_request_id_counter_|. | 154 // Protects |image_request_id_map_| and |image_request_id_counter_|. |
146 base::Lock map_lock_; | 155 base::Lock map_lock_; |
147 | 156 |
148 // The UtilityProcessHost requests are sent to. | 157 // The UtilityProcessHost requests are sent to. |
149 base::WeakPtr<content::UtilityProcessHost> utility_process_host_; | 158 base::WeakPtr<content::UtilityProcessHost> utility_process_host_; |
150 | 159 |
151 // Calls StopBatchMode() after |kBatchModeTimeoutSeconds| have elapsed, | 160 // Calls StopBatchMode() after |kBatchModeTimeoutSeconds| have elapsed, |
152 // unless a new decoding request resets the timer. | 161 // unless a new decoding request resets the timer. |
153 scoped_ptr<base::DelayTimer<ImageDecoder>> batch_mode_timer_; | 162 scoped_ptr<base::DelayTimer<ImageDecoder>> batch_mode_timer_; |
154 | 163 |
| 164 // Mojo service connection. Must always be bound/reset and used on the IO |
| 165 // thread. |
| 166 scoped_ptr<mojo::InterfacePtr<image_decoder::ImageDecoder>> decoder_; |
| 167 |
155 DISALLOW_COPY_AND_ASSIGN(ImageDecoder); | 168 DISALLOW_COPY_AND_ASSIGN(ImageDecoder); |
156 }; | 169 }; |
157 | 170 |
158 #endif // CHROME_BROWSER_IMAGE_DECODER_H_ | 171 #endif // CHROME_BROWSER_IMAGE_DECODER_H_ |
OLD | NEW |