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

Side by Side Diff: base/mac/scoped_cffiledescriptorref.h

Issue 11412101: Provide an iOS message pump for IO implementation. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Formatting nit Created 8 years, 1 month 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
OLDNEW
(Empty)
1 // Copyright 2012 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 BASE_MAC_SCOPED_CFFILEDESCRIPTORREF_H_
6 #define BASE_MAC_SCOPED_CFFILEDESCRIPTORREF_H_
7
8 #include <CoreFoundation/CoreFoundation.h>
9
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12
13 namespace base {
14 namespace mac {
15
16 // ScopedCFFileDescriptorRef is designed after ScopedCFTypeRef<>. On
17 // destruction, it will invalidate the file descriptor.
droger 2012/11/20 14:41:28 It seems that ScopedCFTypeRef has evolved since th
blundell 2012/11/20 20:38:54 After discussion, droger and I realized that Scope
18 class ScopedCFFileDescriptorRef {
Mark Mentovai 2012/11/20 14:47:58 Can this just extend ScopedCFTypeRef<CFFileDescrip
blundell 2012/11/20 20:38:54 See the above comment; I could have this extend Sc
19 public:
20 explicit ScopedCFFileDescriptorRef(CFFileDescriptorRef fdref = NULL)
21 : fdref_(fdref) {
22 }
23
24 ~ScopedCFFileDescriptorRef() {
25 if (fdref_) {
26 CFFileDescriptorInvalidate(fdref_);
27 CFRelease(fdref_);
28 }
29 }
30
31 void reset(CFFileDescriptorRef fdref = NULL) {
32 if (fdref_) {
droger 2012/11/20 14:41:28 Do we want to handle the case where fdref == fdref
blundell 2012/11/20 20:38:54 Done.
33 CFFileDescriptorInvalidate(fdref_);
34 CFRelease(fdref_);
35 }
36 fdref_ = fdref;
37 }
38
39 bool operator==(CFFileDescriptorRef that) const {
40 return fdref_ == that;
41 }
42
43 bool operator!=(CFFileDescriptorRef that) const {
44 return fdref_ != that;
45 }
46
47 operator CFFileDescriptorRef() const {
48 return fdref_;
49 }
50
51 CFFileDescriptorRef get() const {
52 return fdref_;
53 }
54
55 CFFileDescriptorRef release() WARN_UNUSED_RESULT {
56 CFFileDescriptorRef temp = fdref_;
57 fdref_ = NULL;
58 return temp;
59 }
60
61 private:
62 CFFileDescriptorRef fdref_;
63
64 DISALLOW_COPY_AND_ASSIGN(ScopedCFFileDescriptorRef);
65 };
66
67 } // namespace mac
68 } // namespace base
69
70 #endif // BASE_MAC_SCOPED_CFFILEDESCRIPTORREF_H_
OLDNEW
« no previous file with comments | « base/base.gyp ('k') | base/message_loop.h » ('j') | base/message_pump_io_ios.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698