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

Side by Side Diff: dbus/file_descriptor.h

Issue 1407443002: Remove old C++03 move emulation code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: std::move and reflow Created 5 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
« no previous file with comments | « content/child/scoped_web_callbacks.h ('k') | dbus/file_descriptor.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 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 DBUS_FILE_DESCRIPTOR_H_ 5 #ifndef DBUS_FILE_DESCRIPTOR_H_
6 #define DBUS_FILE_DESCRIPTOR_H_ 6 #define DBUS_FILE_DESCRIPTOR_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/move.h" 10 #include "base/move.h"
(...skipping 16 matching lines...) Expand all
27 // the descriptor in fd will be closed if the PopUint32 fails. But 27 // the descriptor in fd will be closed if the PopUint32 fails. But
28 // writer.AppendFileDescriptor(dbus::FileDescriptor(1)); 28 // writer.AppendFileDescriptor(dbus::FileDescriptor(1));
29 // will not automatically close "1" because it is not owned. 29 // will not automatically close "1" because it is not owned.
30 // 30 //
31 // Descriptors must be validated before marshalling in a D-Bus message 31 // Descriptors must be validated before marshalling in a D-Bus message
32 // or using them after unmarshalling. We disallow descriptors to a 32 // or using them after unmarshalling. We disallow descriptors to a
33 // directory to reduce the security risks. Splitting out validation 33 // directory to reduce the security risks. Splitting out validation
34 // also allows the caller to do this work on the File thread to conform 34 // also allows the caller to do this work on the File thread to conform
35 // with i/o restrictions. 35 // with i/o restrictions.
36 class CHROME_DBUS_EXPORT FileDescriptor { 36 class CHROME_DBUS_EXPORT FileDescriptor {
37 MOVE_ONLY_TYPE_FOR_CPP_03(FileDescriptor, RValue); 37 MOVE_ONLY_TYPE_FOR_CPP_03(FileDescriptor);
38 38
39 public: 39 public:
40 // This provides a simple way to pass around file descriptors since they must 40 // This provides a simple way to pass around file descriptors since they must
41 // be closed on a thread that is allowed to perform I/O. 41 // be closed on a thread that is allowed to perform I/O.
42 struct Deleter { 42 struct Deleter {
43 void CHROME_DBUS_EXPORT operator()(FileDescriptor* fd); 43 void CHROME_DBUS_EXPORT operator()(FileDescriptor* fd);
44 }; 44 };
45 45
46 // Permits initialization without a value for passing to 46 // Permits initialization without a value for passing to
47 // dbus::MessageReader::PopFileDescriptor to fill in and from int values. 47 // dbus::MessageReader::PopFileDescriptor to fill in and from int values.
48 FileDescriptor() : value_(-1), owner_(false), valid_(false) {} 48 FileDescriptor() : value_(-1), owner_(false), valid_(false) {}
49 explicit FileDescriptor(int value) : value_(value), owner_(false), 49 explicit FileDescriptor(int value) : value_(value), owner_(false),
50 valid_(false) {} 50 valid_(false) {}
51 51
52 // Move constructor for C++03 move emulation of this type. 52 FileDescriptor(FileDescriptor&& other);
53 FileDescriptor(RValue other);
54 53
55 virtual ~FileDescriptor(); 54 virtual ~FileDescriptor();
56 55
57 // Move operator= for C++03 move emulation of this type. 56 FileDescriptor& operator=(FileDescriptor&& other);
58 FileDescriptor& operator=(RValue other);
59 57
60 // Retrieves value as an int without affecting ownership. 58 // Retrieves value as an int without affecting ownership.
61 int value() const; 59 int value() const;
62 60
63 // Retrieves whether or not the descriptor is ok to send/receive. 61 // Retrieves whether or not the descriptor is ok to send/receive.
64 int is_valid() const { return valid_; } 62 int is_valid() const { return valid_; }
65 63
66 // Sets the value and assign ownership. 64 // Sets the value and assign ownership.
67 void PutValue(int value) { 65 void PutValue(int value) {
68 value_ = value; 66 value_ = value;
(...skipping 16 matching lines...) Expand all
85 bool owner_; 83 bool owner_;
86 bool valid_; 84 bool valid_;
87 }; 85 };
88 86
89 using ScopedFileDescriptor = 87 using ScopedFileDescriptor =
90 scoped_ptr<FileDescriptor, FileDescriptor::Deleter>; 88 scoped_ptr<FileDescriptor, FileDescriptor::Deleter>;
91 89
92 } // namespace dbus 90 } // namespace dbus
93 91
94 #endif // DBUS_FILE_DESCRIPTOR_H_ 92 #endif // DBUS_FILE_DESCRIPTOR_H_
OLDNEW
« no previous file with comments | « content/child/scoped_web_callbacks.h ('k') | dbus/file_descriptor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698