Defer to libbase macros on Android

On Android, prefer the libbase definitions of macros.  This prevents
compiler errors about macro redefinition.

Allow consumers of libchrome to see libbase headers implicitly by
exporting headers on libbase's include path.

Fix a small bug in how libchrome-dbus was defined.  It needs to export
libchrome's headers, since to work with libchrome-dbus, you need all the
headers necessary to consume libchrome as well.

Bug: 28117776
Test: Compiles

Change-Id: I35e969d7037d3374af9d2e931814740e29691029
diff --git a/Android.mk b/Android.mk
index 47ca1ac..018bd4e 100644
--- a/Android.mk
+++ b/Android.mk
@@ -428,7 +428,8 @@
 LOCAL_CFLAGS := $(libchromeCommonCFlags)
 LOCAL_CLANG := $(libchromeUseClang)
 LOCAL_C_INCLUDES := $(libchromeCommonCIncludes)
-LOCAL_SHARED_LIBRARIES := libevent liblog libcutils
+LOCAL_EXPORT_SHARED_LIBRARY_HEADERS := libbase
+LOCAL_SHARED_LIBRARIES :=  libbase libevent liblog libcutils
 LOCAL_STATIC_LIBRARIES := libmodpb64
 LOCAL_EXPORT_C_INCLUDE_DIRS := $(libchromeExportedCIncludes)
 include $(BUILD_SHARED_LIBRARY)
@@ -442,7 +443,8 @@
 LOCAL_CPP_EXTENSION := $(libchromeCommonCppExtension)
 LOCAL_C_INCLUDES := $(libchromeCommonCIncludes)
 LOCAL_EXPORT_C_INCLUDE_DIRS := $(libchromeExportedCIncludes)
-LOCAL_SHARED_LIBRARIES := libevent-host
+LOCAL_EXPORT_SHARED_LIBRARY_HEADERS := libbase
+LOCAL_SHARED_LIBRARIES := libbase libevent-host
 LOCAL_STATIC_LIBRARIES := libmodpb64-host
 LOCAL_SRC_FILES := $(libchromeCommonSrc) $(libchromeHostSrc)
 LOCAL_LDFLAGS := $(libchromeHostLdFlags)
@@ -473,6 +475,7 @@
 LOCAL_CFLAGS := $(libchromeCommonCFlags)
 LOCAL_CLANG := $(libchromeUseClang)
 LOCAL_C_INCLUDES := $(libchromeCommonCIncludes)
+LOCAL_EXPORT_SHARED_LIBRARY_HEADERS := libchrome
 LOCAL_SHARED_LIBRARIES := \
 	libchrome \
 	libdbus \
@@ -480,6 +483,7 @@
 
 LOCAL_STATIC_LIBRARIES :=
 LOCAL_EXPORT_C_INCLUDE_DIRS := $(libchromeExportedCIncludes)
+LOCAL_EXPORT_SHARED_LIBRARY_HEADERS := libchrome
 include $(BUILD_SHARED_LIBRARY)
 
 endif  # local_use_dbus == 1
diff --git a/base/compiler_specific.h b/base/compiler_specific.h
index 339e9b7..4067d61 100644
--- a/base/compiler_specific.h
+++ b/base/compiler_specific.h
@@ -7,6 +7,11 @@
 
 #include "build/build_config.h"
 
+#if defined(ANDROID)
+// Prefer Android's libbase definitions to our own.
+#include <android-base/macros.h>
+#endif  // defined(ANDROID)
+
 #if defined(COMPILER_MSVC)
 
 // For _Printf_format_string_.
diff --git a/base/macros.h b/base/macros.h
index b9dd899..f971da9 100644
--- a/base/macros.h
+++ b/base/macros.h
@@ -12,13 +12,22 @@
 
 #include <stddef.h>  // For size_t.
 
+#if defined(ANDROID)
+// Prefer Android's libbase definitions to our own.
+#include <android-base/macros.h>
+#endif  // defined(ANDROID)
+
 // Put this in the declarations for a class to be uncopyable.
+#if !defined(DISALLOW_COPY)
 #define DISALLOW_COPY(TypeName) \
   TypeName(const TypeName&) = delete
+#endif
 
 // Put this in the declarations for a class to be unassignable.
+#if !defined(DISALLOW_ASSIGN)
 #define DISALLOW_ASSIGN(TypeName) \
   void operator=(const TypeName&) = delete
+#endif
 
 // A macro to disallow the copy constructor and operator= functions
 // This should be used in the private: declarations for a class
@@ -50,8 +59,10 @@
 // This template function declaration is used in defining arraysize.
 // Note that the function doesn't need an implementation, as we only
 // use its type.
+#if !defined(arraysize)
 template <typename T, size_t N> char (&ArraySizeHelper(T (&array)[N]))[N];
 #define arraysize(array) (sizeof(ArraySizeHelper(array)))
+#endif
 
 // Used to explicitly mark the return value of a function as unused. If you are
 // really sure you don't want to do anything with the return value of a function
@@ -84,8 +95,10 @@
 // Use these to declare and define a static local variable (static T;) so that
 // it is leaked so that its destructors are not called at exit. If you need
 // thread-safe initialization, use base/lazy_instance.h instead.
+#if !defined(CR_DEFINE_STATIC_LOCAL)
 #define CR_DEFINE_STATIC_LOCAL(type, name, arguments) \
   static type& name = *new type arguments
+#endif
 
 }  // base