summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Vakulenko <avakulenko@google.com>2016-01-20 16:24:55 -0800
committerAlex Vakulenko <avakulenko@google.com>2016-01-20 18:44:56 -0800
commit42b71bb1f5e3181432118923284adf294524d3d8 (patch)
treef40d5ff520fa1f29591563ebff33185cbf9a5f54
parent8103ab12a472dbb30df17d4ac98fa78d976ec00b (diff)
downloadlibchrome-42b71bb1f5e3181432118923284adf294524d3d8.tar.gz
libchrome: Fix Mac build
The recent uprev attempt missed a couple Mac-specific files. Adding them now. Also, there were some other build breaks in Mac files. Particularly, had to revert the uprev change to the following file base/message_loop/message_pump_mac.mm because the change relied on base::mac::CallWithEHFrame() which was implemented in assembly and didn't compile on 32 bit platform. So, I have removed the change introduced with https://codereview.chromium.org/1212093002 on Chromium side. Change-Id: Ic78acbb22732e64965f99ce31bc8382f228e22bb
-rw-r--r--Android.mk4
-rw-r--r--SConstruct22
-rw-r--r--base/message_loop/message_pump_libevent.cc5
-rw-r--r--base/message_loop/message_pump_mac.mm46
-rw-r--r--base/process/port_provider_mac.cc27
-rw-r--r--base/process/port_provider_mac.h61
-rw-r--r--base/process/process_handle.cc52
-rw-r--r--base/process/process_posix.cc2
-rw-r--r--base/trace_event/malloc_dump_provider.cc3
-rw-r--r--base/trace_event/process_memory_maps_dump_provider.h2
10 files changed, 179 insertions, 45 deletions
diff --git a/Android.mk b/Android.mk
index 8eddd091eb..93b2cfd867 100644
--- a/Android.mk
+++ b/Android.mk
@@ -109,6 +109,7 @@ libchromeCommonSrc := \
base/process/kill_posix.cc \
base/process/launch.cc \
base/process/launch_posix.cc \
+ base/process/process_handle.cc \
base/process/process_handle_posix.cc \
base/process/process_iterator.cc \
base/process/process_metrics.cc \
@@ -178,6 +179,7 @@ libchromeCommonSrc := \
base/trace_event/memory_allocator_dump.cc \
base/trace_event/memory_allocator_dump_guid.cc \
base/trace_event/memory_dump_manager.cc \
+ base/trace_event/malloc_dump_provider.cc \
base/trace_event/memory_dump_request_args.cc \
base/trace_event/memory_dump_session_state.cc \
base/trace_event/process_memory_dump.cc \
@@ -211,7 +213,6 @@ libchromeLinuxSrc := \
base/sys_info_linux.cc \
base/threading/platform_thread_internal_posix.cc \
base/threading/platform_thread_linux.cc \
- base/trace_event/malloc_dump_provider.cc \
components/timers/alarm_timer_chromeos.cc \
libchromeMacSrc := \
@@ -227,6 +228,7 @@ libchromeMacSrc := \
base/mac/scoped_nsautorelease_pool.mm \
base/message_loop/message_pump_mac.mm \
base/process/launch_mac.cc \
+ base/process/port_provider_mac.cc \
base/process/process_handle_mac.cc \
base/process/process_iterator_mac.cc \
base/process/process_metrics_mac.cc \
diff --git a/SConstruct b/SConstruct
index 10e2b802e6..e336a65a1a 100644
--- a/SConstruct
+++ b/SConstruct
@@ -26,9 +26,9 @@ base_libs = [
{
'name' : 'core',
'sources' : """
- allocator/type_profiler_control.cc
at_exit.cc
- atomicops_internals_x86_gcc.cc
+ base64.cc
+ base64url.cc
base_switches.cc
bind_helpers.cc
build_time.cc
@@ -60,9 +60,11 @@ base_libs = [
files/scoped_temp_dir.cc
guid.cc
guid_posix.cc
+ json/json_file_value_serializer.cc
json/json_parser.cc
json/json_reader.cc
json/json_string_value_serializer.cc
+ json/json_value_converter.cc
json/json_writer.cc
json/string_escape.cc
lazy_instance.cc
@@ -75,14 +77,14 @@ base_libs = [
memory/weak_ptr.cc
message_loop/incoming_task_queue.cc
message_loop/message_loop.cc
- message_loop/message_loop_proxy.cc
- message_loop/message_loop_proxy_impl.cc
+ message_loop/message_loop_task_runner.cc
message_loop/message_pump.cc
message_loop/message_pump_default.cc
message_loop/message_pump_glib.cc
message_loop/message_pump_libevent.cc
metrics/bucket_ranges.cc
metrics/field_trial.cc
+ metrics/metrics_hashes.cc
metrics/histogram_base.cc
metrics/histogram.cc
metrics/histogram_samples.cc
@@ -119,6 +121,7 @@ base_libs = [
sequence_checker_impl.cc
sequenced_task_runner.cc
sha1_portable.cc
+ strings/pattern.cc
strings/safe_sprintf.cc
strings/string16.cc
strings/string_number_conversions.cc
@@ -170,23 +173,30 @@ base_libs = [
time/tick_clock.cc
time/time.cc
time/time_posix.cc
+ trace_event/heap_profiler_allocation_context.cc
+ trace_event/heap_profiler_allocation_context_tracker.cc
+ trace_event/heap_profiler_stack_frame_deduplicator.cc
+ trace_event/heap_profiler_type_name_deduplicator.cc
trace_event/malloc_dump_provider.cc
trace_event/memory_allocator_dump.cc
trace_event/memory_allocator_dump_guid.cc
trace_event/memory_dump_manager.cc
+ trace_event/memory_dump_request_args.cc
trace_event/memory_dump_session_state.cc
trace_event/process_memory_dump.cc
trace_event/process_memory_maps.cc
trace_event/process_memory_maps_dump_provider.cc
trace_event/process_memory_totals.cc
trace_event/process_memory_totals_dump_provider.cc
+ trace_event/trace_buffer.cc
trace_event/trace_config.cc
trace_event/trace_event_argument.cc
trace_event/trace_event_impl.cc
- trace_event/trace_event_impl_constants.cc
- trace_event/trace_event_memory.cc
trace_event/trace_event_memory_overhead.cc
trace_event/trace_event_synthetic_delay.cc
+ trace_event/trace_log.cc
+ trace_event/trace_log_constants.cc
+ trace_event/trace_sampling_thread.cc
tracked_objects.cc
tracking_info.cc
values.cc
diff --git a/base/message_loop/message_pump_libevent.cc b/base/message_loop/message_pump_libevent.cc
index 1df9819720..72726a828c 100644
--- a/base/message_loop/message_pump_libevent.cc
+++ b/base/message_loop/message_pump_libevent.cc
@@ -14,9 +14,6 @@
#include "base/memory/scoped_ptr.h"
#include "base/observer_list.h"
#include "base/posix/eintr_wrapper.h"
-#if !defined(__ANDROID__) && !defined(__ANDROID_HOST__)
-#include "base/third_party/libevent/event.h"
-#endif
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
@@ -25,6 +22,8 @@
#include <event2/event.h>
#include <event2/event_compat.h>
#include <event2/event_struct.h>
+#else
+#include "third_party/libevent/event.h"
#endif
#if defined(OS_MACOSX)
diff --git a/base/message_loop/message_pump_mac.mm b/base/message_loop/message_pump_mac.mm
index 9f2f675379..95d1c5f1fc 100644
--- a/base/message_loop/message_pump_mac.mm
+++ b/base/message_loop/message_pump_mac.mm
@@ -10,13 +10,10 @@
#include <limits>
#include "base/logging.h"
-#include "base/mac/call_with_eh_frame.h"
#include "base/mac/scoped_cftyperef.h"
-#include "base/macros.h"
#include "base/message_loop/timer_slack.h"
#include "base/run_loop.h"
#include "base/time/time.h"
-#include "build/build_config.h"
#if !defined(OS_IOS)
#import <AppKit/AppKit.h>
@@ -304,9 +301,7 @@ void MessagePumpCFRunLoopBase::RunDelayedWorkTimer(
// static
void MessagePumpCFRunLoopBase::RunWorkSource(void* info) {
MessagePumpCFRunLoopBase* self = static_cast<MessagePumpCFRunLoopBase*>(info);
- base::mac::CallWithEHFrame(^{
- self->RunWork();
- });
+ self->RunWork();
}
// Called by MessagePumpCFRunLoopBase::RunWorkSource.
@@ -365,9 +360,7 @@ bool MessagePumpCFRunLoopBase::RunWork() {
// static
void MessagePumpCFRunLoopBase::RunIdleWorkSource(void* info) {
MessagePumpCFRunLoopBase* self = static_cast<MessagePumpCFRunLoopBase*>(info);
- base::mac::CallWithEHFrame(^{
- self->RunIdleWork();
- });
+ self->RunIdleWork();
}
// Called by MessagePumpCFRunLoopBase::RunIdleWorkSource.
@@ -401,9 +394,7 @@ bool MessagePumpCFRunLoopBase::RunIdleWork() {
// static
void MessagePumpCFRunLoopBase::RunNestingDeferredWorkSource(void* info) {
MessagePumpCFRunLoopBase* self = static_cast<MessagePumpCFRunLoopBase*>(info);
- base::mac::CallWithEHFrame(^{
- self->RunNestingDeferredWork();
- });
+ self->RunNestingDeferredWork();
}
// Called by MessagePumpCFRunLoopBase::RunNestingDeferredWorkSource.
@@ -451,16 +442,15 @@ void MessagePumpCFRunLoopBase::PreWaitObserver(
CFRunLoopActivity /* activity */,
void* info) {
MessagePumpCFRunLoopBase* self = static_cast<MessagePumpCFRunLoopBase*>(info);
- base::mac::CallWithEHFrame(^{
- // Attempt to do some idle work before going to sleep.
- self->RunIdleWork();
-
- // The run loop is about to go to sleep. If any of the work done since it
- // started or woke up resulted in a nested run loop running,
- // nesting-deferred work may have accumulated. Schedule it for processing
- // if appropriate.
- self->MaybeScheduleNestingDeferredWork();
- });
+
+ // Attempt to do some idle work before going to sleep.
+ self->RunIdleWork();
+
+ // The run loop is about to go to sleep. If any of the work done since it
+ // started or woke up resulted in a nested run loop running,
+ // nesting-deferred work may have accumulated. Schedule it for processing
+ // if appropriate.
+ self->MaybeScheduleNestingDeferredWork();
}
// Called from the run loop.
@@ -476,9 +466,7 @@ void MessagePumpCFRunLoopBase::PreSourceObserver(
// level did not sleep or exit, nesting-deferred work may have accumulated
// if a nested loop ran. Schedule nesting-deferred work for processing if
// appropriate.
- base::mac::CallWithEHFrame(^{
- self->MaybeScheduleNestingDeferredWork();
- });
+ self->MaybeScheduleNestingDeferredWork();
}
// Called from the run loop.
@@ -514,9 +502,7 @@ void MessagePumpCFRunLoopBase::EnterExitObserver(
// to sleep or exiting. It must be called before decrementing the
// value so that the value still corresponds to the level of the exiting
// loop.
- base::mac::CallWithEHFrame(^{
- self->MaybeScheduleNestingDeferredWork();
- });
+ self->MaybeScheduleNestingDeferredWork();
--self->nesting_level_;
break;
@@ -524,9 +510,7 @@ void MessagePumpCFRunLoopBase::EnterExitObserver(
break;
}
- base::mac::CallWithEHFrame(^{
- self->EnterExitRunLoop(activity);
- });
+ self->EnterExitRunLoop(activity);
}
// Called by MessagePumpCFRunLoopBase::EnterExitRunLoop. The default
diff --git a/base/process/port_provider_mac.cc b/base/process/port_provider_mac.cc
new file mode 100644
index 0000000000..ac13949ac8
--- /dev/null
+++ b/base/process/port_provider_mac.cc
@@ -0,0 +1,27 @@
+// Copyright 2015 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/port_provider_mac.h"
+
+namespace base {
+
+PortProvider::PortProvider() : lock_(), observer_list_() {}
+PortProvider::~PortProvider() {}
+
+void PortProvider::AddObserver(Observer* observer) {
+ base::AutoLock l(lock_);
+ observer_list_.AddObserver(observer);
+}
+
+void PortProvider::RemoveObserver(Observer* observer) {
+ base::AutoLock l(lock_);
+ observer_list_.RemoveObserver(observer);
+}
+
+void PortProvider::NotifyObservers(ProcessHandle process) {
+ base::AutoLock l(lock_);
+ FOR_EACH_OBSERVER(Observer, observer_list_, OnReceivedTaskPort(process));
+}
+
+} // namespace base
diff --git a/base/process/port_provider_mac.h b/base/process/port_provider_mac.h
new file mode 100644
index 0000000000..2f40297f28
--- /dev/null
+++ b/base/process/port_provider_mac.h
@@ -0,0 +1,61 @@
+// Copyright 2015 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_PORT_PROVIDER_MAC_H_
+#define BASE_PROCESS_PORT_PROVIDER_MAC_H_
+
+#include <mach/mach.h>
+
+#include "base/base_export.h"
+#include "base/macros.h"
+#include "base/observer_list.h"
+#include "base/process/process_handle.h"
+#include "base/synchronization/lock.h"
+
+namespace base {
+
+// Abstract base class that provides a mapping from ProcessHandle (pid_t) to the
+// Mach task port. This replicates task_for_pid(), which requires root
+// privileges.
+class BASE_EXPORT PortProvider {
+ public:
+ PortProvider();
+ virtual ~PortProvider();
+
+ class Observer {
+ public:
+ virtual ~Observer() {};
+ // Called by the PortProvider to notify observers that the task port was
+ // received for a given process.
+ // No guarantees are made about the thread on which this notification will
+ // be sent.
+ // Observers must not call AddObserver() or RemoveObserver() in this
+ // callback, as doing so will deadlock.
+ virtual void OnReceivedTaskPort(ProcessHandle process) = 0;
+ };
+
+ // Returns the mach task port for |process| if possible, or else
+ // |MACH_PORT_NULL|.
+ virtual mach_port_t TaskForPid(ProcessHandle process) const = 0;
+
+ // Observer interface.
+ void AddObserver(Observer* observer);
+ void RemoveObserver(Observer* observer);
+
+ protected:
+ // Called by subclasses to send a notification to observers.
+ void NotifyObservers(ProcessHandle process);
+
+ private:
+ // ObserverList is not thread-safe, so |lock_| ensures consistency of
+ // |observer_list_|.
+ base::Lock lock_;
+ base::ObserverList<Observer> observer_list_;
+
+ DISALLOW_COPY_AND_ASSIGN(PortProvider);
+};
+
+} // namespace base
+
+#endif // BASE_PROCESS_PORT_PROVIDER_MAC_H_
diff --git a/base/process/process_handle.cc b/base/process/process_handle.cc
new file mode 100644
index 0000000000..1f22b93d31
--- /dev/null
+++ b/base/process/process_handle.cc
@@ -0,0 +1,52 @@
+// Copyright 2015 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 <stdint.h>
+
+#include "base/logging.h"
+#include "base/process/process_handle.h"
+#include "build/build_config.h"
+
+namespace base {
+
+namespace {
+bool g_have_unique_id = false;
+uint32_t g_unique_id;
+
+// The process which set |g_unique_id|.
+ProcessId g_procid;
+
+// Mangle IDs so that they are not accidentally used as PIDs, e.g. as an
+// argument to kill or waitpid.
+uint32_t MangleProcessId(ProcessId process_id) {
+ // Add a large power of 10 so that the pid is still the pid is still readable
+ // inside the mangled id.
+ return static_cast<uint32_t>(process_id) + 1000000000U;
+}
+
+} // namespace
+
+uint32_t GetUniqueIdForProcess() {
+ if (!g_have_unique_id) {
+ return MangleProcessId(GetCurrentProcId());
+ }
+
+ // Make sure we are the same process that set |g_procid|. This check may have
+ // false negatives (if a process ID was reused) but should have no false
+ // positives.
+ DCHECK_EQ(GetCurrentProcId(), g_procid);
+ return g_unique_id;
+}
+
+#if defined(OS_LINUX)
+
+void InitUniqueIdForProcessInPidNamespace(ProcessId pid_outside_of_namespace) {
+ g_unique_id = MangleProcessId(pid_outside_of_namespace);
+ g_procid = GetCurrentProcId();
+ g_have_unique_id = true;
+}
+
+#endif
+
+} // namespace base
diff --git a/base/process/process_posix.cc b/base/process/process_posix.cc
index c6c0732fbe..248fc80910 100644
--- a/base/process/process_posix.cc
+++ b/base/process/process_posix.cc
@@ -359,7 +359,7 @@ bool Process::IsProcessBackgrounded() const {
return false;
}
-bool Process::SetProcessBackgrounded(bool value) {
+bool Process::SetProcessBackgrounded(bool /*value*/) {
// Not implemented for POSIX systems other than Linux. With POSIX, if we were
// to lower the process priority we wouldn't be able to raise it back to its
// initial priority.
diff --git a/base/trace_event/malloc_dump_provider.cc b/base/trace_event/malloc_dump_provider.cc
index 064752bc5b..229a8c14f3 100644
--- a/base/trace_event/malloc_dump_provider.cc
+++ b/base/trace_event/malloc_dump_provider.cc
@@ -50,7 +50,8 @@ bool MallocDumpProvider::OnMemoryDump(const MemoryDumpArgs& /* args */,
&allocated_objects_size);
DCHECK(res);
#elif defined(OS_MACOSX) || defined(OS_IOS)
- malloc_statistics_t stats = {0};
+ malloc_statistics_t stats;
+ memset(&stats, 0, sizeof(stats));
malloc_zone_statistics(nullptr, &stats);
total_virtual_size = stats.size_allocated;
allocated_objects_size = stats.size_in_use;
diff --git a/base/trace_event/process_memory_maps_dump_provider.h b/base/trace_event/process_memory_maps_dump_provider.h
index 84badfe9a0..9d8b8b946e 100644
--- a/base/trace_event/process_memory_maps_dump_provider.h
+++ b/base/trace_event/process_memory_maps_dump_provider.h
@@ -27,9 +27,7 @@ class BASE_EXPORT ProcessMemoryMapsDumpProvider : public MemoryDumpProvider {
friend struct DefaultSingletonTraits<ProcessMemoryMapsDumpProvider>;
FRIEND_TEST_ALL_PREFIXES(ProcessMemoryMapsDumpProviderTest, ParseProcSmaps);
-#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_NACL)
static FILE* proc_smaps_for_testing;
-#endif
ProcessMemoryMapsDumpProvider();
~ProcessMemoryMapsDumpProvider() override;