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