Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(247)

Side by Side Diff: chrome/browser/image_decoder.h

Issue 1028543002: Turn the utility process image decoder into a Mojo service. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 // Protects |image_request_id_map_| and |image_request_id_counter_|. 152 // Protects |image_request_id_map_| and |image_request_id_counter_|.
144 base::Lock map_lock_; 153 base::Lock map_lock_;
145 154
146 // The UtilityProcessHost requests are sent to. 155 // The UtilityProcessHost requests are sent to.
147 base::WeakPtr<content::UtilityProcessHost> utility_process_host_; 156 base::WeakPtr<content::UtilityProcessHost> utility_process_host_;
148 157
149 // Calls StopBatchMode() after |kBatchModeTimeoutSeconds| have elapsed, 158 // Calls StopBatchMode() after |kBatchModeTimeoutSeconds| have elapsed,
150 // unless a new decoding request resets the timer. 159 // unless a new decoding request resets the timer.
151 scoped_ptr<base::DelayTimer<ImageDecoder>> batch_mode_timer_; 160 scoped_ptr<base::DelayTimer<ImageDecoder>> batch_mode_timer_;
152 161
162 // Mojo service connection. Must always be bound/reset and used on the IO
163 // thread.
164 scoped_ptr<mojo::InterfacePtr<image_decoder::ImageDecoder>> decoder_;
Sam McNally 2015/05/06 06:41:39 Why a scoped_ptr?
Anand Mistry (off Chromium) 2015/05/06 07:14:23 Let me paraphrase Dorothy: gyp, and gn, and deps!
165
153 DISALLOW_COPY_AND_ASSIGN(ImageDecoder); 166 DISALLOW_COPY_AND_ASSIGN(ImageDecoder);
154 }; 167 };
155 168
156 #endif // CHROME_BROWSER_IMAGE_DECODER_H_ 169 #endif // CHROME_BROWSER_IMAGE_DECODER_H_
OLDNEW
« no previous file with comments | « chrome/browser/DEPS ('k') | chrome/browser/image_decoder.cc » ('j') | chrome/utility/BUILD.gn » ('J')

Powered by Google App Engine
This is Rietveld 408576698