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

Side by Side Diff: dbus/file_descriptor.cc

Issue 307423005: Remove PlatformFile from dbus/file_descriptor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add comment Created 6 years, 6 months 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 | « no previous file | no next file » | 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 #include "base/files/file.h"
5 #include "base/logging.h" 6 #include "base/logging.h"
6 #include "base/platform_file.h"
7 #include "dbus/file_descriptor.h" 7 #include "dbus/file_descriptor.h"
8 8
9 namespace dbus { 9 namespace dbus {
10 10
11 FileDescriptor::~FileDescriptor() { 11 FileDescriptor::~FileDescriptor() {
12 if (owner_) 12 if (owner_)
13 base::ClosePlatformFile(value_); 13 base::File auto_closer(value_);
14 } 14 }
15 15
16 int FileDescriptor::value() const { 16 int FileDescriptor::value() const {
17 CHECK(valid_); 17 CHECK(valid_);
18 return value_; 18 return value_;
19 } 19 }
20 20
21 int FileDescriptor::TakeValue() { 21 int FileDescriptor::TakeValue() {
22 CHECK(valid_); // NB: check first so owner_ is unchanged if this triggers 22 CHECK(valid_); // NB: check first so owner_ is unchanged if this triggers
23 owner_ = false; 23 owner_ = false;
24 return value_; 24 return value_;
25 } 25 }
26 26
27 void FileDescriptor::CheckValidity() { 27 void FileDescriptor::CheckValidity() {
28 base::PlatformFileInfo info; 28 base::File file(value_);
29 bool ok = base::GetPlatformFileInfo(value_, &info); 29 base::File::Info info;
30 bool ok = file.GetInfo(&info);
31 file.TakePlatformFile(); // Prevent |value_| from being closed by |file|.
30 valid_ = (ok && !info.is_directory); 32 valid_ = (ok && !info.is_directory);
31 } 33 }
32 34
33 } // namespace dbus 35 } // namespace dbus
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698