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 #include "chrome/utility/chrome_content_utility_client.h" | 5 #include "chrome/utility/chrome_content_utility_client.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 200 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
201 switches::kUtilityProcessEnableMDns)) { | 201 switches::kUtilityProcessEnableMDns)) { |
202 local_discovery::ServiceDiscoveryMessageHandler::PreSandboxStartup(); | 202 local_discovery::ServiceDiscoveryMessageHandler::PreSandboxStartup(); |
203 } | 203 } |
204 #endif // ENABLE_MDNS | 204 #endif // ENABLE_MDNS |
205 } | 205 } |
206 | 206 |
207 // static | 207 // static |
208 SkBitmap ChromeContentUtilityClient::DecodeImage( | 208 SkBitmap ChromeContentUtilityClient::DecodeImage( |
209 const std::vector<unsigned char>& encoded_data, bool shrink_to_fit) { | 209 const std::vector<unsigned char>& encoded_data, bool shrink_to_fit) { |
210 SkBitmap decoded_image = content::DecodeImage(&encoded_data[0], | 210 SkBitmap decoded_image; |
211 gfx::Size(), | 211 if (encoded_data.empty()) |
212 encoded_data.size()); | 212 return decoded_image; |
| 213 |
| 214 decoded_image = content::DecodeImage(&encoded_data[0], |
| 215 gfx::Size(), |
| 216 encoded_data.size()); |
213 | 217 |
214 int64_t struct_size = sizeof(ChromeUtilityHostMsg_DecodeImage_Succeeded); | 218 int64_t struct_size = sizeof(ChromeUtilityHostMsg_DecodeImage_Succeeded); |
215 int64_t image_size = decoded_image.computeSize64(); | 219 int64_t image_size = decoded_image.computeSize64(); |
216 int halves = 0; | 220 int halves = 0; |
217 while (struct_size + (image_size >> 2*halves) > max_ipc_message_size_) | 221 while (struct_size + (image_size >> 2*halves) > max_ipc_message_size_) |
218 halves++; | 222 halves++; |
219 if (halves) { | 223 if (halves) { |
220 if (shrink_to_fit) { | 224 if (shrink_to_fit) { |
221 // If decoded image is too large for IPC message, shrink it by halves. | 225 // If decoded image is too large for IPC message, shrink it by halves. |
222 // This prevents quality loss, and should never overshrink on displays | 226 // This prevents quality loss, and should never overshrink on displays |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 const std::string& mime_type, int64 total_size, bool get_attached_images) { | 403 const std::string& mime_type, int64 total_size, bool get_attached_images) { |
400 // Only one IPCDataSource may be created and added to the list of handlers. | 404 // Only one IPCDataSource may be created and added to the list of handlers. |
401 metadata::IPCDataSource* source = new metadata::IPCDataSource(total_size); | 405 metadata::IPCDataSource* source = new metadata::IPCDataSource(total_size); |
402 handlers_.push_back(source); | 406 handlers_.push_back(source); |
403 | 407 |
404 metadata::MediaMetadataParser* parser = new metadata::MediaMetadataParser( | 408 metadata::MediaMetadataParser* parser = new metadata::MediaMetadataParser( |
405 source, mime_type, get_attached_images); | 409 source, mime_type, get_attached_images); |
406 parser->Start(base::Bind(&FinishParseMediaMetadata, base::Owned(parser))); | 410 parser->Start(base::Bind(&FinishParseMediaMetadata, base::Owned(parser))); |
407 } | 411 } |
408 #endif | 412 #endif |
OLD | NEW |