diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-08-30 10:22:43 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-08-30 12:36:28 +0000 |
commit | 271a6c3487a14599023a9106329505597638d793 (patch) | |
tree | e040d58ffc86c1480b79ca8528020ca9ec919bf8 /chromium/base/process | |
parent | 7b2ffa587235a47d4094787d72f38102089f402a (diff) |
BASELINE: Update Chromium to 77.0.3865.59
Change-Id: I1e89a5f3b009a9519a6705102ad65c92fe736f21
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/base/process')
-rw-r--r-- | chromium/base/process/kill.cc | 2 | ||||
-rw-r--r-- | chromium/base/process/launch_win.cc | 5 | ||||
-rw-r--r-- | chromium/base/process/process_fuchsia.cc | 3 | ||||
-rw-r--r-- | chromium/base/process/process_metrics.h | 34 | ||||
-rw-r--r-- | chromium/base/process/process_metrics_fuchsia.cc | 6 | ||||
-rw-r--r-- | chromium/base/process/process_metrics_linux.cc | 60 | ||||
-rw-r--r-- | chromium/base/process/process_metrics_mac.cc | 48 | ||||
-rw-r--r-- | chromium/base/process/process_metrics_posix.cc | 9 | ||||
-rw-r--r-- | chromium/base/process/process_metrics_win.cc | 12 | ||||
-rw-r--r-- | chromium/base/process/process_posix.cc | 5 | ||||
-rw-r--r-- | chromium/base/process/process_win.cc | 17 |
11 files changed, 55 insertions, 146 deletions
diff --git a/chromium/base/process/kill.cc b/chromium/base/process/kill.cc index f641d3fe03e..54b99beb890 100644 --- a/chromium/base/process/kill.cc +++ b/chromium/base/process/kill.cc @@ -40,7 +40,7 @@ void EnsureProcessTerminated(Process process) { if (process.WaitForExitWithTimeout(TimeDelta(), nullptr)) return; - PostDelayedTaskWithTraits( + PostDelayedTask( FROM_HERE, {TaskPriority::BEST_EFFORT, TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN}, BindOnce( diff --git a/chromium/base/process/launch_win.cc b/chromium/base/process/launch_win.cc index e2f79b8c9ff..6bf9e188d66 100644 --- a/chromium/base/process/launch_win.cc +++ b/chromium/base/process/launch_win.cc @@ -26,6 +26,7 @@ #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" #include "base/system/sys_info.h" +#include "base/threading/scoped_thread_priority.h" #include "base/win/scoped_handle.h" #include "base/win/scoped_process_information.h" #include "base/win/startup_information.h" @@ -200,6 +201,10 @@ Process LaunchProcess(const CommandLine& cmdline, Process LaunchProcess(const string16& cmdline, const LaunchOptions& options) { + // Mitigate the issues caused by loading DLLs on a background thread + // (http://crbug/973868). + base::ScopedThreadMayLoadLibraryOnBackgroundThread priority_boost(FROM_HERE); + win::StartupInformation startup_info_wrapper; STARTUPINFO* startup_info = startup_info_wrapper.startup_info(); diff --git a/chromium/base/process/process_fuchsia.cc b/chromium/base/process/process_fuchsia.cc index 8ecf9d618dc..f2605754471 100644 --- a/chromium/base/process/process_fuchsia.cc +++ b/chromium/base/process/process_fuchsia.cc @@ -13,7 +13,10 @@ #include "base/fuchsia/default_job.h" #include "base/fuchsia/fuchsia_logging.h" #include "base/strings/stringprintf.h" + +#if BUILDFLAG(CLANG_COVERAGE) #include "base/test/clang_coverage.h" +#endif namespace base { diff --git a/chromium/base/process/process_metrics.h b/chromium/base/process/process_metrics.h index 16e97850cbb..259910914a8 100644 --- a/chromium/base/process/process_metrics.h +++ b/chromium/base/process/process_metrics.h @@ -98,37 +98,6 @@ class BASE_EXPORT ProcessMetrics { BASE_EXPORT size_t GetResidentSetSize() const; #endif -#if defined(OS_CHROMEOS) - // /proc/<pid>/totmaps is a syscall that returns memory summary statistics for - // the process. - // totmaps is a Linux specific concept, currently only being used on ChromeOS. - // Do not attempt to extend this to other platforms. - // - struct TotalsSummary { - size_t private_clean_kb; - size_t private_dirty_kb; - size_t swap_kb; - }; - BASE_EXPORT TotalsSummary GetTotalsSummary() const; -#endif - -#if defined(OS_MACOSX) - struct TaskVMInfo { - // Only available on macOS 10.12+. - // Anonymous, non-discardable memory, including non-volatile IOKit. - // Measured in bytes. - uint64_t phys_footprint = 0; - - // Anonymous, non-discardable, non-compressed memory, excluding IOKit. - // Measured in bytes. - uint64_t internal = 0; - - // Compressed memory measured in bytes. - uint64_t compressed = 0; - }; - TaskVMInfo GetTaskVMInfo() const; -#endif - // Returns the percentage of time spent executing, across all threads of the // process, in the interval since the last time the method was called. Since // this considers the total execution time across all threads in a process, @@ -285,6 +254,9 @@ BASE_EXPORT size_t GetPageSize(); // at once. If the number is unavailable, a conservative best guess is returned. BASE_EXPORT size_t GetMaxFds(); +// Returns the maximum number of handles that can be open at once per process. +BASE_EXPORT size_t GetHandleLimit(); + #if defined(OS_POSIX) // Increases the file descriptor soft limit to |max_descriptors| or the OS hard // limit, whichever is lower. If the limit is already higher than diff --git a/chromium/base/process/process_metrics_fuchsia.cc b/chromium/base/process/process_metrics_fuchsia.cc index ddfa9c61b52..3c7d14cd84e 100644 --- a/chromium/base/process/process_metrics_fuchsia.cc +++ b/chromium/base/process/process_metrics_fuchsia.cc @@ -12,6 +12,12 @@ size_t GetMaxFds() { return FDIO_MAX_FD; } +size_t GetHandleLimit() { + // Duplicated from the internal Magenta kernel constant kMaxHandleCount + // (zircon/kernel/object/handle.cc). + return 256 * 1024u; +} + size_t GetSystemCommitCharge() { // TODO(https://crbug.com/926581): Fuchsia does not support this. return 0; diff --git a/chromium/base/process/process_metrics_linux.cc b/chromium/base/process/process_metrics_linux.cc index 0c119bd2836..7ffccec2b3e 100644 --- a/chromium/base/process/process_metrics_linux.cc +++ b/chromium/base/process/process_metrics_linux.cc @@ -307,66 +307,6 @@ ProcessMetrics::ProcessMetrics(ProcessHandle process) ProcessMetrics::ProcessMetrics(ProcessHandle process) : process_(process) {} #endif -#if defined(OS_CHROMEOS) -// Private, Shared and Proportional working set sizes are obtained from -// /proc/<pid>/totmaps -ProcessMetrics::TotalsSummary ProcessMetrics::GetTotalsSummary() const { - // The format of /proc/<pid>/totmaps is: - // - // Rss: 6120 kB - // Pss: 3335 kB - // Shared_Clean: 1008 kB - // Shared_Dirty: 4012 kB - // Private_Clean: 4 kB - // Private_Dirty: 1096 kB - // Referenced: XXX kB - // Anonymous: XXX kB - // AnonHugePages: XXX kB - // Swap: XXX kB - // Locked: XXX kB - ProcessMetrics::TotalsSummary summary = {}; - - const size_t kPrivate_CleanIndex = (4 * 3) + 1; - const size_t kPrivate_DirtyIndex = (5 * 3) + 1; - const size_t kSwapIndex = (9 * 3) + 1; - - std::string totmaps_data; - { - FilePath totmaps_file = internal::GetProcPidDir(process_).Append("totmaps"); - ThreadRestrictions::ScopedAllowIO allow_io; - bool ret = ReadFileToString(totmaps_file, &totmaps_data); - if (!ret || totmaps_data.length() == 0) - return summary; - } - - std::vector<std::string> totmaps_fields = SplitString( - totmaps_data, kWhitespaceASCII, KEEP_WHITESPACE, SPLIT_WANT_NONEMPTY); - - DCHECK_EQ("Private_Clean:", totmaps_fields[kPrivate_CleanIndex - 1]); - DCHECK_EQ("Private_Dirty:", totmaps_fields[kPrivate_DirtyIndex - 1]); - DCHECK_EQ("Swap:", totmaps_fields[kSwapIndex-1]); - - int private_clean_kb = 0; - int private_dirty_kb = 0; - int swap_kb = 0; - bool success = true; - success &= - StringToInt(totmaps_fields[kPrivate_CleanIndex], &private_clean_kb); - success &= - StringToInt(totmaps_fields[kPrivate_DirtyIndex], &private_dirty_kb); - success &= StringToInt(totmaps_fields[kSwapIndex], &swap_kb); - - if (!success) - return summary; - - summary.private_clean_kb = private_clean_kb; - summary.private_dirty_kb = private_dirty_kb; - summary.swap_kb = swap_kb; - - return summary; -} -#endif - size_t GetSystemCommitCharge() { SystemMemoryInfoKB meminfo; if (!GetSystemMemoryInfo(&meminfo)) diff --git a/chromium/base/process/process_metrics_mac.cc b/chromium/base/process/process_metrics_mac.cc index cbb5e937a9e..d05e122897d 100644 --- a/chromium/base/process/process_metrics_mac.cc +++ b/chromium/base/process/process_metrics_mac.cc @@ -25,37 +25,6 @@ namespace base { namespace { -#if !defined(MAC_OS_X_VERSION_10_11) || \ - MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_11 -// The |phys_footprint| field was introduced in 10.11. -struct ChromeTaskVMInfo { - mach_vm_size_t virtual_size; - integer_t region_count; - integer_t page_size; - mach_vm_size_t resident_size; - mach_vm_size_t resident_size_peak; - mach_vm_size_t device; - mach_vm_size_t device_peak; - mach_vm_size_t internal; - mach_vm_size_t internal_peak; - mach_vm_size_t external; - mach_vm_size_t external_peak; - mach_vm_size_t reusable; - mach_vm_size_t reusable_peak; - mach_vm_size_t purgeable_volatile_pmap; - mach_vm_size_t purgeable_volatile_resident; - mach_vm_size_t purgeable_volatile_virtual; - mach_vm_size_t compressed; - mach_vm_size_t compressed_peak; - mach_vm_size_t compressed_lifetime; - mach_vm_size_t phys_footprint; -}; -#else -using ChromeTaskVMInfo = task_vm_info; -#endif // MAC_OS_X_VERSION_10_11 -mach_msg_type_number_t ChromeTaskVMInfoCount = - sizeof(ChromeTaskVMInfo) / sizeof(natural_t); - bool GetTaskInfo(mach_port_t task, task_basic_info_64* task_info_data) { if (task == MACH_PORT_NULL) return false; @@ -105,23 +74,6 @@ std::unique_ptr<ProcessMetrics> ProcessMetrics::CreateProcessMetrics( return WrapUnique(new ProcessMetrics(process, port_provider)); } -ProcessMetrics::TaskVMInfo ProcessMetrics::GetTaskVMInfo() const { - TaskVMInfo info; - ChromeTaskVMInfo task_vm_info; - mach_msg_type_number_t count = ChromeTaskVMInfoCount; - kern_return_t result = - task_info(TaskForPid(process_), TASK_VM_INFO, - reinterpret_cast<task_info_t>(&task_vm_info), &count); - if (result != KERN_SUCCESS) - return info; - - info.internal = task_vm_info.internal; - info.compressed = task_vm_info.compressed; - if (count == ChromeTaskVMInfoCount) - info.phys_footprint = task_vm_info.phys_footprint; - return info; -} - #define TIME_VALUE_TO_TIMEVAL(a, r) do { \ (r)->tv_sec = (a)->seconds; \ (r)->tv_usec = (a)->microseconds; \ diff --git a/chromium/base/process/process_metrics_posix.cc b/chromium/base/process/process_metrics_posix.cc index a09bbf2c56e..5763432aa4f 100644 --- a/chromium/base/process/process_metrics_posix.cc +++ b/chromium/base/process/process_metrics_posix.cc @@ -71,6 +71,15 @@ size_t GetMaxFds() { return static_cast<size_t>(max_fds); } +size_t GetHandleLimit() { +#if defined(OS_MACOSX) + // Taken from a small test that allocated ports in a loop. + return static_cast<size_t>(1 << 18); +#else + return GetMaxFds(); +#endif +} + void IncreaseFdLimitTo(unsigned int max_descriptors) { struct rlimit limits; if (getrlimit(RLIMIT_NOFILE, &limits) == 0) { diff --git a/chromium/base/process/process_metrics_win.cc b/chromium/base/process/process_metrics_win.cc index 45e27674468..5cf0943c654 100644 --- a/chromium/base/process/process_metrics_win.cc +++ b/chromium/base/process/process_metrics_win.cc @@ -129,6 +129,12 @@ size_t GetMaxFds() { return std::numeric_limits<size_t>::max(); } +size_t GetHandleLimit() { + // Rounded down from value reported here: + // http://blogs.technet.com/b/markrussinovich/archive/2009/09/29/3283844.aspx + return static_cast<size_t>(1 << 23); +} + // static std::unique_ptr<ProcessMetrics> ProcessMetrics::CreateProcessMetrics( ProcessHandle process) { @@ -141,6 +147,9 @@ TimeDelta ProcessMetrics::GetCumulativeCPUUsage() { FILETIME kernel_time; FILETIME user_time; + if (!process_.IsValid()) + return TimeDelta(); + if (!GetProcessTimes(process_.Get(), &creation_time, &exit_time, &kernel_time, &user_time)) { // This should never fail because we duplicate the handle to guarantee it @@ -154,6 +163,9 @@ TimeDelta ProcessMetrics::GetCumulativeCPUUsage() { } bool ProcessMetrics::GetIOCounters(IoCounters* io_counters) const { + if (!process_.IsValid()) + return false; + return GetProcessIoCounters(process_.Get(), io_counters) != FALSE; } diff --git a/chromium/base/process/process_posix.cc b/chromium/base/process/process_posix.cc index 38ee542e3a0..9636d44ddc2 100644 --- a/chromium/base/process/process_posix.cc +++ b/chromium/base/process/process_posix.cc @@ -16,7 +16,6 @@ #include "base/logging.h" #include "base/posix/eintr_wrapper.h" #include "base/process/kill.h" -#include "base/test/clang_coverage.h" #include "base/threading/thread_restrictions.h" #include "build/build_config.h" @@ -24,6 +23,10 @@ #include <sys/event.h> #endif +#if BUILDFLAG(CLANG_COVERAGE) +#include "base/test/clang_coverage.h" +#endif + namespace { #if !defined(OS_NACL_NONSFI) diff --git a/chromium/base/process/process_win.cc b/chromium/base/process/process_win.cc index ae97a92c8e5..e43ce2d4faa 100644 --- a/chromium/base/process/process_win.cc +++ b/chromium/base/process/process_win.cc @@ -9,11 +9,14 @@ #include "base/logging.h" #include "base/numerics/safe_conversions.h" #include "base/process/kill.h" -#include "base/test/clang_coverage.h" #include "base/threading/thread_restrictions.h" #include <windows.h> +#if BUILDFLAG(CLANG_COVERAGE) +#include "base/test/clang_coverage.h" +#endif + namespace { DWORD kBasicProcessAccess = @@ -162,10 +165,14 @@ bool Process::Terminate(int exit_code, bool wait) const { DPLOG(ERROR) << "Error waiting for process exit"; Exited(exit_code); } else { - // The process can't be terminated, perhaps because it has already - // exited or is in the process of exiting. A non-zero timeout is necessary - // here for the same reasons as above. - DPLOG(ERROR) << "Unable to terminate process"; + // The process can't be terminated, perhaps because it has already exited or + // is in the process of exiting. An error code of ERROR_ACCESS_DENIED is the + // undocumented-but-expected result if the process has already exited or + // started exiting when TerminateProcess is called, so don't print an error + // message in that case. + if (GetLastError() != ERROR_ACCESS_DENIED) + DPLOG(ERROR) << "Unable to terminate process"; + // A non-zero timeout is necessary here for the same reasons as above. if (::WaitForSingleObject(Handle(), kWaitMs) == WAIT_OBJECT_0) { DWORD actual_exit; Exited(::GetExitCodeProcess(Handle(), &actual_exit) ? actual_exit |