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

Side by Side Diff: chrome/browser/mac/install_from_dmg.mm

Issue 9845017: Fix a few warnings that -Wnull-conversion of a future clang will complain about. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 9 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
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/browser/mac/install_from_dmg.h" 5 #include "chrome/browser/mac/install_from_dmg.h"
6 6
7 #include <ApplicationServices/ApplicationServices.h> 7 #include <ApplicationServices/ApplicationServices.h>
8 #import <AppKit/AppKit.h> 8 #import <AppKit/AppKit.h>
9 #include <CoreFoundation/CoreFoundation.h> 9 #include <CoreFoundation/CoreFoundation.h>
10 #include <CoreServices/CoreServices.h> 10 #include <CoreServices/CoreServices.h>
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 75
76 io_iterator_t iterator_ref; 76 io_iterator_t iterator_ref;
77 kern_return_t kr = 77 kern_return_t kr =
78 IORegistryEntryCreateIterator(media, 78 IORegistryEntryCreateIterator(media,
79 kIOServicePlane, 79 kIOServicePlane,
80 kIORegistryIterateRecursively | 80 kIORegistryIterateRecursively |
81 kIORegistryIterateParents, 81 kIORegistryIterateParents,
82 &iterator_ref); 82 &iterator_ref);
83 if (kr != KERN_SUCCESS) { 83 if (kr != KERN_SUCCESS) {
84 LOG(ERROR) << "IORegistryEntryCreateIterator: " << kr; 84 LOG(ERROR) << "IORegistryEntryCreateIterator: " << kr;
85 return NULL; 85 return 0;
Mark Mentovai 2012/03/27 21:09:59 IO_OBJECT_NULL in this file too.
86 } 86 }
87 base::mac::ScopedIOObject<io_iterator_t> iterator(iterator_ref); 87 base::mac::ScopedIOObject<io_iterator_t> iterator(iterator_ref);
88 iterator_ref = NULL; 88 iterator_ref = 0;
89 89
90 // Look at each of the ancestor services, beginning with the parent, 90 // Look at each of the ancestor services, beginning with the parent,
91 // iterating all the way up to the device tree's root. If any ancestor 91 // iterating all the way up to the device tree's root. If any ancestor
92 // service matches the class used for disk images, the media resides on a 92 // service matches the class used for disk images, the media resides on a
93 // disk image, and the disk image file's path can be determined by examining 93 // disk image, and the disk image file's path can be determined by examining
94 // the image-path property. 94 // the image-path property.
95 for (base::mac::ScopedIOObject<io_service_t> ancestor( 95 for (base::mac::ScopedIOObject<io_service_t> ancestor(
96 IOIteratorNext(iterator)); 96 IOIteratorNext(iterator));
97 ancestor; 97 ancestor;
98 ancestor.reset(IOIteratorNext(iterator))) { 98 ancestor.reset(IOIteratorNext(iterator))) {
99 if (IOObjectConformsTo(ancestor, disk_image_class)) { 99 if (IOObjectConformsTo(ancestor, disk_image_class)) {
100 return ancestor.release(); 100 return ancestor.release();
101 } 101 }
102 } 102 }
103 103
104 // The media does not reside on a disk image. 104 // The media does not reside on a disk image.
105 return NULL; 105 return 0;
106 } 106 }
107 107
108 // Given an io_service_t (expected to be of class IOMedia), determines whether 108 // Given an io_service_t (expected to be of class IOMedia), determines whether
109 // that service is on a disk image. If it is, returns true. If image_path is 109 // that service is on a disk image. If it is, returns true. If image_path is
110 // present, it will be set to the pathname of the disk image file, encoded in 110 // present, it will be set to the pathname of the disk image file, encoded in
111 // filesystem encoding. 111 // filesystem encoding.
112 bool MediaResidesOnDiskImage(io_service_t media, std::string* image_path) { 112 bool MediaResidesOnDiskImage(io_service_t media, std::string* image_path) {
113 if (image_path) { 113 if (image_path) {
114 image_path->clear(); 114 image_path->clear();
115 } 115 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 206
207 io_iterator_t iterator_ref; 207 io_iterator_t iterator_ref;
208 kern_return_t kr = IOServiceGetMatchingServices(master_port, 208 kern_return_t kr = IOServiceGetMatchingServices(master_port,
209 match_dict, 209 match_dict,
210 &iterator_ref); 210 &iterator_ref);
211 if (kr != KERN_SUCCESS) { 211 if (kr != KERN_SUCCESS) {
212 LOG(ERROR) << "IOServiceGetMatchingServices: " << kr; 212 LOG(ERROR) << "IOServiceGetMatchingServices: " << kr;
213 return false; 213 return false;
214 } 214 }
215 base::mac::ScopedIOObject<io_iterator_t> iterator(iterator_ref); 215 base::mac::ScopedIOObject<io_iterator_t> iterator(iterator_ref);
216 iterator_ref = NULL; 216 iterator_ref = 0;
217 217
218 // There needs to be exactly one matching service. 218 // There needs to be exactly one matching service.
219 base::mac::ScopedIOObject<io_service_t> media(IOIteratorNext(iterator)); 219 base::mac::ScopedIOObject<io_service_t> media(IOIteratorNext(iterator));
220 if (!media) { 220 if (!media) {
221 LOG(ERROR) << "IOIteratorNext: no service"; 221 LOG(ERROR) << "IOIteratorNext: no service";
222 return false; 222 return false;
223 } 223 }
224 base::mac::ScopedIOObject<io_service_t> unexpected_service( 224 base::mac::ScopedIOObject<io_service_t> unexpected_service(
225 IOIteratorNext(iterator)); 225 IOIteratorNext(iterator));
226 if (unexpected_service) { 226 if (unexpected_service) {
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 const UInt8* trash_path_u8 = reinterpret_cast<const UInt8*>( 679 const UInt8* trash_path_u8 = reinterpret_cast<const UInt8*>(
680 trash_path.value().c_str()); 680 trash_path.value().c_str());
681 status = FNNotifyByPath(trash_path_u8, 681 status = FNNotifyByPath(trash_path_u8,
682 kFNDirectoryModifiedMessage, 682 kFNDirectoryModifiedMessage,
683 kNilOptions); 683 kNilOptions);
684 if (status != noErr) { 684 if (status != noErr) {
685 OSSTATUS_LOG(ERROR, status) << "FNNotifyByPath"; 685 OSSTATUS_LOG(ERROR, status) << "FNNotifyByPath";
686 return; 686 return;
687 } 687 }
688 } 688 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698