Invoke the iOS hook from TestSuite so each run_all_unittests.cc file does not
[chromium-blink-merge.git] / base / process_util_ios.mm
blob161d39686aa0e018fa13974a805accfa487b46e9
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/process_util.h"
7 #import <Foundation/Foundation.h>
8 #include <mach/task.h>
9 #include <stdio.h>
11 #include "base/logging.h"
13 // This is just enough of a shim to let the support needed by test_support
14 // link.  In general, process_util isn't valid on iOS.
16 namespace base {
18 namespace {
20 bool GetTaskInfo(task_basic_info_64* task_info_data) {
21   mach_msg_type_number_t count = TASK_BASIC_INFO_64_COUNT;
22   kern_return_t kr = task_info(mach_task_self(),
23                                TASK_BASIC_INFO_64,
24                                reinterpret_cast<task_info_t>(task_info_data),
25                                &count);
26   return kr == KERN_SUCCESS;
29 }  // namespace
31 ProcessId GetCurrentProcId() {
32   return getpid();
35 ProcessHandle GetCurrentProcessHandle() {
36   return GetCurrentProcId();
39 void EnableTerminationOnHeapCorruption() {
40   // On iOS, there nothing to do AFAIK.
43 void EnableTerminationOnOutOfMemory() {
44   // iOS provides this for free!
47 void RaiseProcessToHighPriority() {
48   // Impossible on iOS. Do nothing.
51 ProcessMetrics::ProcessMetrics(ProcessHandle process) {}
53 ProcessMetrics::~ProcessMetrics() {}
55 // static
56 ProcessMetrics* ProcessMetrics::CreateProcessMetrics(ProcessHandle process) {
57   return new ProcessMetrics(process);
60 size_t ProcessMetrics::GetWorkingSetSize() const {
61   task_basic_info_64 task_info_data;
62   if (!GetTaskInfo(&task_info_data))
63     return 0;
64   return task_info_data.resident_size;
67 }  // namespace base