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

Unified Diff: dbus/file_descriptor.cc

Issue 10382021: dbus: revamp fd passing for i/o restrictions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments Created 8 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « dbus/file_descriptor.h ('k') | dbus/message.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dbus/file_descriptor.cc
diff --git a/dbus/file_descriptor.cc b/dbus/file_descriptor.cc
index fc240f552c634524fb619e52095305fd054c5807..91b089f657cf271e5240e05e24be4f1eca9b6452 100644
--- a/dbus/file_descriptor.cc
+++ b/dbus/file_descriptor.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/logging.h"
#include "base/platform_file.h"
#include "dbus/file_descriptor.h"
@@ -12,4 +13,21 @@ FileDescriptor::~FileDescriptor() {
base::ClosePlatformFile(value_);
}
+int FileDescriptor::value() const {
+ CHECK(valid_);
+ return value_;
+}
+
+int FileDescriptor::TakeValue() {
+ CHECK(valid_); // NB: check first so owner_ is unchanged if this triggers
+ owner_ = false;
+ return value_;
+}
+
+void FileDescriptor::CheckValidity() {
+ base::PlatformFileInfo info;
+ bool ok = base::GetPlatformFileInfo(value_, &info);
+ valid_ = (ok && !info.is_directory);
+}
+
} // namespace dbus
« no previous file with comments | « dbus/file_descriptor.h ('k') | dbus/message.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698