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

Side by Side Diff: chrome/utility/chrome_content_utility_client.cc

Issue 683913009: Eliminate resource leaks from zip::ZipFiles and (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename file closer, add comment, reorder ZipReader/FileWrapper, change test iteration count Created 6 years, 1 month 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 #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/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 void ChromeContentUtilityClient::OnDecodeImage( 242 void ChromeContentUtilityClient::OnDecodeImage(
243 const std::vector<unsigned char>& encoded_data, bool shrink_to_fit) { 243 const std::vector<unsigned char>& encoded_data, bool shrink_to_fit) {
244 DecodeImageAndSend(encoded_data, shrink_to_fit); 244 DecodeImageAndSend(encoded_data, shrink_to_fit);
245 } 245 }
246 246
247 #if defined(OS_CHROMEOS) 247 #if defined(OS_CHROMEOS)
248 void ChromeContentUtilityClient::OnCreateZipFile( 248 void ChromeContentUtilityClient::OnCreateZipFile(
249 const base::FilePath& src_dir, 249 const base::FilePath& src_dir,
250 const std::vector<base::FilePath>& src_relative_paths, 250 const std::vector<base::FilePath>& src_relative_paths,
251 const base::FileDescriptor& dest_fd) { 251 const base::FileDescriptor& dest_fd) {
252 // dest_fd should be closed in the function. See ipc/ipc_message_util.h for
253 // details.
254 base::ScopedFD fd_closer(dest_fd.fd);
252 bool succeeded = true; 255 bool succeeded = true;
253 256
254 // Check sanity of source relative paths. Reject if path is absolute or 257 // Check sanity of source relative paths. Reject if path is absolute or
255 // contains any attempt to reference a parent directory ("../" tricks). 258 // contains any attempt to reference a parent directory ("../" tricks).
256 for (std::vector<base::FilePath>::const_iterator iter = 259 for (std::vector<base::FilePath>::const_iterator iter =
257 src_relative_paths.begin(); iter != src_relative_paths.end(); 260 src_relative_paths.begin(); iter != src_relative_paths.end();
258 ++iter) { 261 ++iter) {
259 if (iter->IsAbsolute() || iter->ReferencesParent()) { 262 if (iter->IsAbsolute() || iter->ReferencesParent()) {
260 succeeded = false; 263 succeeded = false;
261 break; 264 break;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 const std::string& mime_type, int64 total_size, bool get_attached_images) { 349 const std::string& mime_type, int64 total_size, bool get_attached_images) {
347 // Only one IPCDataSource may be created and added to the list of handlers. 350 // Only one IPCDataSource may be created and added to the list of handlers.
348 metadata::IPCDataSource* source = new metadata::IPCDataSource(total_size); 351 metadata::IPCDataSource* source = new metadata::IPCDataSource(total_size);
349 handlers_.push_back(source); 352 handlers_.push_back(source);
350 353
351 metadata::MediaMetadataParser* parser = new metadata::MediaMetadataParser( 354 metadata::MediaMetadataParser* parser = new metadata::MediaMetadataParser(
352 source, mime_type, get_attached_images); 355 source, mime_type, get_attached_images);
353 parser->Start(base::Bind(&FinishParseMediaMetadata, base::Owned(parser))); 356 parser->Start(base::Bind(&FinishParseMediaMetadata, base::Owned(parser)));
354 } 357 }
355 #endif 358 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698