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

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

Issue 9317074: Create an API around UtilityProcessHost and use that from chrome. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/first_run/first_run_win.cc ('k') | chrome/browser/image_decoder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "content/browser/utility_process_host.h" 13 #include "content/public/browser/browser_thread.h"
14 #include "content/public/browser/utility_process_host_client.h"
14 15
15 class SkBitmap; 16 class SkBitmap;
16 17
17 // Decodes an image in a sandboxed process. 18 // Decodes an image in a sandboxed process.
18 class ImageDecoder : public UtilityProcessHost::Client { 19 class ImageDecoder : public content::UtilityProcessHostClient {
19 public: 20 public:
20 class Delegate { 21 class Delegate {
21 public: 22 public:
22 // Called when image is decoded. 23 // Called when image is decoded.
23 // |decoder| is used to identify the image in case of decoding several 24 // |decoder| is used to identify the image in case of decoding several
24 // images simultaneously. 25 // images simultaneously.
25 virtual void OnImageDecoded(const ImageDecoder* decoder, 26 virtual void OnImageDecoded(const ImageDecoder* decoder,
26 const SkBitmap& decoded_image) = 0; 27 const SkBitmap& decoded_image) = 0;
27 28
28 // Called when decoding image failed. Delegate can do some cleanup in 29 // Called when decoding image failed. Delegate can do some cleanup in
29 // this handler. 30 // this handler.
30 virtual void OnDecodeImageFailed(const ImageDecoder* decoder) {} 31 virtual void OnDecodeImageFailed(const ImageDecoder* decoder) {}
31 32
32 protected: 33 protected:
33 virtual ~Delegate() {} 34 virtual ~Delegate() {}
34 }; 35 };
35 36
36 ImageDecoder(Delegate* delegate, 37 ImageDecoder(Delegate* delegate,
37 const std::string& image_data); 38 const std::string& image_data);
38 39
39 // Starts image decoding. 40 // Starts image decoding.
40 void Start(); 41 void Start();
41 42
42 private: 43 private:
43 // It's a reference counted object, so destructor is private. 44 // It's a reference counted object, so destructor is private.
44 virtual ~ImageDecoder(); 45 virtual ~ImageDecoder();
45 46
46 // Overidden from UtilityProcessHost::Client: 47 // Overidden from UtilityProcessHostClient:
47 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 48 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
48 49
49 // IPC message handlers. 50 // IPC message handlers.
50 void OnDecodeImageSucceeded(const SkBitmap& decoded_image); 51 void OnDecodeImageSucceeded(const SkBitmap& decoded_image);
51 void OnDecodeImageFailed(); 52 void OnDecodeImageFailed();
52 53
53 // Launches sandboxed process that will decode the image. 54 // Launches sandboxed process that will decode the image.
54 void DecodeImageInSandbox(const std::vector<unsigned char>& image_data); 55 void DecodeImageInSandbox(const std::vector<unsigned char>& image_data);
55 56
56 Delegate* delegate_; 57 Delegate* delegate_;
57 std::vector<unsigned char> image_data_; 58 std::vector<unsigned char> image_data_;
58 content::BrowserThread::ID target_thread_id_; 59 content::BrowserThread::ID target_thread_id_;
59 60
60 DISALLOW_COPY_AND_ASSIGN(ImageDecoder); 61 DISALLOW_COPY_AND_ASSIGN(ImageDecoder);
61 }; 62 };
62 63
63 #endif // CHROME_BROWSER_IMAGE_DECODER_H_ 64 #endif // CHROME_BROWSER_IMAGE_DECODER_H_
OLDNEW
« no previous file with comments | « chrome/browser/first_run/first_run_win.cc ('k') | chrome/browser/image_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698