Chromium Code Reviews| Index: chromecast/crash/linux/crash_util.cc |
| diff --git a/chromecast/crash/linux/crash_util.cc b/chromecast/crash/linux/crash_util.cc |
| index e80b179c16e35d8f2292fd0892a9303563ac97a9..d9b434f4a9bc3da2744a5ae7b607cb0b54ecf38b 100644 |
| --- a/chromecast/crash/linux/crash_util.cc |
| +++ b/chromecast/crash/linux/crash_util.cc |
| @@ -4,10 +4,10 @@ |
| #include "chromecast/crash/linux/crash_util.h" |
| -#include <stdlib.h> |
| - |
| #include "base/bind.h" |
| #include "base/files/file_path.h" |
| +#include "base/files/file_util.h" |
| +#include "base/threading/thread_restrictions.h" |
| #include "base/time/time.h" |
| #include "chromecast/base/path_utils.h" |
| #include "chromecast/base/version.h" |
| @@ -37,12 +37,13 @@ bool CrashUtil::RequestUploadCrashDump( |
| const std::string& existing_minidump_path, |
| const std::string& crashed_process_name, |
| uint64_t crashed_process_start_time_ms) { |
| + // Remove IO restrictions from this thread. Chromium IO functions must be used |
| + // to access the file system and upload information to the crash server. |
| + base::ThreadRestrictions::SetIOAllowed(true); |
|
gfhuang
2015/07/16 18:39:59
this has to be scopedIO or you need to SetIOAllowe
gunsch
2015/07/16 18:49:18
ScopedAllowIO is banned.
I think this is only use
wzhong
2015/07/16 18:52:19
SetIOAllowed() returns previous state.
Save it an
wzhong
2015/07/16 18:52:19
SetIOAllowed() returns previous state.
Save it an
wzhong
2015/07/16 18:54:18
It should be used only around base::Move().
gfhuang
2015/07/16 18:57:01
We need to set it back to false then.
This could
gfhuang
2015/07/16 18:57:01
+1, the process could be alive after these (browse
slan
2015/07/16 20:06:24
I was not aware that this could be posted to the U
|
| + |
| LOG(INFO) << "Request to upload crash dump " << existing_minidump_path |
| << " for process " << crashed_process_name; |
| - // Note: Do not use Chromium IO methods in this function. When cast_shell |
| - // crashes, this function can be called by any thread, which may not allow IO. |
| - // Use stdlib system calls for IO instead. |
| uint64_t uptime_ms = GetCurrentTimeMs() - crashed_process_start_time_ms; |
| MinidumpParams params(crashed_process_name, |
| uptime_ms, |
| @@ -68,10 +69,11 @@ bool CrashUtil::RequestUploadCrashDump( |
| writer->set_non_blocking(false); |
| success = (0 == writer->Write()); // error already logged. |
| - // In case the file is still in $TEMP, remove it. |
| - if (remove(existing_minidump_path.c_str()) < 0 && errno != ENOENT) { |
| + // In case the file is still in $TEMP, remove it. Note that DeleteFile() will |
| + // return true if |existing_minidump_path| has already been moved. |
| + if (!base::DeleteFile(base::FilePath(existing_minidump_path), false)) { |
| LOG(ERROR) << "Unable to delete temp minidump file " |
| - << existing_minidump_path << ": " << strerror(errno); |
| + << existing_minidump_path; |
| success = false; |
| } |