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

Unified Diff: content/common/sandbox_mac_system_access_unittest.mm

Issue 202113004: Implement ScopedFD in terms of ScopedGeneric. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | « content/common/sandbox_mac.mm ('k') | ipc/ipc_channel_factory.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/sandbox_mac_system_access_unittest.mm
diff --git a/content/common/sandbox_mac_system_access_unittest.mm b/content/common/sandbox_mac_system_access_unittest.mm
index 09ac85485d24522009ee1001cdbee73a89103092..4ddc73a5988c0de0e012ae93a131ab1112890154 100644
--- a/content/common/sandbox_mac_system_access_unittest.mm
+++ b/content/common/sandbox_mac_system_access_unittest.mm
@@ -5,6 +5,7 @@
#import <Cocoa/Cocoa.h>
#include "base/file_util.h"
+#include "base/files/scoped_file.h"
#include "base/logging.h"
#include "base/strings/sys_string_conversions.h"
#include "content/common/sandbox_mac.h"
@@ -86,9 +87,8 @@ class MacSandboxedFileAccessTestCase : public MacSandboxTestCase {
REGISTER_SANDBOX_TEST_CASE(MacSandboxedFileAccessTestCase);
bool MacSandboxedFileAccessTestCase::SandboxedTest() {
- int fdes = open("/etc/passwd", O_RDONLY);
- file_util::ScopedFD file_closer(&fdes);
- return fdes == -1;
+ base::ScopedFD fdes(open("/etc/passwd", O_RDONLY));
+ return !fdes.is_valid();
}
TEST_F(MacSandboxTest, FileAccess) {
@@ -105,15 +105,14 @@ class MacSandboxedUrandomTestCase : public MacSandboxTestCase {
REGISTER_SANDBOX_TEST_CASE(MacSandboxedUrandomTestCase);
bool MacSandboxedUrandomTestCase::SandboxedTest() {
- int fdes = open("/dev/urandom", O_RDONLY);
- file_util::ScopedFD file_closer(&fdes);
+ base::ScopedFD fdes(open("/dev/urandom", O_RDONLY));
// Opening /dev/urandom succeeds under the sandbox.
- if (fdes == -1)
+ if (!fdes.is_valid())
return false;
char buf[16];
- int rc = read(fdes, buf, sizeof(buf));
+ int rc = read(fdes.get(), buf, sizeof(buf));
return rc == sizeof(buf);
}
« no previous file with comments | « content/common/sandbox_mac.mm ('k') | ipc/ipc_channel_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698