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

Side by Side Diff: components/image_fetcher/content/image_decoder.h

Issue 2763103002: Move ImageDecoder to components/image_fetcher/content (Closed)
Patch Set: Rebased. Created 3 years, 8 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 COMPONENTS_IMAGE_FETCHER_CONTENT_IMAGE_DECODER_H_
6 #define CHROME_BROWSER_IMAGE_DECODER_H_ 6 #define COMPONENTS_IMAGE_FETCHER_CONTENT_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/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/sequence_checker.h" 14 #include "base/sequence_checker.h"
15 #include "base/sequenced_task_runner.h" 15 #include "base/sequenced_task_runner.h"
16 #include "base/synchronization/lock.h" 16 #include "base/synchronization/lock.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 // the image has been decoded. 64 // the image has been decoded.
65 const scoped_refptr<base::SequencedTaskRunner> task_runner_; 65 const scoped_refptr<base::SequencedTaskRunner> task_runner_;
66 66
67 base::SequenceChecker sequence_checker_; 67 base::SequenceChecker sequence_checker_;
68 }; 68 };
69 69
70 enum ImageCodec { 70 enum ImageCodec {
71 DEFAULT_CODEC = 0, // Uses WebKit image decoding (via WebImage). 71 DEFAULT_CODEC = 0, // Uses WebKit image decoding (via WebImage).
72 #if defined(OS_CHROMEOS) 72 #if defined(OS_CHROMEOS)
73 ROBUST_JPEG_CODEC, // Restrict decoding to robust jpeg codec. 73 ROBUST_JPEG_CODEC, // Restrict decoding to robust jpeg codec.
74 ROBUST_PNG_CODEC, // Restrict decoding to robust PNG codec. 74 ROBUST_PNG_CODEC, // Restrict decoding to robust PNG codec.
75 #endif // defined(OS_CHROMEOS) 75 #endif // defined(OS_CHROMEOS)
76 }; 76 };
77 77
78 static ImageDecoder* GetInstance(); 78 static ImageDecoder* GetInstance();
79 79
80 // Calls StartWithOptions() with ImageCodec::DEFAULT_CODEC and 80 // Calls StartWithOptions() with ImageCodec::DEFAULT_CODEC and
81 // shrink_to_fit = false. 81 // shrink_to_fit = false.
82 static void Start(ImageRequest* image_request, 82 static void Start(ImageRequest* image_request,
83 std::vector<uint8_t> image_data); 83 std::vector<uint8_t> image_data);
84 // Deprecated. Use std::vector<uint8_t> version to avoid an extra copy. 84 // Deprecated. Use std::vector<uint8_t> version to avoid an extra copy.
85 static void Start(ImageRequest* image_request, 85 static void Start(ImageRequest* image_request, const std::string& image_data);
86 const std::string& image_data);
87 86
88 // Starts asynchronous image decoding. Once finished, the callback will be 87 // Starts asynchronous image decoding. Once finished, the callback will be
89 // posted back to image_request's |task_runner_|. 88 // posted back to image_request's |task_runner_|.
90 // For images with multiple frames (e.g. ico files), a frame with a size as 89 // For images with multiple frames (e.g. ico files), a frame with a size as
91 // close as possible to |desired_image_frame_size| is chosen (tries to take 90 // close as possible to |desired_image_frame_size| is chosen (tries to take
92 // one in larger size if there's no precise match). Passing gfx::Size() as 91 // one in larger size if there's no precise match). Passing gfx::Size() as
93 // |desired_image_frame_size| is also supported and will result in chosing the 92 // |desired_image_frame_size| is also supported and will result in chosing the
94 // smallest available size. 93 // smallest available size.
95 static void StartWithOptions(ImageRequest* image_request, 94 static void StartWithOptions(ImageRequest* image_request,
96 std::vector<uint8_t> image_data, 95 std::vector<uint8_t> image_data,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 129
131 // Map of request id's to ImageRequests. 130 // Map of request id's to ImageRequests.
132 RequestMap image_request_id_map_; 131 RequestMap image_request_id_map_;
133 132
134 // Protects |image_request_id_map_| and |image_request_id_counter_|. 133 // Protects |image_request_id_map_| and |image_request_id_counter_|.
135 base::Lock map_lock_; 134 base::Lock map_lock_;
136 135
137 DISALLOW_COPY_AND_ASSIGN(ImageDecoder); 136 DISALLOW_COPY_AND_ASSIGN(ImageDecoder);
138 }; 137 };
139 138
140 #endif // CHROME_BROWSER_IMAGE_DECODER_H_ 139 #endif // COMPONENTS_IMAGE_FETCHER_CONTENT_IMAGE_DECODER_H_
OLDNEW
« no previous file with comments | « components/image_fetcher/content/DEPS ('k') | components/image_fetcher/content/image_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698