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

Unified Diff: mojo/edk/platform/platform_handle.cc

Issue 1483823004: EDK: Move {platform_handle,scoped_platform_handle}.* to //mojo/edk/platform. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/edk/platform/platform_handle.h ('k') | mojo/edk/platform/scoped_platform_handle.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/platform/platform_handle.cc
diff --git a/mojo/edk/platform/platform_handle.cc b/mojo/edk/platform/platform_handle.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8a7c7be1b70d16eb3745e129f50932969dc49f3b
--- /dev/null
+++ b/mojo/edk/platform/platform_handle.cc
@@ -0,0 +1,30 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "mojo/edk/platform/platform_handle.h"
+
+#include <assert.h>
+#include <errno.h>
+#include <unistd.h>
+
+namespace mojo {
+namespace platform {
+
+void PlatformHandle::CloseIfNecessary() {
+ if (!is_valid())
+ return;
+
+ if (close(fd) != 0) {
+ // The possible errors are EBADF (which is very bad -- it indicates a bug in
+ // our code), EINTR, or EIO. On EINTR, don't retry |close()| (this is the
+ // correct behavior on Linux, and the only safe thing to do on Mac: see,
+ // e.g., http://crbug.com/269623). EIO is sad (it indicates potential data
+ // loss), but again there's nothing more to do.
+ assert(errno == EINTR || errno == EIO);
+ }
+ fd = -1;
+}
+
+} // namespace embedder
+} // namespace mojo
« no previous file with comments | « mojo/edk/platform/platform_handle.h ('k') | mojo/edk/platform/scoped_platform_handle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698