OLD | NEW |
1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_MAC_SCOPED_AUTHORIZATIONREF_H_ | 5 #ifndef BASE_MAC_SCOPED_AUTHORIZATIONREF_H_ |
6 #define CHROME_BROWSER_MAC_SCOPED_AUTHORIZATIONREF_H_ | 6 #define BASE_MAC_SCOPED_AUTHORIZATIONREF_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <Security/Authorization.h> | 9 #include <Security/Authorization.h> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 | 13 |
14 // ScopedAuthorizationRef maintains ownership of an AuthorizationRef. It is | 14 // ScopedAuthorizationRef maintains ownership of an AuthorizationRef. It is |
15 // patterned after the scoped_ptr interface. | 15 // patterned after the scoped_ptr interface. |
16 | 16 |
| 17 namespace base { |
| 18 namespace mac { |
| 19 |
17 class ScopedAuthorizationRef { | 20 class ScopedAuthorizationRef { |
18 public: | 21 public: |
19 explicit ScopedAuthorizationRef(AuthorizationRef authorization = NULL) | 22 explicit ScopedAuthorizationRef(AuthorizationRef authorization = NULL) |
20 : authorization_(authorization) { | 23 : authorization_(authorization) { |
21 } | 24 } |
22 | 25 |
23 ~ScopedAuthorizationRef() { | 26 ~ScopedAuthorizationRef() { |
24 if (authorization_) { | 27 if (authorization_) { |
25 AuthorizationFree(authorization_, kAuthorizationFlagDestroyRights); | 28 AuthorizationFree(authorization_, kAuthorizationFlagDestroyRights); |
26 } | 29 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 authorization_ = NULL; | 73 authorization_ = NULL; |
71 return temp; | 74 return temp; |
72 } | 75 } |
73 | 76 |
74 private: | 77 private: |
75 AuthorizationRef authorization_; | 78 AuthorizationRef authorization_; |
76 | 79 |
77 DISALLOW_COPY_AND_ASSIGN(ScopedAuthorizationRef); | 80 DISALLOW_COPY_AND_ASSIGN(ScopedAuthorizationRef); |
78 }; | 81 }; |
79 | 82 |
80 #endif // CHROME_BROWSER_MAC_SCOPED_AUTHORIZATIONREF_H_ | 83 } // namespace mac |
| 84 } // namespace base |
| 85 |
| 86 #endif // BASE_MAC_SCOPED_AUTHORIZATIONREF_H_ |
OLD | NEW |