Differential D38165 Diff 118368 www/qt5-webengine/files/patch-src_3rdparty_chromium_base_process_internal__linux.cc
Changeset View
Changeset View
Standalone View
Standalone View
www/qt5-webengine/files/patch-src_3rdparty_chromium_base_process_internal__linux.cc
--- src/3rdparty/chromium/base/process/internal_linux.cc.orig 2020-11-07 01:22:36 UTC | --- src/3rdparty/chromium/base/process/internal_linux.cc.orig 2021-12-15 16:12:54 UTC | ||||
+++ src/3rdparty/chromium/base/process/internal_linux.cc | +++ src/3rdparty/chromium/base/process/internal_linux.cc | ||||
@@ -29,7 +29,11 @@ namespace internal { | @@ -30,7 +30,11 @@ const char kProcDir[] = "/proc"; | ||||
const char kProcDir[] = "/proc"; | const char kProcDir[] = "/proc"; | ||||
+#if defined(OS_BSD) | +#if defined(OS_BSD) | ||||
+const char kStatFile[] = "status"; | +const char kStatFile[] = "status"; | ||||
+#else | +#else | ||||
const char kStatFile[] = "stat"; | const char kStatFile[] = "stat"; | ||||
+#endif | +#endif | ||||
FilePath GetProcPidDir(pid_t pid) { | FilePath GetProcPidDir(pid_t pid) { | ||||
return FilePath(kProcDir).Append(NumberToString(pid)); | return FilePath(kProcDir).Append(NumberToString(pid)); | ||||
@@ -64,6 +68,7 @@ bool ReadProcFile(const FilePath& file, std::string* b | @@ -66,6 +70,7 @@ bool ReadProcFile(const FilePath& file, std::string* b | ||||
DLOG(WARNING) << "Failed to read " << file.MaybeAsASCII(); | DLOG(WARNING) << "Failed to read " << file.MaybeAsASCII(); | ||||
return false; | return false; | ||||
} | } | ||||
+ | + | ||||
return !buffer->empty(); | return !buffer->empty(); | ||||
} | } | ||||
@@ -79,6 +84,22 @@ bool ParseProcStats(const std::string& stats_data, | @@ -81,6 +86,22 @@ bool ParseProcStats(const std::string& stats_data, | ||||
if (stats_data.empty()) | if (stats_data.empty()) | ||||
return false; | return false; | ||||
+#if defined(OS_BSD) | +#if defined(OS_BSD) | ||||
+ proc_stats->clear(); | + proc_stats->clear(); | ||||
+ | + | ||||
+ std::vector<std::string> other_stats = SplitString( | + std::vector<std::string> other_stats = SplitString( | ||||
+ stats_data, " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | + stats_data, " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | ||||
+ | + | ||||
+ for (const auto& i : other_stats) { | + for (const auto& i : other_stats) { | ||||
+ auto pos = i.find(','); | + auto pos = i.find(','); | ||||
+ | + | ||||
+ if (pos == std::string::npos) { | + if (pos == std::string::npos) { | ||||
+ proc_stats->push_back(i); | + proc_stats->push_back(i); | ||||
+ } else { | + } else { | ||||
+ proc_stats->push_back(i.substr(0, pos)); | + proc_stats->push_back(i.substr(0, pos)); | ||||
+ } | + } | ||||
+ } | + } | ||||
+#else | +#else | ||||
// The stat file is formatted as: | // The stat file is formatted as: | ||||
// pid (process name) data1 data2 .... dataN | // pid (process name) data1 data2 .... dataN | ||||
// Look for the closing paren by scanning backwards, to avoid being fooled by | // Look for the closing paren by scanning backwards, to avoid being fooled by | ||||
@@ -108,6 +129,7 @@ bool ParseProcStats(const std::string& stats_data, | @@ -110,6 +131,7 @@ bool ParseProcStats(const std::string& stats_data, | ||||
base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | ||||
for (const auto& i : other_stats) | for (const auto& i : other_stats) | ||||
proc_stats->push_back(i); | proc_stats->push_back(i); | ||||
+#endif | +#endif | ||||
return true; | return true; | ||||
} | } | ||||
@@ -155,7 +177,11 @@ int64_t ReadProcStatsAndGetFieldAsInt64(pid_t pid, Pro | @@ -157,7 +179,11 @@ int64_t ReadProcSelfStatsAndGetFieldAsInt64(ProcStatsF | ||||
} | } | ||||
int64_t ReadProcSelfStatsAndGetFieldAsInt64(ProcStatsFields field_num) { | int64_t ReadProcSelfStatsAndGetFieldAsInt64(ProcStatsFields field_num) { | ||||
+#if defined(OS_BSD) | +#if defined(OS_BSD) | ||||
+ FilePath stat_file = FilePath(kProcDir).Append("curproc").Append(kStatFile); | + FilePath stat_file = FilePath(kProcDir).Append("curproc").Append(kStatFile); | ||||
+#else | +#else | ||||
FilePath stat_file = FilePath(kProcDir).Append("self").Append(kStatFile); | FilePath stat_file = FilePath(kProcDir).Append("self").Append(kStatFile); | ||||
+#endif | +#endif | ||||
return ReadStatFileAndGetFieldAsInt64(stat_file, field_num); | return ReadStatFileAndGetFieldAsInt64(stat_file, field_num); | ||||
} | } | ||||
@@ -171,6 +197,9 @@ size_t ReadProcStatsAndGetFieldAsSizeT(pid_t pid, | @@ -173,6 +199,9 @@ Time GetBootTime() { | ||||
} | } | ||||
Time GetBootTime() { | Time GetBootTime() { | ||||
+#if defined(OS_BSD) | +#if defined(OS_BSD) | ||||
+ return Time(); | + return Time(); | ||||
+#else | +#else | ||||
FilePath path("/proc/stat"); | FilePath path("/proc/stat"); | ||||
std::string contents; | std::string contents; | ||||
if (!ReadProcFile(path, &contents)) | if (!ReadProcFile(path, &contents)) | ||||
@@ -184,9 +213,13 @@ Time GetBootTime() { | @@ -186,9 +215,13 @@ Time GetBootTime() { | ||||
if (!StringToInt(btime_it->second, &btime)) | if (!StringToInt(btime_it->second, &btime)) | ||||
return Time(); | return Time(); | ||||
return Time::FromTimeT(btime); | return Time::FromTimeT(btime); | ||||
+#endif | +#endif | ||||
} | } | ||||
TimeDelta GetUserCpuTimeSinceBoot() { | TimeDelta GetUserCpuTimeSinceBoot() { | ||||
+#if defined(OS_BSD) | +#if defined(OS_BSD) | ||||
+ return TimeDelta(); | + return TimeDelta(); | ||||
+#else | +#else | ||||
FilePath path("/proc/stat"); | FilePath path("/proc/stat"); | ||||
std::string contents; | std::string contents; | ||||
if (!ReadProcFile(path, &contents)) | if (!ReadProcFile(path, &contents)) | ||||
@@ -210,6 +243,7 @@ TimeDelta GetUserCpuTimeSinceBoot() { | @@ -212,6 +245,7 @@ TimeDelta GetUserCpuTimeSinceBoot() { | ||||
return TimeDelta(); | return TimeDelta(); | ||||
return ClockTicksToTimeDelta(user + nice); | return ClockTicksToTimeDelta(user + nice); | ||||
+#endif | +#endif | ||||
} | } | ||||
TimeDelta ClockTicksToTimeDelta(int clock_ticks) { | TimeDelta ClockTicksToTimeDelta(int clock_ticks) { |