diff options
Diffstat (limited to 'base')
-rw-r--r-- | base/base.gyp | 8 | ||||
-rw-r--r-- | base/base.gypi | 35 | ||||
-rw-r--r-- | base/process.h | 67 | ||||
-rw-r--r-- | base/process/process.h | 70 | ||||
-rw-r--r-- | base/process/process_info.h | 25 | ||||
-rw-r--r-- | base/process/process_info_mac.cc (renamed from base/process_info_mac.cc) | 2 | ||||
-rw-r--r-- | base/process/process_info_win.cc (renamed from base/process_info_win.cc) | 2 | ||||
-rw-r--r-- | base/process/process_linux.cc (renamed from base/process_linux.cc) | 2 | ||||
-rw-r--r-- | base/process/process_posix.cc (renamed from base/process_posix.cc) | 2 | ||||
-rw-r--r-- | base/process/process_util_unittest.cc (renamed from base/process_util_unittest.cc) | 0 | ||||
-rw-r--r-- | base/process/process_util_unittest_ios.cc (renamed from base/process_util_unittest_ios.cc) | 0 | ||||
-rw-r--r-- | base/process/process_win.cc (renamed from base/process_win.cc) | 2 | ||||
-rw-r--r-- | base/process_info.h | 22 | ||||
-rw-r--r-- | base/process_util_linux.cc | 51 |
14 files changed, 129 insertions, 159 deletions
diff --git a/base/base.gyp b/base/base.gyp index e4db68d..972ff3c 100644 --- a/base/base.gyp +++ b/base/base.gyp @@ -556,11 +556,11 @@ 'prefs/pref_service_unittest.cc', 'prefs/pref_value_map_unittest.cc', 'prefs/pref_value_store_unittest.cc', - 'process_util_unittest.cc', - 'process_util_unittest_ios.cc', 'process/memory_unittest.cc', 'process/memory_unittest_mac.h', 'process/memory_unittest_mac.mm', + 'process/process_util_unittest.cc', + 'process/process_util_unittest_ios.cc', 'profiler/tracked_time_unittest.cc', 'rand_util_unittest.cc', 'safe_numerics_unittest.cc', @@ -683,9 +683,9 @@ ['OS == "ios" and _toolset != "host"', { 'sources/': [ # Only test the iOS-meaningful portion of process_utils. - ['exclude', '^process_util_unittest\\.cc$'], ['exclude', '^process/memory_unittest'], - ['include', '^process_util_unittest_ios\\.cc$'], + ['exclude', '^process/process_util_unittest\\.cc$'], + ['include', '^process/process_util_unittest_ios\\.cc$'], # Requires spawning processes. ['exclude', '^metrics/stats_table_unittest\\.cc$'], # iOS does not use message_pump_libevent. diff --git a/base/base.gypi b/base/base.gypi index 63c2b93..19fdcb9 100644 --- a/base/base.gypi +++ b/base/base.gypi @@ -379,14 +379,6 @@ 'power_monitor/power_monitor_posix.cc', 'power_monitor/power_monitor_win.cc', 'power_monitor/power_observer.h', - 'process.h', - 'process_info.h', - 'process_info_mac.cc', - 'process_info_win.cc', - 'process_linux.cc', - 'process_posix.cc', - 'process_util.h', - 'process_win.cc', 'process/internal_linux.cc', 'process/internal_linux.h', 'process/kill.cc', @@ -403,12 +395,16 @@ 'process/memory_linux.cc', 'process/memory_mac.mm', 'process/memory_win.cc', + 'process/process.h', 'process/process_handle_freebsd.cc', 'process/process_handle_linux.cc', 'process/process_handle_mac.cc', 'process/process_handle_openbsd.cc', 'process/process_handle_posix.cc', 'process/process_handle_win.cc', + 'process/process_info.h', + 'process/process_info_mac.cc', + 'process/process_info_win.cc', 'process/process_iterator.cc', 'process/process_iterator.h', 'process/process_iterator_freebsd.cc', @@ -416,6 +412,7 @@ 'process/process_iterator_mac.cc', 'process/process_iterator_openbsd.cc', 'process/process_iterator_win.cc', + 'process/process_linux.cc', 'process/process_metrics.h', 'process/process_metrics_freebsd.cc', 'process/process_metrics_ios.cc', @@ -424,6 +421,8 @@ 'process/process_metrics_openbsd.cc', 'process/process_metrics_posix.cc', 'process/process_metrics_win.cc', + 'process/process_posix.cc', + 'process/process_win.cc', 'profiler/scoped_profile.cc', 'profiler/scoped_profile.h', 'profiler/alternate_timer.cc', @@ -701,9 +700,9 @@ 'path_service.cc', 'posix/unix_domain_socket_linux.cc', 'process/kill_posix.cc', - 'process/process_metrics_posix.cc', 'process/launch_posix.cc', - 'process_posix.cc', + 'process/process_metrics_posix.cc', + 'process/process_posix.cc', 'rand_util_posix.cc', 'scoped_native_library.cc', 'files/scoped_temp_dir.cc', @@ -726,7 +725,6 @@ 'sources/': [ ['include', '^debug/proc_maps_linux\\.cc$'], ['include', '^files/file_path_watcher_linux\\.cc$'], - ['include', '^process_util_linux\\.cc$'], ['include', '^process/memory_linux\\.cc$'], ['include', '^process/internal_linux\\.cc$'], ['include', '^process/process_handle_linux\\.cc$'], @@ -766,14 +764,12 @@ ['include', '^threading/platform_thread_mac\\.'], ['include', '^time/time_mac\\.'], ['include', '^worker_pool_mac\\.'], - # Exclude all process_util except the minimal implementation + # Exclude all process/ except the minimal implementation # needed on iOS (mostly for unit tests). - ['exclude', '^process_util'], - ['include', '^process_util_ios\\.mm$'], - ['exclude', '^process/launch_posix\\.cc$'], - ['exclude', '^process/launch_mac\\.cc$'], - ['exclude', '^process/memory_mac\\.mm$'], - ['include', '^process/process_handle_posix\\.cc$'], + ['exclude', '^process/.*'], + ['include', '^process/.*_ios\.(cc|mm)$'], + ['include', '^process/memory_stubs\.cc$'], + ['include', '^process/process_handle_posix\.cc$'], ], 'sources': [ 'process/memory_stubs.cc', @@ -858,8 +854,7 @@ ['exclude', '^files/file_path_watcher_linux\\.cc$'], ['exclude', '^files/file_path_watcher_stub\\.cc$'], ['exclude', '^file_util_linux\\.cc$'], - ['exclude', '^process_linux\\.cc$'], - ['exclude', '^process_util_linux\\.cc$'], + ['exclude', '^process/process_linux\\.cc$'], ['exclude', '^sys_info_linux\\.cc$'], ], }], diff --git a/base/process.h b/base/process.h index 57983cc..71f4391 100644 --- a/base/process.h +++ b/base/process.h @@ -1,70 +1,13 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2013 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// Forwarding header until all include paths can be updated. +// TODO(rsesek): Remove this file <http://crbug.com/242290>. + #ifndef BASE_PROCESS_H_ #define BASE_PROCESS_H_ -#include "base/base_export.h" -#include "base/basictypes.h" -#include "base/process/process_handle.h" -#include "build/build_config.h" - -namespace base { - -class BASE_EXPORT Process { - public: - Process() : process_(kNullProcessHandle) { - } - - explicit Process(ProcessHandle handle) : process_(handle) { - } - - // A handle to the current process. - static Process Current(); - - static bool CanBackgroundProcesses(); - - // Get/Set the handle for this process. The handle will be 0 if the process - // is no longer running. - ProcessHandle handle() const { return process_; } - void set_handle(ProcessHandle handle) { - process_ = handle; - } - - // Get the PID for this process. - ProcessId pid() const; - - // Is the this process the current process. - bool is_current() const; - - // Close the process handle. This will not terminate the process. - void Close(); - - // Terminates the process with extreme prejudice. The given result code will - // be the exit code of the process. If the process has already exited, this - // will do nothing. - void Terminate(int result_code); - - // A process is backgrounded when it's priority is lower than normal. - // Return true if this process is backgrounded, false otherwise. - bool IsProcessBackgrounded() const; - - // Set a process as backgrounded. If value is true, the priority - // of the process will be lowered. If value is false, the priority - // of the process will be made "normal" - equivalent to default - // process priority. - // Returns true if the priority was changed, false otherwise. - bool SetProcessBackgrounded(bool value); - - // Returns an integer representing the priority of a process. The meaning - // of this value is OS dependent. - int GetPriority() const; - - private: - ProcessHandle process_; -}; - -} // namespace base +#include "base/process/process.h" #endif // BASE_PROCESS_H_ diff --git a/base/process/process.h b/base/process/process.h new file mode 100644 index 0000000..20e8884 --- /dev/null +++ b/base/process/process.h @@ -0,0 +1,70 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef BASE_PROCESS_PROCESS_PROCESS_H_ +#define BASE_PROCESS_PROCESS_PROCESS_H_ + +#include "base/base_export.h" +#include "base/basictypes.h" +#include "base/process/process_handle.h" +#include "build/build_config.h" + +namespace base { + +class BASE_EXPORT Process { + public: + Process() : process_(kNullProcessHandle) { + } + + explicit Process(ProcessHandle handle) : process_(handle) { + } + + // A handle to the current process. + static Process Current(); + + static bool CanBackgroundProcesses(); + + // Get/Set the handle for this process. The handle will be 0 if the process + // is no longer running. + ProcessHandle handle() const { return process_; } + void set_handle(ProcessHandle handle) { + process_ = handle; + } + + // Get the PID for this process. + ProcessId pid() const; + + // Is the this process the current process. + bool is_current() const; + + // Close the process handle. This will not terminate the process. + void Close(); + + // Terminates the process with extreme prejudice. The given result code will + // be the exit code of the process. If the process has already exited, this + // will do nothing. + void Terminate(int result_code); + + // A process is backgrounded when it's priority is lower than normal. + // Return true if this process is backgrounded, false otherwise. + bool IsProcessBackgrounded() const; + + // Set a process as backgrounded. If value is true, the priority + // of the process will be lowered. If value is false, the priority + // of the process will be made "normal" - equivalent to default + // process priority. + // Returns true if the priority was changed, false otherwise. + bool SetProcessBackgrounded(bool value); + + // Returns an integer representing the priority of a process. The meaning + // of this value is OS dependent. + int GetPriority() const; + + private: + ProcessHandle process_; +}; + +} // namespace base + +#endif // BASE_PROCESS_PROCESS_PROCESS_H_ diff --git a/base/process/process_info.h b/base/process/process_info.h new file mode 100644 index 0000000..e72c56b --- /dev/null +++ b/base/process/process_info.h @@ -0,0 +1,25 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef BASE_PROCESS_PROCESS_PROCESS_INFO_H_ +#define BASE_PROCESS_PROCESS_PROCESS_INFO_H_ + +#include "base/base_export.h" +#include "base/basictypes.h" + +namespace base { + +class Time; + +// Vends information about the current process. +class BASE_EXPORT CurrentProcessInfo { + public: + // Returns the time at which the process was launched or NULL if an error + // occurred retrieving the information. + static const Time* CreationTime(); +}; + +} // namespace base + +#endif // BASE_PROCESS_PROCESS_PROCESS_INFO_H_ diff --git a/base/process_info_mac.cc b/base/process/process_info_mac.cc index 99a21cc..d83acd1 100644 --- a/base/process_info_mac.cc +++ b/base/process/process_info_mac.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/process_info.h" +#include "base/process/process_info.h" #include <sys/sysctl.h> #include <sys/time.h> diff --git a/base/process_info_win.cc b/base/process/process_info_win.cc index 04c6c2f..5290b76 100644 --- a/base/process_info_win.cc +++ b/base/process/process_info_win.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/process_info.h" +#include "base/process/process_info.h" #include <windows.h> diff --git a/base/process_linux.cc b/base/process/process_linux.cc index 9fd4a7d..93006aa 100644 --- a/base/process_linux.cc +++ b/base/process/process_linux.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/process.h" +#include "base/process/process.h" #include <errno.h> #include <sys/resource.h> diff --git a/base/process_posix.cc b/base/process/process_posix.cc index 20e623c..a446b98 100644 --- a/base/process_posix.cc +++ b/base/process/process_posix.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/process.h" +#include "base/process/process.h" #include <sys/types.h> #include <sys/time.h> diff --git a/base/process_util_unittest.cc b/base/process/process_util_unittest.cc index 4a3d36d..4a3d36d 100644 --- a/base/process_util_unittest.cc +++ b/base/process/process_util_unittest.cc diff --git a/base/process_util_unittest_ios.cc b/base/process/process_util_unittest_ios.cc index c82535d..c82535d 100644 --- a/base/process_util_unittest_ios.cc +++ b/base/process/process_util_unittest_ios.cc diff --git a/base/process_win.cc b/base/process/process_win.cc index 3f683ab..30945f2a 100644 --- a/base/process_win.cc +++ b/base/process/process_win.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/process.h" +#include "base/process/process.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "base/process_util.h" diff --git a/base/process_info.h b/base/process_info.h index 429d4dc..17502b8 100644 --- a/base/process_info.h +++ b/base/process_info.h @@ -1,25 +1,13 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2013 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// Forwarding header until all include paths can be updated. +// TODO(rsesek): Remove this file <http://crbug.com/242290>. + #ifndef BASE_PROCESS_INFO_H_ #define BASE_PROCESS_INFO_H_ -#include "base/base_export.h" -#include "base/basictypes.h" - -namespace base { - -class Time; - -// Vends information about the current process. -class BASE_EXPORT CurrentProcessInfo { - public: - // Returns the time at which the process was launched or NULL if an error - // occurred retrieving the information. - static const Time* CreationTime(); -}; - -} // namespace base +#include "base/process/process_info.h" #endif // BASE_PROCESS_INFO_H_ diff --git a/base/process_util_linux.cc b/base/process_util_linux.cc deleted file mode 100644 index b76f8c1..0000000 --- a/base/process_util_linux.cc +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "base/process_util.h" - -#include <dirent.h> -#include <malloc.h> -#include <sys/time.h> -#include <sys/types.h> -#include <unistd.h> - -#include "base/file_util.h" -#include "base/logging.h" -#include "base/process/internal_linux.h" -#include "base/strings/string_number_conversions.h" -#include "base/strings/string_split.h" -#include "base/strings/string_util.h" -#include "base/sys_info.h" -#include "base/threading/thread_restrictions.h" - -namespace base { - -size_t g_oom_size = 0U; - -const char kProcSelfExe[] = "/proc/self/exe"; - -ProcessId GetParentProcessId(ProcessHandle process) { - ProcessId pid = - internal::ReadProcStatsAndGetFieldAsInt(process, internal::VM_PPID); - if (pid) - return pid; - return -1; -} - -FilePath GetProcessExecutablePath(ProcessHandle process) { - FilePath stat_file = internal::GetProcPidDir(process).Append("exe"); - FilePath exe_name; - if (!file_util::ReadSymbolicLink(stat_file, &exe_name)) { - // No such process. Happens frequently in e.g. TerminateAllChromeProcesses - return FilePath(); - } - return exe_name; -} - -int GetNumberOfThreads(ProcessHandle process) { - return internal::ReadProcStatsAndGetFieldAsInt(process, - internal::VM_NUMTHREADS); -} - -} // namespace base |