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

Side by Side Diff: chrome/browser/cocoa/scoped_authorizationref.h

Issue 437053: In-application Keystone ticket promotion (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years 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
« no previous file with comments | « chrome/browser/cocoa/keystone_promote_preflight.sh ('k') | chrome/chrome.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_COCOA_SCOPED_AUTHORIZATIONREF_H_
6 #define CHROME_BROWSER_COCOA_SCOPED_AUTHORIZATIONREF_H_
7
8 #include <Security/Authorization.h>
9
10 #include "base/basictypes.h"
11
12 // scoped_AuthorizationRef maintains ownership of an AuthorizationRef. It is
13 // patterned after the scoped_ptr interface.
14
15 class scoped_AuthorizationRef {
16 public:
17 explicit scoped_AuthorizationRef(AuthorizationRef authorization = NULL)
18 : authorization_(authorization) {
19 }
20
21 ~scoped_AuthorizationRef() {
22 if (authorization_) {
23 AuthorizationFree(authorization_, kAuthorizationFlagDestroyRights);
24 }
25 }
26
27 void reset(AuthorizationRef authorization = NULL) {
28 if (authorization_ != authorization) {
29 if (authorization_) {
30 AuthorizationFree(authorization_, kAuthorizationFlagDestroyRights);
31 }
32 authorization_ = authorization;
33 }
34 }
35
36 bool operator==(AuthorizationRef that) const {
37 return authorization_ == that;
38 }
39
40 bool operator!=(AuthorizationRef that) const {
41 return authorization_ != that;
42 }
43
44 operator AuthorizationRef() const {
45 return authorization_;
46 }
47
48 AuthorizationRef* operator&() {
49 return &authorization_;
50 }
51
52 AuthorizationRef get() const {
53 return authorization_;
54 }
55
56 void swap(scoped_AuthorizationRef& that) {
57 AuthorizationRef temp = that.authorization_;
58 that.authorization_ = authorization_;
59 authorization_ = temp;
60 }
61
62 // scoped_AuthorizationRef::release() is like scoped_ptr<>::release. It is
63 // NOT a wrapper for AuthorizationFree(). To force a
64 // scoped_AuthorizationRef object to call AuthorizationFree(), use
65 // scoped_AuthorizaitonRef::reset().
66 AuthorizationRef release() {
67 AuthorizationRef temp = authorization_;
68 authorization_ = NULL;
69 return temp;
70 }
71
72 private:
73 AuthorizationRef authorization_;
74
75 DISALLOW_COPY_AND_ASSIGN(scoped_AuthorizationRef);
76 };
77
78 #endif // CHROME_BROWSER_COCOA_SCOPED_AUTHORIZATIONREF_H_
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/keystone_promote_preflight.sh ('k') | chrome/chrome.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698