summaryrefslogtreecommitdiffstats
path: root/chrome/browser/mac
diff options
context:
space:
mode:
authormark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-27 16:26:24 +0000
committermark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-27 16:26:24 +0000
commita6e349a6368c997c13512eff8e78304a6e2119b0 (patch)
treef5d6867c9c168cd69ab39c0385bc82b2622c17d7 /chrome/browser/mac
parentde29ac1c0b78c359fef7b642437d58a7f2f83478 (diff)
downloadchromium_src-a6e349a6368c997c13512eff8e78304a6e2119b0.zip
chromium_src-a6e349a6368c997c13512eff8e78304a6e2119b0.tar.gz
chromium_src-a6e349a6368c997c13512eff8e78304a6e2119b0.tar.bz2
Rename scoped_ioobject to ScopedIOObject and put it into its own file. Rename
scoped_AuthorizationRef to ScopedAuthorizationRef. BUG=cleanup TEST=none Review URL: http://codereview.chromium.org/7230022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@90588 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/mac')
-rw-r--r--chrome/browser/mac/authorization_util.mm2
-rw-r--r--chrome/browser/mac/install_from_dmg.mm72
-rw-r--r--chrome/browser/mac/keystone_glue.h2
-rw-r--r--chrome/browser/mac/keystone_glue.mm4
-rw-r--r--chrome/browser/mac/scoped_authorizationref.h18
-rw-r--r--chrome/browser/mac/scoped_ioobject.h69
6 files changed, 91 insertions, 76 deletions
diff --git a/chrome/browser/mac/authorization_util.mm b/chrome/browser/mac/authorization_util.mm
index 4db58b9..29b813d 100644
--- a/chrome/browser/mac/authorization_util.mm
+++ b/chrome/browser/mac/authorization_util.mm
@@ -21,7 +21,7 @@ namespace authorization_util {
AuthorizationRef AuthorizationCreateToRunAsRoot(CFStringRef prompt) {
// Create an empty AuthorizationRef.
- scoped_AuthorizationRef authorization;
+ ScopedAuthorizationRef authorization;
OSStatus status = AuthorizationCreate(NULL,
kAuthorizationEmptyEnvironment,
kAuthorizationFlagDefaults,
diff --git a/chrome/browser/mac/install_from_dmg.mm b/chrome/browser/mac/install_from_dmg.mm
index 85d1a7f..356171b 100644
--- a/chrome/browser/mac/install_from_dmg.mm
+++ b/chrome/browser/mac/install_from_dmg.mm
@@ -21,6 +21,7 @@
#include "base/mac/scoped_nsautorelease_pool.h"
#include "chrome/browser/mac/authorization_util.h"
#include "chrome/browser/mac/scoped_authorizationref.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"
@@ -40,61 +41,6 @@
namespace {
-// Just like ScopedCFTypeRef but for io_object_t and subclasses.
-template<typename IOT>
-class scoped_ioobject {
- public:
- typedef IOT element_type;
-
- explicit scoped_ioobject(IOT object = NULL)
- : object_(object) {
- }
-
- ~scoped_ioobject() {
- 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(scoped_ioobject& that) {
- IOT temp = that.object_;
- that.object_ = object_;
- object_ = temp;
- }
-
- IOT release() {
- IOT temp = object_;
- object_ = NULL;
- return temp;
- }
-
- private:
- IOT object_;
-
- DISALLOW_COPY_AND_ASSIGN(scoped_ioobject);
-};
-
// Returns true if |path| is located on a read-only filesystem of a disk
// image. Returns false if not, or in the event of an error.
bool IsPathOnReadOnlyDiskImage(const char path[]) {
@@ -140,16 +86,16 @@ bool IsPathOnReadOnlyDiskImage(const char path[]) {
<< ": kernel error " << kr;
return false;
}
- scoped_ioobject<io_iterator_t> iterator(iterator_ref);
+ ScopedIOObject<io_iterator_t> iterator(iterator_ref);
iterator_ref = NULL;
// There needs to be exactly one matching service.
- scoped_ioobject<io_service_t> filesystem_service(IOIteratorNext(iterator));
+ ScopedIOObject<io_service_t> filesystem_service(IOIteratorNext(iterator));
if (!filesystem_service) {
LOG(ERROR) << "IOIteratorNext " << bsd_device_name << ": no service";
return false;
}
- scoped_ioobject<io_service_t> unexpected_service(IOIteratorNext(iterator));
+ ScopedIOObject<io_service_t> unexpected_service(IOIteratorNext(iterator));
if (unexpected_service) {
LOG(ERROR) << "IOIteratorNext " << bsd_device_name << ": too many services";
return false;
@@ -183,9 +129,9 @@ bool IsPathOnReadOnlyDiskImage(const char path[]) {
// with the parent, iterating all the way up to the device tree's root. If
// any ancestor service matches the class used for disk images, the
// filesystem resides on a disk image.
- for(scoped_ioobject<io_service_t> ancestor_service(IOIteratorNext(iterator));
- ancestor_service;
- ancestor_service.reset(IOIteratorNext(iterator))) {
+ for (ScopedIOObject<io_service_t> ancestor_service(IOIteratorNext(iterator));
+ ancestor_service;
+ ancestor_service.reset(IOIteratorNext(iterator))) {
if (IOObjectConformsTo(ancestor_service, disk_image_class)) {
return true;
}
@@ -254,7 +200,7 @@ bool InstallFromDiskImage(AuthorizationRef authorization_arg,
NSString* installer_path,
NSString* source_path,
NSString* target_path) {
- scoped_AuthorizationRef authorization(authorization_arg);
+ ScopedAuthorizationRef authorization(authorization_arg);
authorization_arg = NULL;
int exit_status;
if (authorization) {
@@ -397,7 +343,7 @@ bool MaybeInstallFromDiskImage() {
return false;
}
- scoped_AuthorizationRef authorization(
+ ScopedAuthorizationRef authorization(
MaybeShowAuthorizationDialog(application_directory));
// authorization will be NULL if it's deemed unnecessary or if
// authentication fails. In either case, try to install without privilege
diff --git a/chrome/browser/mac/keystone_glue.h b/chrome/browser/mac/keystone_glue.h
index 58b5705..615b5e9 100644
--- a/chrome/browser/mac/keystone_glue.h
+++ b/chrome/browser/mac/keystone_glue.h
@@ -93,7 +93,7 @@ enum BrandFileType {
// The authorization object, when it needs to persist because it's being
// carried across threads.
- scoped_AuthorizationRef authorization_;
+ ScopedAuthorizationRef authorization_;
// YES if a synchronous promotion operation is in progress (promotion during
// installation).
diff --git a/chrome/browser/mac/keystone_glue.mm b/chrome/browser/mac/keystone_glue.mm
index 94bcfec..5f7b641 100644
--- a/chrome/browser/mac/keystone_glue.mm
+++ b/chrome/browser/mac/keystone_glue.mm
@@ -719,7 +719,7 @@ NSString* const kVersionKey = @"KSVersion";
NSString* prompt = l10n_util::GetNSStringFWithFixup(
IDS_PROMOTE_AUTHENTICATION_PROMPT,
l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
- scoped_AuthorizationRef authorization(
+ ScopedAuthorizationRef authorization(
authorization_util::AuthorizationCreateToRunAsRoot(
base::mac::NSToCFCast(prompt)));
if (!authorization.get()) {
@@ -731,7 +731,7 @@ NSString* const kVersionKey = @"KSVersion";
- (void)promoteTicketWithAuthorization:(AuthorizationRef)authorization_arg
synchronous:(BOOL)synchronous {
- scoped_AuthorizationRef authorization(authorization_arg);
+ ScopedAuthorizationRef authorization(authorization_arg);
authorization_arg = NULL;
if ([self asyncOperationPending]) {
diff --git a/chrome/browser/mac/scoped_authorizationref.h b/chrome/browser/mac/scoped_authorizationref.h
index 2a4c6fe..fbe0b9d 100644
--- a/chrome/browser/mac/scoped_authorizationref.h
+++ b/chrome/browser/mac/scoped_authorizationref.h
@@ -11,16 +11,16 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
-// scoped_AuthorizationRef maintains ownership of an AuthorizationRef. It is
+// ScopedAuthorizationRef maintains ownership of an AuthorizationRef. It is
// patterned after the scoped_ptr interface.
-class scoped_AuthorizationRef {
+class ScopedAuthorizationRef {
public:
- explicit scoped_AuthorizationRef(AuthorizationRef authorization = NULL)
+ explicit ScopedAuthorizationRef(AuthorizationRef authorization = NULL)
: authorization_(authorization) {
}
- ~scoped_AuthorizationRef() {
+ ~ScopedAuthorizationRef() {
if (authorization_) {
AuthorizationFree(authorization_, kAuthorizationFlagDestroyRights);
}
@@ -55,16 +55,16 @@ class scoped_AuthorizationRef {
return authorization_;
}
- void swap(scoped_AuthorizationRef& that) {
+ void swap(ScopedAuthorizationRef& that) {
AuthorizationRef temp = that.authorization_;
that.authorization_ = authorization_;
authorization_ = temp;
}
- // scoped_AuthorizationRef::release() is like scoped_ptr<>::release. It is
+ // ScopedAuthorizationRef::release() is like scoped_ptr<>::release. It is
// NOT a wrapper for AuthorizationFree(). To force a
- // scoped_AuthorizationRef object to call AuthorizationFree(), use
- // scoped_AuthorizaitonRef::reset().
+ // ScopedAuthorizationRef object to call AuthorizationFree(), use
+ // ScopedAuthorizationRef::reset().
AuthorizationRef release() WARN_UNUSED_RESULT {
AuthorizationRef temp = authorization_;
authorization_ = NULL;
@@ -74,7 +74,7 @@ class scoped_AuthorizationRef {
private:
AuthorizationRef authorization_;
- DISALLOW_COPY_AND_ASSIGN(scoped_AuthorizationRef);
+ DISALLOW_COPY_AND_ASSIGN(ScopedAuthorizationRef);
};
#endif // CHROME_BROWSER_MAC_SCOPED_AUTHORIZATIONREF_H_
diff --git a/chrome/browser/mac/scoped_ioobject.h b/chrome/browser/mac/scoped_ioobject.h
new file mode 100644
index 0000000..f8febd8
--- /dev/null
+++ b/chrome/browser/mac/scoped_ioobject.h
@@ -0,0 +1,69 @@
+// 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_