diff options
author | benl@chromium.org <benl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-07 16:39:46 +0000 |
---|---|---|
committer | benl@chromium.org <benl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-07 16:39:46 +0000 |
commit | fb66f9deac79dfe9e0eedc184705e824ae9144c3 (patch) | |
tree | 019f94cbb5f93009383182cffe8184009adcb6e6 /base | |
parent | ccf440ed5cf9f0a3368457c73a7496a900e03c06 (diff) | |
download | chromium_src-fb66f9deac79dfe9e0eedc184705e824ae9144c3.zip chromium_src-fb66f9deac79dfe9e0eedc184705e824ae9144c3.tar.gz chromium_src-fb66f9deac79dfe9e0eedc184705e824ae9144c3.tar.bz2 |
Added USE_GDK, set when either TOOLKIT_GTK or TOOLKIT_VIEWS is set but
not OS_WIN.
Added USE_X11. Set when OS_LINUX or OS_FREEBSD is set.
Added USE_BASE_DATA_PACK for base::DataPack usage, set for OS_MACOSX,
OS_LINUX or OS_FREEBSD.
Added USE_NSS for ... nss (for crypto). Windows and MacOS use
platform-specific libraries.
All of the above cause slightly odd formulations like:
#if defined(OS_WIN)
...
#elif defined(USE_BASE_DATA_PACK)
...
#endif
Possibly should also define USE_DLL_FOR_DATA, etc? Or something?
Wrapped various references to struct stat64 and stat64() to use struct
stat and stat() for FreeBSD - but a "man stat64" on Linux suggests
that we could do the same thing for at least Linux, too, and perhaps
eliminate the wrapper?
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25599 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/base.gyp | 43 | ||||
-rw-r--r-- | base/clipboard.h | 6 | ||||
-rw-r--r-- | base/clipboard_linux.cc | 5 | ||||
-rw-r--r-- | base/crypto/signature_verifier.h | 4 | ||||
-rw-r--r-- | base/file_util_posix.cc | 43 | ||||
-rw-r--r-- | base/gfx/native_widget_types.h | 16 | ||||
-rw-r--r-- | base/gfx/rect.h | 8 | ||||
-rw-r--r-- | base/keyboard_codes.h | 2 |
8 files changed, 78 insertions, 49 deletions
diff --git a/base/base.gyp b/base/base.gyp index 6636b53..d0a2209 100644 --- a/base/base.gyp +++ b/base/base.gyp @@ -366,7 +366,7 @@ 4244, 4554, 4018, 4102, ], 'conditions': [ - [ 'OS == "linux"', { + [ 'OS == "linux" or OS == "freebsd"', { 'variables' : { 'linux_use_tcmalloc%': 0, }, @@ -398,17 +398,21 @@ 'cflags': [ '-Wno-write-strings', ], - 'link_settings': { - 'libraries': [ - # We need rt for clock_gettime(). - '-lrt', - ], - }, + 'conditions': [ + [ 'OS == "linux"', { + 'link_settings': { + 'libraries': [ + # We need rt for clock_gettime(). + '-lrt', + ], + }, + }, + ] ], 'export_dependent_settings': [ '../build/linux/system.gyp:gtk', ], }, - { # else: OS != "linux" + { # else: OS != "linux" && OS != "freebsd" 'sources/': [ ['exclude', '/xdg_mime/'], ], @@ -437,6 +441,15 @@ ], }, ], + [ 'OS == "freebsd"', { + 'sources!': [ + 'directory_watcher_inotify.cc', + ], + 'sources': [ + 'directory_watcher_stub.cc', + ], + }, + ], [ 'OS == "mac"', { 'sources/': [ ['exclude', '_(linux|win|chromeos)\\.cc$'] ], 'sources!': [ @@ -544,7 +557,7 @@ 'base', ], 'conditions': [ - ['OS == "linux"', { + ['OS == "linux" or OS == "freebsd"', { 'dependencies': [ '../build/linux/system.gyp:gtk', ], @@ -554,7 +567,7 @@ 'gfx/native_theme.cc', ], }], - [ 'OS != "linux"', { 'sources!': [ + [ 'OS != "linux" and OS != "freebsd"', { 'sources!': [ 'gfx/gtk_native_view_id_manager.cc', 'gfx/gtk_util.cc', 'gfx/native_widget_types_gtk.cc', @@ -663,7 +676,7 @@ '../testing/gtest.gyp:gtest', ], 'conditions': [ - ['OS == "linux"', { + ['OS == "linux" or OS == "freebsd"', { 'sources!': [ 'file_version_info_unittest.cc', # Linux has an implementation of idle_timer, but it's unclear @@ -675,7 +688,7 @@ '../build/linux/system.gyp:gtk', '../build/linux/system.gyp:nss', ], - }, { # OS != "linux" + }, { # OS != "linux" and OS != "freebsd" 'sources!': [ 'message_pump_glib_unittest.cc', ] @@ -727,7 +740,7 @@ 'test_file_util_win.cc', ], 'conditions': [ - [ 'OS == "linux"', { + [ 'OS == "linux" or OS == "freebsd"', { 'sources/': [ ['exclude', '_(mac|win|chromeos)\\.cc$'], ['exclude', '\\.mm?$' ] ], 'conditions': [ @@ -766,7 +779,7 @@ ], }, 'conditions': [ - ['OS == "linux"', { + ['OS == "linux" or OS == "freebsd"', { 'dependencies': [ # Needed to handle the #include chain: # base/perf_test_suite.h @@ -795,7 +808,7 @@ }, ], }], - [ 'OS == "linux"', { + [ 'OS == "linux" or OS == "freebsd"', { 'targets': [ { 'target_name': 'linux_versioninfo', diff --git a/base/clipboard.h b/base/clipboard.h index de0f62d..bd4aefd 100644 --- a/base/clipboard.h +++ b/base/clipboard.h @@ -21,7 +21,7 @@ class FilePath; class Clipboard { public: typedef std::string FormatType; -#if defined(OS_LINUX) +#if defined(USE_X11) typedef struct _GtkClipboard GtkClipboard; typedef std::map<FormatType, std::pair<char*, size_t> > TargetMap; #endif @@ -167,7 +167,7 @@ class Clipboard { void WriteFiles(const char* file_data, size_t file_len); void WriteBitmap(const char* pixel_data, const char* size_data); -#if defined(OS_WIN) || defined(OS_LINUX) +#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_FREEBSD) // |format_name| is an ASCII string and should be NULL-terminated. // TODO(estade): port to mac. void WriteData(const char* format_name, size_t format_len, @@ -200,7 +200,7 @@ class Clipboard { // True if we can create a window. bool create_window_; -#elif defined(OS_LINUX) +#elif defined(USE_X11) // Data is stored in the |clipboard_data_| map until it is saved to the system // clipboard. The Store* functions save data to the |clipboard_data_| map. The // SetGtkClipboard function replaces whatever is on the system clipboard with diff --git a/base/clipboard_linux.cc b/base/clipboard_linux.cc index c259cea..6aedc91 100644 --- a/base/clipboard_linux.cc +++ b/base/clipboard_linux.cc @@ -119,7 +119,10 @@ void Clipboard::SetGtkClipboard() { int i = 0; for (Clipboard::TargetMap::iterator iter = clipboard_data_->begin(); iter != clipboard_data_->end(); ++iter, ++i) { - targets[i].target = strndup(iter->first.data(), iter->first.size()); + targets[i].target = static_cast<gchar*>(malloc(iter->first.size() + 1)); + memcpy(targets[i].target, iter->first.data(), iter->first.size()); + targets[i].target[iter->first.size()] = '\0'; + targets[i].flags = 0; targets[i].info = i; } diff --git a/base/crypto/signature_verifier.h b/base/crypto/signature_verifier.h index 18873e8..89bf565 100644 --- a/base/crypto/signature_verifier.h +++ b/base/crypto/signature_verifier.h @@ -7,7 +7,7 @@ #include "build/build_config.h" -#if defined(OS_LINUX) +#if defined(USE_NSS) #include <cryptoht.h> #elif defined(OS_MACOSX) #include <Security/cssm.h> @@ -81,7 +81,7 @@ class SignatureVerifier { std::vector<uint8> signature_; -#if defined(OS_LINUX) +#if defined(USE_NSS) VFYContext* vfy_context_; #elif defined(OS_MACOSX) std::vector<uint8> public_key_info_; diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc index 5bc3306..3715d21 100644 --- a/base/file_util_posix.cc +++ b/base/file_util_posix.cc @@ -82,6 +82,19 @@ class LocaleAwareComparator { namespace file_util { +#if defined(OS_FREEBSD) +typedef struct stat stat_wrapper_t; +static int CallStat(const char *path, stat_wrapper_t *sb) { + return stat(path, sb); +} +#else +typedef struct stat64 stat_wrapper_t; +static int CallStat(const char *path, stat_wrapper_t *sb) { + return stat64(path, sb); +} +#endif + + #if defined(GOOGLE_CHROME_BUILD) static const char* kTempFileName = "com.google.chrome.XXXXXX"; #else @@ -114,7 +127,7 @@ int CountFilesCreatedAfter(const FilePath& path, DIR* dir = opendir(path.value().c_str()); if (dir) { -#if !defined(OS_LINUX) && !defined(OS_MACOSX) +#if !defined(OS_LINUX) && !defined(OS_MACOSX) && !defined(OS_FREEBSD) #error Depending on the definition of struct dirent, additional space for \ pathname may be needed #endif @@ -125,8 +138,8 @@ int CountFilesCreatedAfter(const FilePath& path, (strcmp(ent->d_name, "..") == 0)) continue; - struct stat64 st; - int test = stat64(path.Append(ent->d_name).value().c_str(), &st); + stat_wrapper_t st; + int test = CallStat(path.Append(ent->d_name).value().c_str(), &st); if (test != 0) { LOG(ERROR) << "stat64 failed: " << strerror(errno); continue; @@ -160,8 +173,8 @@ int CountFilesCreatedAfter(const FilePath& path, // here. bool Delete(const FilePath& path, bool recursive) { const char* path_str = path.value().c_str(); - struct stat64 file_info; - int test = stat64(path_str, &file_info); + stat_wrapper_t file_info; + int test = CallStat(path_str, &file_info); if (test != 0) { // The Windows version defines this condition as success. bool ret = (errno == ENOENT || errno == ENOTDIR); @@ -302,19 +315,19 @@ bool CopyDirectory(const FilePath& from_path, } bool PathExists(const FilePath& path) { - struct stat64 file_info; - return (stat64(path.value().c_str(), &file_info) == 0); + stat_wrapper_t file_info; + return CallStat(path.value().c_str(), &file_info) == 0; } bool PathIsWritable(const FilePath& path) { FilePath test_path(path); - struct stat64 file_info; - if (stat64(test_path.value().c_str(), &file_info) != 0) { + stat_wrapper_t file_info; + if (CallStat(test_path.value().c_str(), &file_info) != 0) { // If the path doesn't exist, test the parent dir. test_path = test_path.DirName(); // If the parent dir doesn't exist, then return false (the path is not // directly writable). - if (stat64(test_path.value().c_str(), &file_info) != 0) + if (CallStat(test_path.value().c_str(), &file_info) != 0) return false; } if (S_IWOTH & file_info.st_mode) @@ -327,8 +340,8 @@ bool PathIsWritable(const FilePath& path) { } bool DirectoryExists(const FilePath& path) { - struct stat64 file_info; - if (stat64(path.value().c_str(), &file_info) == 0) + stat_wrapper_t file_info; + if (CallStat(path.value().c_str(), &file_info) == 0) return S_ISDIR(file_info.st_mode); return false; } @@ -460,8 +473,8 @@ bool CreateDirectory(const FilePath& full_path) { } bool GetFileInfo(const FilePath& file_path, FileInfo* results) { - struct stat64 file_info; - if (stat64(file_path.value().c_str(), &file_info) != 0) + stat_wrapper_t file_info; + if (CallStat(file_path.value().c_str(), &file_info) != 0) return false; results->is_directory = S_ISDIR(file_info.st_mode); results->size = file_info.st_size; @@ -637,7 +650,7 @@ bool FileEnumerator::ReadDirectory(std::vector<DirectoryEntryInfo>* entries, if (!dir) return false; -#if !defined(OS_LINUX) && !defined(OS_MACOSX) +#if !defined(OS_LINUX) && !defined(OS_MACOSX) && !defined(OS_FREEBSD) #error Depending on the definition of struct dirent, additional space for \ pathname may be needed #endif diff --git a/base/gfx/native_widget_types.h b/base/gfx/native_widget_types.h index 08bf76f..0ca82f2 100644 --- a/base/gfx/native_widget_types.h +++ b/base/gfx/native_widget_types.h @@ -46,7 +46,7 @@ class NSView; class NSWindow; class NSTextField; #endif // __OBJC__ -#elif defined(OS_LINUX) +#elif defined(USE_X11) typedef struct _GdkCursor GdkCursor; typedef struct _GtkWidget GtkWidget; typedef struct _GtkWindow GtkWindow; @@ -69,7 +69,7 @@ typedef NSTextField* NativeEditView; typedef CGContext* NativeDrawingContext; typedef void* NativeCursor; typedef void* NativeMenu; -#elif defined(OS_LINUX) +#elif defined(USE_X11) typedef GtkWidget* NativeView; typedef GtkWindow* NativeWindow; typedef GtkWidget* NativeEditView; @@ -102,15 +102,15 @@ static inline NativeView NativeViewFromId(NativeViewId id) { #define NativeViewFromId(x) NATIVE_VIEW_FROM_ID_NOT_AVAILABLE_ON_MAC -#elif defined(OS_LINUX) +#elif defined(USE_X11) // A NativeView on Linux is a GtkWidget*. However, we can't go directly from an // X window ID to a GtkWidget. Thus, functions which handle NativeViewIds from // the renderer have to use Xlib. This is fine since these functions are // generally performed on the BACKGROUND_X thread which can't use GTK anyway. -#define NativeViewFromId(x) NATIVE_VIEW_FROM_ID_NOT_AVAILIBLE_ON_LINUX +#define NativeViewFromId(x) NATIVE_VIEW_FROM_ID_NOT_AVAILIBLE_ON_X11 -#endif // defined(OS_LINUX) +#endif // defined(USE_X11) // Convert a NativeView to a NativeViewId. See the comments above // NativeViewFromId. @@ -118,10 +118,10 @@ static inline NativeView NativeViewFromId(NativeViewId id) { static inline NativeViewId IdFromNativeView(NativeView view) { return reinterpret_cast<NativeViewId>(view); } -#elif defined(OS_LINUX) +#elif defined(USE_X11) // Not inlined because it involves pulling too many headers. NativeViewId IdFromNativeView(NativeView view); -#endif // defined(OS_LINUX) +#endif // defined(USE_X11) // PluginWindowHandle is an abstraction wrapping "the types of windows @@ -129,7 +129,7 @@ NativeViewId IdFromNativeView(NativeView view); // window id. #if defined(OS_WIN) typedef HWND PluginWindowHandle; -#elif defined(OS_LINUX) +#elif defined(USE_X11) typedef unsigned long PluginWindowHandle; #else // On OS X we don't have windowed plugins. diff --git a/base/gfx/rect.h b/base/gfx/rect.h index f944dd7..414a348 100644 --- a/base/gfx/rect.h +++ b/base/gfx/rect.h @@ -19,7 +19,7 @@ #if defined(OS_WIN) typedef struct tagRECT RECT; -#elif defined(OS_LINUX) +#elif defined(USE_X11) typedef struct _GdkRectangle GdkRectangle; #endif @@ -34,7 +34,7 @@ class Rect { explicit Rect(const RECT& r); #elif defined(OS_MACOSX) explicit Rect(const CGRect& r); -#elif defined(OS_LINUX) +#elif defined(USE_X11) explicit Rect(const GdkRectangle& r); #endif Rect(const gfx::Point& origin, const gfx::Size& size); @@ -45,7 +45,7 @@ class Rect { Rect& operator=(const RECT& r); #elif defined(OS_MACOSX) Rect& operator=(const CGRect& r); -#elif defined(OS_LINUX) +#elif defined(USE_X11) Rect& operator=(const GdkRectangle& r); #endif @@ -97,7 +97,7 @@ class Rect { #if defined(OS_WIN) // Construct an equivalent Win32 RECT object. RECT ToRECT() const; -#elif defined(OS_LINUX) +#elif defined(USE_X11) GdkRectangle ToGdkRectangle() const; #elif defined(OS_MACOSX) // Construct an equivalent CoreGraphics object. diff --git a/base/keyboard_codes.h b/base/keyboard_codes.h index 3d8700f..49add77 100644 --- a/base/keyboard_codes.h +++ b/base/keyboard_codes.h @@ -9,7 +9,7 @@ #if defined(OS_WIN) #include "base/keyboard_codes_win.h" -#elif defined(OS_LINUX) +#elif defined(USE_X11) #include "base/keyboard_codes_linux.h" #elif defined(OS_MACOSX) #include "base/keyboard_codes_mac.h" |