OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chrome/browser/chromeos/system/automatic_reboot_manager.h" | 5 #include "chrome/browser/chromeos/system/automatic_reboot_manager.h" |
6 | 6 |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include <sys/stat.h> | 8 #include <sys/stat.h> |
9 #include <sys/types.h> | 9 #include <sys/types.h> |
10 | 10 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 base::TimeDelta ReadTimeDeltaFromFile(const base::FilePath& path) { | 58 base::TimeDelta ReadTimeDeltaFromFile(const base::FilePath& path) { |
59 base::ThreadRestrictions::AssertIOAllowed(); | 59 base::ThreadRestrictions::AssertIOAllowed(); |
60 base::ScopedFD fd( | 60 base::ScopedFD fd( |
61 HANDLE_EINTR(open(path.value().c_str(), O_RDONLY | O_NOFOLLOW))); | 61 HANDLE_EINTR(open(path.value().c_str(), O_RDONLY | O_NOFOLLOW))); |
62 if (!fd.is_valid()) | 62 if (!fd.is_valid()) |
63 return base::TimeDelta(); | 63 return base::TimeDelta(); |
64 | 64 |
65 std::string contents; | 65 std::string contents; |
66 char buffer[kOneKilobyte]; | 66 char buffer[kOneKilobyte]; |
67 ssize_t length; | 67 ssize_t length; |
68 while ((length = read(fd.get(), buffer, sizeof(buffer))) > 0) | 68 while ((length = HANDLE_EINTR(read(fd.get(), buffer, sizeof(buffer)))) > 0) |
69 contents.append(buffer, length); | 69 contents.append(buffer, length); |
70 | 70 |
71 double seconds; | 71 double seconds; |
72 if (!base::StringToDouble(contents.substr(0, contents.find(' ')), &seconds) || | 72 if (!base::StringToDouble(contents.substr(0, contents.find(' ')), &seconds) || |
73 seconds < 0.0) { | 73 seconds < 0.0) { |
74 return base::TimeDelta(); | 74 return base::TimeDelta(); |
75 } | 75 } |
76 return base::TimeDelta::FromMilliseconds(seconds * 1000.0); | 76 return base::TimeDelta::FromMilliseconds(seconds * 1000.0); |
77 } | 77 } |
78 | 78 |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 } | 410 } |
411 | 411 |
412 login_screen_idle_timer_.reset(); | 412 login_screen_idle_timer_.reset(); |
413 grace_start_timer_.reset(); | 413 grace_start_timer_.reset(); |
414 grace_end_timer_.reset(); | 414 grace_end_timer_.reset(); |
415 DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart(); | 415 DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart(); |
416 } | 416 } |
417 | 417 |
418 } // namespace system | 418 } // namespace system |
419 } // namespace chromeos | 419 } // namespace chromeos |
OLD | NEW |