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

Unified Diff: chrome/browser/chromeos/system/automatic_reboot_manager.cc

Issue 197873014: Revert of 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
Index: chrome/browser/chromeos/system/automatic_reboot_manager.cc
diff --git a/chrome/browser/chromeos/system/automatic_reboot_manager.cc b/chrome/browser/chromeos/system/automatic_reboot_manager.cc
index 2ca1409783c062511593a47f937b0ccea3bf0c2a..1e00316530cd5a237536a8e183e7849a8a7d215b 100644
--- a/chrome/browser/chromeos/system/automatic_reboot_manager.cc
+++ b/chrome/browser/chromeos/system/automatic_reboot_manager.cc
@@ -18,7 +18,6 @@
#include "base/callback.h"
#include "base/file_util.h"
#include "base/files/file_path.h"
-#include "base/files/scoped_file.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/memory/ref_counted.h"
@@ -57,15 +56,15 @@
base::TimeDelta ReadTimeDeltaFromFile(const base::FilePath& path) {
base::ThreadRestrictions::AssertIOAllowed();
- base::ScopedFD fd(
- HANDLE_EINTR(open(path.value().c_str(), O_RDONLY | O_NOFOLLOW)));
- if (!fd.is_valid())
+ int fd = HANDLE_EINTR(open(path.value().c_str(), O_RDONLY | O_NOFOLLOW));
+ if (fd < 0)
return base::TimeDelta();
+ file_util::ScopedFD fd_closer(&fd);
std::string contents;
char buffer[kOneKilobyte];
ssize_t length;
- while ((length = read(fd.get(), buffer, sizeof(buffer))) > 0)
+ while ((length = read(fd, buffer, sizeof(buffer))) > 0)
contents.append(buffer, length);
double seconds;
@@ -109,16 +108,16 @@
if (uptime == kZeroTimeDelta)
return;
- base::ScopedFD fd(HANDLE_EINTR(
- open(update_reboot_needed_uptime_file.value().c_str(),
- O_CREAT | O_WRONLY | O_TRUNC | O_NOFOLLOW,
- 0666)));
- if (!fd.is_valid())
- return;
+ int fd = HANDLE_EINTR(open(update_reboot_needed_uptime_file.value().c_str(),
+ O_CREAT | O_WRONLY | O_TRUNC | O_NOFOLLOW,
+ 0666));
+ if (fd < 0)
+ return;
+ file_util::ScopedFD fd_closer(&fd);
std::string update_reboot_needed_uptime =
base::DoubleToString(uptime.InSecondsF());
- base::WriteFileDescriptor(fd.get(), update_reboot_needed_uptime.c_str(),
+ base::WriteFileDescriptor(fd, update_reboot_needed_uptime.c_str(),
update_reboot_needed_uptime.size());
}
« no previous file with comments | « base/test/launcher/test_launcher.cc ('k') | chrome/browser/extensions/api/messaging/native_message_process_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698