diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-29 20:45:22 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-29 20:45:22 +0000 |
commit | 91d91fac1db8f2f163e4873bd93a65f4fada37ee (patch) | |
tree | a128f7ef2b816771bc0a69fa025350992c4ba5b9 /base | |
parent | 666f40f61545af4f8f52d964c341d01630a352cd (diff) | |
download | chromium_src-91d91fac1db8f2f163e4873bd93a65f4fada37ee.zip chromium_src-91d91fac1db8f2f163e4873bd93a65f4fada37ee.tar.gz chromium_src-91d91fac1db8f2f163e4873bd93a65f4fada37ee.tar.bz2 |
linux: components support for base/
This builds base_unittests using libbase as a component.
Review URL: http://codereview.chromium.org/6904109
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@83583 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/atomicops_internals_x86_gcc.h | 10 | ||||
-rw-r--r-- | base/base.gypi | 32 | ||||
-rw-r--r-- | base/base_api.h | 6 | ||||
-rw-r--r-- | base/file_descriptor_shuffle.h | 12 | ||||
-rw-r--r-- | base/file_util.h | 7 | ||||
-rw-r--r-- | base/logging.h | 4 | ||||
-rw-r--r-- | base/message_pump_libevent.h | 2 | ||||
-rw-r--r-- | base/nix/xdg_util.h | 18 | ||||
-rw-r--r-- | base/process_util.h | 28 | ||||
-rw-r--r-- | base/string16.h | 6 | ||||
-rw-r--r-- | base/synchronization/lock_impl.h | 3 | ||||
-rw-r--r-- | base/threading/worker_pool_posix.h | 2 |
12 files changed, 75 insertions, 55 deletions
diff --git a/base/atomicops_internals_x86_gcc.h b/base/atomicops_internals_x86_gcc.h index 08dc5aa..297727e 100644 --- a/base/atomicops_internals_x86_gcc.h +++ b/base/atomicops_internals_x86_gcc.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// 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. @@ -8,8 +8,11 @@ #define BASE_ATOMICOPS_INTERNALS_X86_GCC_H_ #pragma once +#include "base/base_api.h" + // This struct is not part of the public API of this module; clients may not -// use it. +// use it. (However, it's exported via BASE_API because clients implicitly +// do use it at link time by inlining these functions.) // Features of this x86. Values may not be correct before main() is run, // but are set conservatively. struct AtomicOps_x86CPUFeatureStruct { @@ -17,7 +20,8 @@ struct AtomicOps_x86CPUFeatureStruct { // after acquire compare-and-swap. bool has_sse2; // Processor has SSE2. }; -extern struct AtomicOps_x86CPUFeatureStruct AtomicOps_Internalx86CPUFeatures; +BASE_API extern struct AtomicOps_x86CPUFeatureStruct + AtomicOps_Internalx86CPUFeatures; #define ATOMICOPS_COMPILER_BARRIER() __asm__ __volatile__("" : : : "memory") diff --git a/base/base.gypi b/base/base.gypi index e8aeb50..51f50ed 100644 --- a/base/base.gypi +++ b/base/base.gypi @@ -527,25 +527,29 @@ 'win_util.cc', ], },], - [ 'OS=="win" and component=="shared_library"', { + [ 'component=="shared_library"', { 'defines': [ 'BASE_DLL', 'BASE_IMPLEMENTATION=1', ], - 'msvs_disabled_warnings': [ - 4251, - ], - 'sources!': [ - 'debug/debug_on_start_win.cc', + 'conditions': [ + ['OS=="win"', { + 'msvs_disabled_warnings': [ + 4251, + ], + 'sources!': [ + 'debug/debug_on_start_win.cc', + ], + 'direct_dependent_settings': { + 'defines': [ + 'BASE_DLL', + ], + 'msvs_disabled_warnings': [ + 4251, + ], + }, + }], ], - 'direct_dependent_settings': { - 'defines': [ - 'BASE_DLL', - ], - 'msvs_disabled_warnings': [ - 4251, - ], - }, }], ], 'sources': [ diff --git a/base/base_api.h b/base/base_api.h index 83b4bdf..0c23659 100644 --- a/base/base_api.h +++ b/base/base_api.h @@ -6,13 +6,17 @@ #define BASE_BASE_API_H_ #pragma once -#if defined(WIN32) && defined(BASE_DLL) +#if defined(BASE_DLL) +#if defined(WIN32) #if defined(BASE_IMPLEMENTATION) #define BASE_API __declspec(dllexport) #else #define BASE_API __declspec(dllimport) #endif // defined(BASE_IMPLEMENTATION) #else +#define BASE_API __attribute__((visibility("default"))) +#endif // defined(WIN32) +#else #define BASE_API #endif diff --git a/base/file_descriptor_shuffle.h b/base/file_descriptor_shuffle.h index e193035..0a649fa 100644 --- a/base/file_descriptor_shuffle.h +++ b/base/file_descriptor_shuffle.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// 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. @@ -24,6 +24,8 @@ #include <vector> +#include "base/base_api.h" + namespace base { // A Delegate which performs the actions required to perform an injective @@ -67,11 +69,11 @@ struct InjectionArc { typedef std::vector<InjectionArc> InjectiveMultimap; -bool PerformInjectiveMultimap(const InjectiveMultimap& map, - InjectionDelegate* delegate); +BASE_API bool PerformInjectiveMultimap(const InjectiveMultimap& map, + InjectionDelegate* delegate); -bool PerformInjectiveMultimapDestructive(InjectiveMultimap* map, - InjectionDelegate* delegate); +BASE_API bool PerformInjectiveMultimapDestructive(InjectiveMultimap* map, + InjectionDelegate* delegate); // This function will not call malloc but will mutate |map| static inline bool ShuffleFileDescriptors(InjectiveMultimap* map) { diff --git a/base/file_util.h b/base/file_util.h index 6fe9a3d..a187fee 100644 --- a/base/file_util.h +++ b/base/file_util.h @@ -180,15 +180,16 @@ BASE_API bool ReadFileToString(const FilePath& path, std::string* contents); // Read exactly |bytes| bytes from file descriptor |fd|, storing the result // in |buffer|. This function is protected against EINTR and partial reads. // Returns true iff |bytes| bytes have been successfuly read from |fd|. -bool ReadFromFD(int fd, char* buffer, size_t bytes); +BASE_API bool ReadFromFD(int fd, char* buffer, size_t bytes); // Creates a symbolic link at |symlink| pointing to |target|. Returns // false on failure. -bool CreateSymbolicLink(const FilePath& target, const FilePath& symlink); +BASE_API bool CreateSymbolicLink(const FilePath& target, + const FilePath& symlink); // Reads the given |symlink| and returns where it points to in |target|. // Returns false upon failure. -bool ReadSymbolicLink(const FilePath& symlink, FilePath* target); +BASE_API bool ReadSymbolicLink(const FilePath& symlink, FilePath* target); #endif // defined(OS_POSIX) #if defined(OS_WIN) diff --git a/base/logging.h b/base/logging.h index 1d094e3..54d6dfd 100644 --- a/base/logging.h +++ b/base/logging.h @@ -468,7 +468,7 @@ std::string* MakeCheckOpString(const t1& v1, const t2& v2, const char* names) { } // MSVC doesn't like complex extern templates and DLLs. -#if !defined(COMPILER_MSVC) +#if !defined(COMPILER_MSVC) && defined(BASE_DLL) // Commonly used instantiations of MakeCheckOpString<>. Explicitly instantiated // in logging.cc. extern template std::string* MakeCheckOpString<int, int>( @@ -842,7 +842,7 @@ class BASE_API Win32ErrorLogMessage { }; #elif defined(OS_POSIX) // Appends a formatted system message of the errno type -class ErrnoLogMessage { +class BASE_API ErrnoLogMessage { public: ErrnoLogMessage(const char* file, int line, diff --git a/base/message_pump_libevent.h b/base/message_pump_libevent.h index 2ade511..d58d902 100644 --- a/base/message_pump_libevent.h +++ b/base/message_pump_libevent.h @@ -19,7 +19,7 @@ namespace base { // Class to monitor sockets and issue callbacks when sockets are ready for I/O // TODO(dkegel): add support for background file IO somehow -class MessagePumpLibevent : public MessagePump { +class BASE_API MessagePumpLibevent : public MessagePump { public: class IOObserver { public: diff --git a/base/nix/xdg_util.h b/base/nix/xdg_util.h index 5e711d5..8420a9e 100644 --- a/base/nix/xdg_util.h +++ b/base/nix/xdg_util.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// 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. @@ -13,6 +13,8 @@ // net. We should have a net API to allow the embedder to specify the behavior // that it uses XDG for, and then move this file. +#include "base/base_api.h" + #ifdef nix #error asdf #endif @@ -30,14 +32,14 @@ namespace nix { // a directory path. |fallback_dir| is the directory relative to $HOME that we // use if |env_name| cannot be found or is empty. |fallback_dir| may be NULL. // Examples of |env_name| are XDG_CONFIG_HOME and XDG_DATA_HOME. -FilePath GetXDGDirectory(Environment* env, const char* env_name, - const char* fallback_dir); +BASE_API FilePath GetXDGDirectory(Environment* env, const char* env_name, + const char* fallback_dir); // Wrapper around xdg_user_dir_lookup() from src/base/third_party/xdg-user-dirs // This looks up "well known" user directories like the desktop and music // folder. Examples of |dir_name| are DESKTOP and MUSIC. -FilePath GetXDGUserDirectory(Environment* env, const char* dir_name, - const char* fallback_dir); +BASE_API FilePath GetXDGUserDirectory(Environment* env, const char* dir_name, + const char* fallback_dir); enum DesktopEnvironment { DESKTOP_ENVIRONMENT_OTHER, @@ -53,13 +55,13 @@ enum DesktopEnvironment { // of which desktop environment we're using. We use this to know when // to attempt to use preferences from the desktop environment -- // proxy settings, password manager, etc. -DesktopEnvironment GetDesktopEnvironment(Environment* env); +BASE_API DesktopEnvironment GetDesktopEnvironment(Environment* env); // Return a string representation of the given desktop environment. // May return NULL in the case of DESKTOP_ENVIRONMENT_OTHER. -const char* GetDesktopEnvironmentName(DesktopEnvironment env); +BASE_API const char* GetDesktopEnvironmentName(DesktopEnvironment env); // Convenience wrapper that calls GetDesktopEnvironment() first. -const char* GetDesktopEnvironmentName(Environment* env); +BASE_API const char* GetDesktopEnvironmentName(Environment* env); } // namespace nix } // namespace base diff --git a/base/process_util.h b/base/process_util.h index bdf9b9e..bb8f30e 100644 --- a/base/process_util.h +++ b/base/process_util.h @@ -170,7 +170,7 @@ FilePath GetProcessExecutablePath(ProcessHandle process); // Parse the data found in /proc/<pid>/stat and return the sum of the // CPU-related ticks. Returns -1 on parse error. // Exposed for testing. -int ParseProcStatCPU(const std::string& input); +BASE_API int ParseProcStatCPU(const std::string& input); static const char kAdjustOOMScoreSwitch[] = "--adjust-oom-score"; @@ -182,7 +182,7 @@ bool AdjustOOMScore(ProcessId process, int score); #if defined(OS_POSIX) // Returns the ID for the parent of the given process. -ProcessId GetParentProcessId(ProcessHandle process); +BASE_API ProcessId GetParentProcessId(ProcessHandle process); // Close all file descriptors, except those which are a destination in the // given multimap. Only call this function in a child process where you know @@ -264,17 +264,17 @@ BASE_API bool LaunchAppAsUser(UserTokenHandle token, // Note that the first argument in argv must point to the executable filename. // If the filename is not fully specified, PATH will be searched. typedef std::vector<std::pair<int, int> > file_handle_mapping_vector; -bool LaunchApp(const std::vector<std::string>& argv, - const file_handle_mapping_vector& fds_to_remap, - bool wait, ProcessHandle* process_handle); +BASE_API bool LaunchApp(const std::vector<std::string>& argv, + const file_handle_mapping_vector& fds_to_remap, + bool wait, ProcessHandle* process_handle); // Similar to the above, but also (un)set environment variables in child process // through |environ|. typedef std::vector<std::pair<std::string, std::string> > environment_vector; -bool LaunchApp(const std::vector<std::string>& argv, - const environment_vector& environ, - const file_handle_mapping_vector& fds_to_remap, - bool wait, ProcessHandle* process_handle); +BASE_API bool LaunchApp(const std::vector<std::string>& argv, + const environment_vector& environ, + const file_handle_mapping_vector& fds_to_remap, + bool wait, ProcessHandle* process_handle); // Similar to the above two methods, but starts the child process in a process // group of its own, instead of allowing it to inherit the parent's process @@ -291,8 +291,8 @@ bool LaunchAppInNewProcessGroup(const std::vector<std::string>& argv, // the second is empty, in which case the key-value is removed. // // The returned array is allocated using new[] and must be freed by the caller. -char** AlterEnvironment(const environment_vector& changes, - const char* const* const env); +BASE_API char** AlterEnvironment(const environment_vector& changes, + const char* const* const env); #endif // defined(OS_POSIX) // Executes the application specified by cl. This function delegates to one @@ -310,8 +310,8 @@ BASE_API bool GetAppOutput(const CommandLine& cl, std::string* output); // A restricted version of |GetAppOutput()| which (a) clears the environment, // and (b) stores at most |max_output| bytes; also, it doesn't search the path // for the command. -bool GetAppOutputRestricted(const CommandLine& cl, - std::string* output, size_t max_output); +BASE_API bool GetAppOutputRestricted(const CommandLine& cl, + std::string* output, size_t max_output); #endif // Used to filter processes by process ID. @@ -650,7 +650,7 @@ BASE_API void EnableTerminationOnHeapCorruption(); #if !defined(OS_WIN) // Turns on process termination if memory runs out. This is handled on Windows // inside RegisterInvalidParamHandler(). -void EnableTerminationOnOutOfMemory(); +BASE_API void EnableTerminationOnOutOfMemory(); #if defined(OS_MACOSX) // Exposed for testing. malloc_zone_t* GetPurgeableZone(); diff --git a/base/string16.h b/base/string16.h index 25e980c..be0c7d9 100644 --- a/base/string16.h +++ b/base/string16.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// 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. @@ -30,6 +30,7 @@ #include <stdio.h> #include <string> +#include "base/base_api.h" #include "base/basictypes.h" #if defined(WCHAR_T_IS_UTF16) @@ -168,7 +169,8 @@ extern template class std::basic_string<char16, base::string16_char_traits>; typedef std::basic_string<char16, base::string16_char_traits> string16; namespace base { -extern std::ostream& operator<<(std::ostream& out, const string16& str); +BASE_API extern std::ostream& operator<<(std::ostream& out, + const string16& str); } #endif // WCHAR_T_IS_UTF32 diff --git a/base/synchronization/lock_impl.h b/base/synchronization/lock_impl.h index 2994610..79bc147 100644 --- a/base/synchronization/lock_impl.h +++ b/base/synchronization/lock_impl.h @@ -14,6 +14,7 @@ #include <pthread.h> #endif +#include "base/base_api.h" #include "base/basictypes.h" namespace base { @@ -22,7 +23,7 @@ namespace internal { // This class implements the underlying platform-specific spin-lock mechanism // used for the Lock class. Most users should not use LockImpl directly, but // should instead use Lock. -class LockImpl { +class BASE_API LockImpl { public: #if defined(OS_WIN) typedef CRITICAL_SECTION OSLockType; diff --git a/base/threading/worker_pool_posix.h b/base/threading/worker_pool_posix.h index 701157a..9bb9eda 100644 --- a/base/threading/worker_pool_posix.h +++ b/base/threading/worker_pool_posix.h @@ -39,7 +39,7 @@ class Task; namespace base { -class PosixDynamicThreadPool +class BASE_API PosixDynamicThreadPool : public RefCountedThreadSafe<PosixDynamicThreadPool> { public: class PosixDynamicThreadPoolPeer; |