diff options
author | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-23 18:17:33 +0000 |
---|---|---|
committer | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-23 18:17:33 +0000 |
commit | 7a801dab5e105a7debcbc982e1b00a2e01e4e0e2 (patch) | |
tree | 521a31a82b106b66c6403d762b94a1fa8d833efc /chrome/browser/mac | |
parent | d3d6b274c90b4e0c6ddb2ddb2b7f011eeb917fb8 (diff) | |
download | chromium_src-7a801dab5e105a7debcbc982e1b00a2e01e4e0e2.zip chromium_src-7a801dab5e105a7debcbc982e1b00a2e01e4e0e2.tar.gz chromium_src-7a801dab5e105a7debcbc982e1b00a2e01e4e0e2.tar.bz2 |
Move ScopedIOObject to base/mac.
That way, it can be used in rlz.
BUG=none
TEST=none
TBR=mark (who said "LG" instead of "LGTM")
Review URL: https://chromiumcodereview.appspot.com/9839058
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@128533 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/mac')
-rw-r--r-- | chrome/browser/mac/install_from_dmg.mm | 19 | ||||
-rw-r--r-- | chrome/browser/mac/scoped_ioobject.h | 69 |
2 files changed, 11 insertions, 77 deletions
diff --git a/chrome/browser/mac/install_from_dmg.mm b/chrome/browser/mac/install_from_dmg.mm index dc6bca4..ab1241e 100644 --- a/chrome/browser/mac/install_from_dmg.mm +++ b/chrome/browser/mac/install_from_dmg.mm @@ -27,11 +27,11 @@ #import "base/mac/mac_util.h" #include "base/mac/scoped_authorizationref.h" #include "base/mac/scoped_cftyperef.h" +#include "base/mac/scoped_ioobject.h" #include "base/mac/scoped_nsautorelease_pool.h" #include "base/string_util.h" #include "base/sys_string_conversions.h" #include "chrome/browser/mac/dock.h" -#include "chrome/browser/mac/scoped_ioobject.h" #import "chrome/browser/mac/keystone_glue.h" #include "chrome/browser/mac/relauncher.h" #include "chrome/common/chrome_constants.h" @@ -84,7 +84,7 @@ io_service_t CopyHDIXDriveServiceForMedia(io_service_t media) { LOG(ERROR) << "IORegistryEntryCreateIterator: " << kr; return NULL; } - ScopedIOObject<io_iterator_t> iterator(iterator_ref); + base::mac::ScopedIOObject<io_iterator_t> iterator(iterator_ref); iterator_ref = NULL; // Look at each of the ancestor services, beginning with the parent, @@ -92,7 +92,8 @@ io_service_t CopyHDIXDriveServiceForMedia(io_service_t media) { // service matches the class used for disk images, the media resides on a // disk image, and the disk image file's path can be determined by examining // the image-path property. - for (ScopedIOObject<io_service_t> ancestor(IOIteratorNext(iterator)); + for (base::mac::ScopedIOObject<io_service_t> ancestor( + IOIteratorNext(iterator)); ancestor; ancestor.reset(IOIteratorNext(iterator))) { if (IOObjectConformsTo(ancestor, disk_image_class)) { @@ -113,7 +114,8 @@ bool MediaResidesOnDiskImage(io_service_t media, std::string* image_path) { image_path->clear(); } - ScopedIOObject<io_service_t> hdix_drive(CopyHDIXDriveServiceForMedia(media)); + base::mac::ScopedIOObject<io_service_t> hdix_drive( + CopyHDIXDriveServiceForMedia(media)); if (!hdix_drive) { return false; } @@ -210,16 +212,17 @@ bool IsPathOnReadOnlyDiskImage(const char path[], LOG(ERROR) << "IOServiceGetMatchingServices: " << kr; return false; } - ScopedIOObject<io_iterator_t> iterator(iterator_ref); + base::mac::ScopedIOObject<io_iterator_t> iterator(iterator_ref); iterator_ref = NULL; // There needs to be exactly one matching service. - ScopedIOObject<io_service_t> media(IOIteratorNext(iterator)); + base::mac::ScopedIOObject<io_service_t> media(IOIteratorNext(iterator)); if (!media) { LOG(ERROR) << "IOIteratorNext: no service"; return false; } - ScopedIOObject<io_service_t> unexpected_service(IOIteratorNext(iterator)); + base::mac::ScopedIOObject<io_service_t> unexpected_service( + IOIteratorNext(iterator)); if (unexpected_service) { LOG(ERROR) << "IOIteratorNext: too many services"; return false; @@ -626,7 +629,7 @@ void EjectAndTrashDiskImage(const std::string& dmg_bsd_device_name) { return; } - ScopedIOObject<io_service_t> media(DADiskCopyIOMedia(disk)); + base::mac::ScopedIOObject<io_service_t> media(DADiskCopyIOMedia(disk)); if (!media.get()) { LOG(ERROR) << "DADiskCopyIOMedia"; return; diff --git a/chrome/browser/mac/scoped_ioobject.h b/chrome/browser/mac/scoped_ioobject.h deleted file mode 100644 index f8febd8..0000000 --- a/chrome/browser/mac/scoped_ioobject.h +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_MAC_SCOPED_IOOBJECT_H_ -#define CHROME_BROWSER_MAC_SCOPED_IOOBJECT_H_ -#pragma once - -#include <IOKit/IOKitLib.h> - -#include "base/basictypes.h" -#include "base/compiler_specific.h" - -// Just like ScopedCFTypeRef but for io_object_t and subclasses. -template<typename IOT> -class ScopedIOObject { - public: - typedef IOT element_type; - - explicit ScopedIOObject(IOT object = NULL) - : object_(object) { - } - - ~ScopedIOObject() { - if (object_) - IOObjectRelease(object_); - } - - void reset(IOT object = NULL) { - if (object_) - IOObjectRelease(object_); - object_ = object; - } - - bool operator==(IOT that) const { - return object_ == that; - } - - bool operator!=(IOT that) const { - return object_ != that; - } - - operator IOT() const { - return object_; - } - - IOT get() const { - return object_; - } - - void swap(ScopedIOObject& that) { - IOT temp = that.object_; - that.object_ = object_; - object_ = temp; - } - - IOT release() WARN_UNUSED_RESULT { - IOT temp = object_; - object_ = NULL; - return temp; - } - - private: - IOT object_; - - DISALLOW_COPY_AND_ASSIGN(ScopedIOObject); -}; - -#endif // CHROME_BROWSER_MAC_SCOPED_IOOBJECT_H_ |