Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef DBUS_FILE_DESCRIPTOR_H_ | |
| 6 #define DBUS_FILE_DESCRIPTOR_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 namespace dbus { | |
| 10 | |
| 11 // FileDescriptor is a type used to encapsulate D-Bus file descriptors | |
| 12 // and to follow the RAII idiom appropiate for use with message operations | |
| 13 // where the descriptor might be easily leaked. Ownership is asserted | |
| 14 // only when PutValue is used. | |
| 15 class FileDescriptor { | |
| 16 public: | |
| 17 // Permit initialization without a value for passing to | |
|
satorux1
2012/03/28 00:32:43
nit: Permit -> Permits. Please also fix other plac
Sam Leffler
2012/03/28 17:28:09
Not sure which clause you're pointed me at but "Pe
satorux1
2012/03/28 17:30:16
These comments should be descriptive ("Opens the f
Sam Leffler
2012/03/28 19:25:27
Done.
| |
| 18 // dbus::MessageReader::PopFileDescriptor to fill in and from int values. | |
| 19 FileDescriptor() : value_(-1), owner_(true) {} | |
|
keybuk
2012/03/27 22:36:35
owner_(true) here means you'll close(-1) later; be
| |
| 20 explicit FileDescriptor(int value) : value_(value), owner_(false) {} | |
|
satorux1
2012/03/28 00:32:43
Could you remove the default constructor?
The st
Sam Leffler
2012/03/28 17:28:09
This cribs from dbus::ObjectPath. Removing it make
| |
| 21 | |
| 22 virtual ~FileDescriptor(); | |
| 23 | |
| 24 // Retrieve value as an int. | |
|
keybuk
2012/03/28 17:57:37
nit: Retrieves.
Also explain that this does not ta
| |
| 25 int value() const { return value_; } | |
| 26 | |
| 27 // Set the value and assign ownership. | |
|
keybuk
2012/03/28 17:57:37
nit: Sets
| |
| 28 void PutValue(int value) { | |
|
satorux1
2012/03/28 00:32:43
Put -> Set? Set is more common for this.
Sam Leffler
2012/03/28 17:28:09
Please get together w/ keybuk and decide which way
keybuk
2012/03/28 17:57:37
I asked Sam to change this from Set to Put because
| |
| 29 value_ = value; | |
| 30 owner_ = true; | |
| 31 } | |
| 32 | |
| 33 // Take the value and ownership. | |
| 34 int TakeValue(void) { | |
|
satorux1
2012/03/28 00:32:43
nit: (void) -> ()
Sam Leffler
2012/03/28 17:28:09
Done.
| |
| 35 owner_ = false; | |
| 36 return value_; | |
|
satorux1
2012/03/28 00:32:43
I guess owner_ is unnecessary. We can use -1 as no
Sam Leffler
2012/03/28 17:28:09
They are not equivalent. It is useful to preserve
keybuk
2012/03/28 17:57:37
It's probably worth explaining in the class commen
Sam Leffler
2012/03/28 19:25:27
Done.
| |
| 37 } | |
|
satorux1
2012/03/28 00:32:43
nit: we usually have a blank line here.
Sam Leffler
2012/03/28 17:28:09
Done.
| |
| 38 private: | |
| 39 int value_; | |
| 40 bool owner_; | |
| 41 | |
| 42 DISALLOW_COPY_AND_ASSIGN(FileDescriptor); | |
| 43 }; | |
| 44 | |
| 45 } // namespace dbus | |
| 46 | |
| 47 #endif // DBUS_FILE_DESCRIPTOR_H_ | |
| OLD | NEW |