Skip to content

Commit

Permalink
More POSIX support for Chromium, consisting mostly of broadening ifde…
Browse files Browse the repository at this point in the history
…fs. This

patch cuts across modules, as there's only a handful necessary for each,
with the most in chrome/test/. ALSA is enabled on FreeBSD and Solaris, as
libasound has been ported to those two platforms, and I moved resolv.h in
host_resolver_proc.cc, because it depends on headers from sys_addrinfo.h on
FreeBSD.

Patch by ruben (chromium@hybridsource.org)

Review URL: http://codereview.chromium.org/6976055

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@87641 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
tony@chromium.org committed Jun 2, 2011
1 parent ef42e30 commit 23f7711
Show file tree
Hide file tree
Showing 28 changed files with 62 additions and 60 deletions.
2 changes: 1 addition & 1 deletion base/debug/leak_annotations.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include "build/build_config.h"

#if defined(OS_LINUX) && defined(USE_HEAPCHECKER)
#if defined(OS_POSIX) && !defined(OS_MACOSX) && defined(USE_HEAPCHECKER)

#include "third_party/tcmalloc/chromium/src/google/heap-checker.h"

Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/ui/tab_contents/tab_contents_wrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ TabContentsWrapper::TabContentsWrapper(TabContents* contents)
NotificationService::AllSources());
registrar_.Add(this, NotificationType::USER_STYLE_SHEET_UPDATED,
NotificationService::AllSources());
#if defined(OS_LINUX)
#if defined(OS_POSIX) && !defined(OS_MACOSX)
registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED,
NotificationService::AllSources());
#endif
Expand Down Expand Up @@ -413,7 +413,7 @@ void TabContentsWrapper::Observe(NotificationType type,
case NotificationType::USER_STYLE_SHEET_UPDATED:
UpdateWebPreferences();
break;
#if defined(OS_LINUX)
#if defined(OS_POSIX) && !defined(OS_MACOSX)
case NotificationType::BROWSER_THEME_CHANGED: {
UpdateRendererPreferences();
break;
Expand Down
2 changes: 1 addition & 1 deletion chrome/chrome_tests.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -2973,7 +2973,7 @@
'../third_party/WebKit/Source/WebCore/WebCore.gyp/WebCore.gyp:webcore',
],
}],
['OS=="linux"', {
['toolkit_uses_gtk == 1', {
'dependencies': [
'../build/linux/system.gyp:gtk',
'../tools/xdisplaycheck/xdisplaycheck.gyp:xdisplaycheck',
Expand Down
16 changes: 8 additions & 8 deletions chrome/common/chrome_constants.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,27 @@ const char kChromeVersionEnvVar[] = "CHROME_VERSION";
#if defined(OS_WIN)
const FilePath::CharType kBrowserProcessExecutableName[] = FPL("chrome.exe");
const FilePath::CharType kHelperProcessExecutableName[] = FPL("chrome.exe");
#elif defined(OS_LINUX)
const FilePath::CharType kBrowserProcessExecutableName[] = FPL("chrome");
// Helper processes end up with a name of "exe" due to execing via
// /proc/self/exe. See bug 22703.
const FilePath::CharType kHelperProcessExecutableName[] = FPL("exe");
#elif defined(OS_MACOSX)
const FilePath::CharType kBrowserProcessExecutableName[] = FPL(PRODUCT_STRING);
const FilePath::CharType kHelperProcessExecutableName[] =
FPL(PRODUCT_STRING " Helper");
#elif defined(OS_POSIX)
const FilePath::CharType kBrowserProcessExecutableName[] = FPL("chrome");
// Helper processes end up with a name of "exe" due to execing via
// /proc/self/exe. See bug 22703.
const FilePath::CharType kHelperProcessExecutableName[] = FPL("exe");
#endif // OS_*
#if defined(OS_WIN)
const FilePath::CharType kBrowserProcessExecutablePath[] = FPL("chrome.exe");
const FilePath::CharType kHelperProcessExecutablePath[] = FPL("chrome.exe");
#elif defined(OS_LINUX)
const FilePath::CharType kBrowserProcessExecutablePath[] = FPL("chrome");
const FilePath::CharType kHelperProcessExecutablePath[] = FPL("chrome");
#elif defined(OS_MACOSX)
const FilePath::CharType kBrowserProcessExecutablePath[] =
FPL(PRODUCT_STRING ".app/Contents/MacOS/" PRODUCT_STRING);
const FilePath::CharType kHelperProcessExecutablePath[] =
FPL(PRODUCT_STRING " Helper.app/Contents/MacOS/" PRODUCT_STRING " Helper");
#elif defined(OS_POSIX)
const FilePath::CharType kBrowserProcessExecutablePath[] = FPL("chrome");
const FilePath::CharType kHelperProcessExecutablePath[] = FPL("chrome");
#endif // OS_*
#if defined(OS_MACOSX)
const FilePath::CharType kFrameworkName[] =
Expand Down
2 changes: 1 addition & 1 deletion chrome/test/automated_ui_tests/automated_ui_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ std::string GetChromeRevision() {
file_info.reset(
FileVersionInfo::CreateFileVersionInfo(FilePath(kChromeDll)));
last_change = WideToASCII(file_info->last_change());
#elif defined(OS_LINUX) || defined(OS_MACOSX)
#elif defined(OS_POSIX)
chrome::VersionInfo version_info;
last_change = version_info.LastChange();
#endif // !defined(OS_WIN)
Expand Down
4 changes: 2 additions & 2 deletions chrome/test/automation/automation_proxy_uitest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1382,7 +1382,7 @@ TEST_F(ExternalTabUITestPopupEnabled, MAYBE_UserGestureTargetBlank) {
#endif // defined(OS_WIN)

// TODO(port): Need to port autocomplete_edit_proxy.* first.
#if defined(OS_WIN) || defined(OS_LINUX)
#if !defined(OS_MACOSX)
TEST_F(AutomationProxyTest, AutocompleteGetSetText) {
scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
ASSERT_TRUE(browser.get());
Expand Down Expand Up @@ -1426,7 +1426,7 @@ TEST_F(AutomationProxyTest, AutocompleteParallelProxy) {
EXPECT_EQ(text_to_set2, actual_text2);
}

#endif // defined(OS_WIN) || defined(OS_LINUX)
#endif // !defined(OS_MACOSX)

#if defined(OS_MACOSX)
// Disabled, http://crbug.com/48601.
Expand Down
8 changes: 4 additions & 4 deletions chrome/test/chrome_process_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ ChromeProcessList GetRunningChromeProcesses(base::ProcessId browser_pid) {
result.push_back(process_entry->pid());
}

#if defined(OS_LINUX)
// On Linux we might be running with a zygote process for the renderers.
#if defined(OS_POSIX) && !defined(OS_MACOSX)
// On Unix we might be running with a zygote process for the renderers.
// Because of that we sweep the list of processes again and pick those which
// are children of one of the processes that we've already seen.
{
Expand All @@ -72,9 +72,9 @@ ChromeProcessList GetRunningChromeProcesses(base::ProcessId browser_pid) {
while (const base::ProcessEntry* process_entry = it.NextProcessEntry())
result.push_back(process_entry->pid());
}
#endif // defined(OS_LINUX)
#endif // defined(OS_POSIX) && !defined(OS_MACOSX)

#if defined(OS_LINUX) || defined(OS_MACOSX)
#if defined(OS_POSIX)
// On Mac OS X we run the subprocesses with a different bundle, and
// on Linux via /proc/self/exe, so they end up with a different
// name. We must collect them in a second pass.
Expand Down
2 changes: 1 addition & 1 deletion chrome/test/plugin/pdf_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ IN_PROC_BROWSER_TEST_F(PDFBrowserTest, FLAKY_SLOW_Loading) {
std::string filename = file_path.BaseName().MaybeAsASCII();
ASSERT_FALSE(filename.empty());

#if defined(OS_MACOSX) || defined(OS_LINUX)
#if defined(OS_POSIX)
if (filename == "sample.pdf")
continue; // Crashes on Mac and Linux. http://crbug.com/63549
#endif
Expand Down
2 changes: 1 addition & 1 deletion chrome/test/reliability/page_load_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class PageLoadTest : public UITest {
file_info.reset(
FileVersionInfo::CreateFileVersionInfo(FilePath(kChromeDll)));
last_change = WideToASCII(file_info->last_change());
#elif defined(OS_LINUX) || defined(OS_MACOSX)
#elif defined(OS_POSIX)
// TODO(fmeawad): On Mac, the version retrieved here belongs to the test
// module and not the chrome binary, need to be changed to chrome binary
// instead.
Expand Down
2 changes: 1 addition & 1 deletion chrome/test/startup/feature_startup_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ TEST_F(NewTabUIStartupTest, FLAKY_NewTabTimingTestsCold) {
RunNewTabTimingTest();
}

#if defined(OS_LINUX)
#if defined(TOOLKIT_USES_GTK)
TEST_F(NewTabUIStartupTest, GtkThemeCold) {
RunStartupTest("tab_gtk_theme_cold", false /* cold */,
false /* not important */,
Expand Down
2 changes: 1 addition & 1 deletion chrome/test/startup/startup_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ TEST_F(StartupTest, PerfComplexTheme) {
ProxyLauncher::COMPLEX_THEME, 0, 0);
}

#if defined(OS_LINUX)
#if defined(TOOLKIT_USES_GTK)
TEST_F(StartupTest, PerfGtkTheme) {
RunStartupTest("warm", "gtk-theme", WARM, NOT_IMPORTANT,
ProxyLauncher::NATIVE_THEME, 0, 0);
Expand Down
2 changes: 1 addition & 1 deletion chrome/test/test_launcher_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ bool OverrideUserDataDir(const FilePath& user_data_dir) {
// This matches what is done in ChromeMain().
success = PathService::Override(chrome::DIR_USER_DATA, user_data_dir);

#if defined(OS_LINUX)
#if defined(OS_POSIX) && !defined(OS_MACOSX)
// Make sure the cache directory is inside our clear profile. Otherwise
// the cache may contain data from earlier tests that could break the
// current test.
Expand Down
4 changes: 2 additions & 2 deletions chrome/test/ui/history_uitest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ TEST_F(HistoryTester, VerifyHistoryLength3) {
kTestCompleteSuccess, TestTimeouts::action_max_timeout_ms());
}

#if defined(OS_WIN) || defined(OS_LINUX)
#if !defined(OS_MACOSX)
TEST_F(HistoryTester, ConsiderRedirectAfterGestureAsUserInitiated) {
// Test the history length for the following page transition.
//
Expand Down Expand Up @@ -116,7 +116,7 @@ TEST_F(HistoryTester, ConsiderRedirectAfterGestureAsUserInitiated) {
WaitForFinish("History_Length_Test_12", "1", url, kTestCompleteCookie,
kTestCompleteSuccess, TestTimeouts::action_max_timeout_ms());
}
#endif // defined(OS_WIN) || defined(OS_LINUX)
#endif // !defined(OS_MACOSX)

TEST_F(HistoryTester, ConsiderSlowRedirectAsUserInitiated) {
// Test the history length for the following page transition.
Expand Down
2 changes: 1 addition & 1 deletion chrome/test/ui_test_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ void RunMessageLoop() {
#if defined(TOOLKIT_VIEWS)
views::AcceleratorHandler handler;
loop->Run(&handler);
#elif defined(OS_LINUX)
#elif defined(OS_POSIX) && !defined(OS_MACOSX)
loop->Run(NULL);
#else
loop->Run();
Expand Down
2 changes: 1 addition & 1 deletion gpu/command_buffer/service/gles2_cmd_decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2629,7 +2629,7 @@ void GLES2DecoderImpl::DoCopyTextureToParentTextureCHROMIUM(
}

void GLES2DecoderImpl::DoResizeCHROMIUM(GLuint width, GLuint height) {
#if defined(OS_LINUX)
#if defined(OS_POSIX) && !defined(OS_MACOSX)
// Make sure that we are done drawing to the back buffer before resizing.
glFinish();
#endif
Expand Down
4 changes: 2 additions & 2 deletions gpu/demos/demos.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# also be compiled with -fPIC flag. Setting GYP_DEFINES="linux_fpic=1"
# compiles everything with -fPIC. Disable pepper demos on linux/x64
# unless linux_fpic is 1.
['OS=="linux" and (target_arch=="x64" or target_arch=="arm") and linux_fpic!=1', {
['os_posix == 1 and OS != "mac" and (target_arch=="x64" or target_arch=="arm") and linux_fpic!=1', {
'enable_pepper_demos%': 0,
}, {
'enable_pepper_demos%': 1,
Expand Down Expand Up @@ -107,7 +107,7 @@
],
},
'conditions': [
['OS=="linux"', {
['os_posix == 1 and OS != "mac"', {
# -gstabs, used in the official builds, causes an ICE. Remove it.
'cflags!': ['-gstabs'],
}],
Expand Down
8 changes: 4 additions & 4 deletions gpu/demos/framework/main_exe.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@
#include "gpu/demos/framework/window.h"
#include "ui/gfx/gl/gl_surface.h"

#if defined(OS_LINUX)
#if defined(TOOLKIT_USES_GTK)
#include <gtk/gtk.h>
#endif // OS_LINUX
#endif // TOOLKIT_USES_GTK

namespace {
static const int kWindowWidth = 512;
static const int kWindowHeight = 512;
} // namespace.

int main(int argc, char** argv) {
#if defined(OS_LINUX)
#if defined(TOOLKIT_USES_GTK)
gtk_init(&argc, &argv);
#endif // OS_LINUX
#endif // TOOLKIT_USES_GTK

// AtExitManager is used by singleton classes to delete themselves when
// the program terminates.
Expand Down
4 changes: 2 additions & 2 deletions gpu/gles2_conform_support/gles2_conform_support.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
'egl_native',
],
'conditions': [
['OS=="linux"', {
['toolkit_uses_gtk == 1', {
'dependencies': ['../../build/linux/system.gyp:gtk'],
}],
],
Expand All @@ -76,7 +76,7 @@
'<(DEPTH)/third_party/expat/expat.gyp:expat',
],
'conditions': [
['OS=="linux"', {
['toolkit_uses_gtk == 1', {
'dependencies': ['../../build/linux/system.gyp:gtk'],
}],
],
Expand Down
8 changes: 4 additions & 4 deletions gpu/gles2_conform_support/native/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
#include "base/at_exit.h"
#include "base/message_loop.h"

#if defined(OS_LINUX)
#if defined(TOOLKIT_USES_GTK)
#include <gtk/gtk.h>
#endif // OS_LINUX
#endif

extern "C" {
#if defined(GLES2_CONFORM_SUPPORT_ONLY)
Expand All @@ -18,9 +18,9 @@ extern "C" {
}

int main(int argc, char *argv[]) {
#if defined(OS_LINUX)
#if defined(TOOLKIT_USES_GTK)
gtk_init(&argc, &argv);
#endif // OS_LINUX
#endif

base::AtExitManager at_exit;
MessageLoopForUI message_loop;
Expand Down
4 changes: 2 additions & 2 deletions ipc/sync_socket_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/multiprocess_func_list.h"

#if defined(OS_LINUX) || defined(OS_MACOSX)
#if defined(OS_POSIX)
#include "base/file_descriptor_posix.h"
#endif // defined(OS_LINUX) || defined(OS_MACOSX)
#endif

enum IPCMessageIds {
UNUSED_IPC_TYPE,
Expand Down
2 changes: 1 addition & 1 deletion media/base/media_switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace switches {

#if defined(OS_LINUX)
#if defined(OS_LINUX) || defined(OS_FREEBSD) || defined(OS_SOLARIS)
// The Alsa device to use when opening an audio stream.
const char kAlsaOutputDevice[] = "alsa-output-device";
// The Alsa device to use when opening an audio input stream.
Expand Down
2 changes: 1 addition & 1 deletion media/base/media_switches.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace switches {

#if defined(OS_LINUX)
#if defined(OS_LINUX) || defined(OS_FREEBSD) || defined(OS_SOLARIS)
extern const char kAlsaOutputDevice[];
extern const char kAlsaInputDevice[];
#endif
Expand Down
4 changes: 2 additions & 2 deletions media/tools/shader_bench/shader_bench.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "ui/gfx/gl/gl_surface.h"
#include "ui/gfx/native_widget_types.h"

#if defined(OS_LINUX)
#if defined(TOOLKIT_USES_GTK)
#include <gtk/gtk.h>
#endif

Expand Down Expand Up @@ -98,7 +98,7 @@ int main(int argc, char** argv) {
}

// Read command line.
#if defined(OS_LINUX)
#if defined(TOOLKIT_USES_GTK)
gtk_init(&argc, &argv);
#endif
CommandLine::Init(argc, argv);
Expand Down
8 changes: 5 additions & 3 deletions net/base/host_resolver_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,15 @@ HostCache* CreateDefaultCache() {
std::vector<int> GetAllGetAddrinfoOSErrors() {
int os_errors[] = {
#if defined(OS_POSIX)
#if !defined(OS_FREEBSD)
EAI_ADDRFAMILY,
EAI_NODATA,
#endif
EAI_AGAIN,
EAI_BADFLAGS,
EAI_FAIL,
EAI_FAMILY,
EAI_MEMORY,
EAI_NODATA,
EAI_NONAME,
EAI_SERVICE,
EAI_SOCKTYPE,
Expand Down Expand Up @@ -1058,7 +1060,7 @@ HostResolverImpl::HostResolverImpl(
#if defined(OS_WIN)
EnsureWinsockInit();
#endif
#if defined(OS_LINUX)
#if defined(OS_POSIX) && !defined(OS_MACOSX)
if (HaveOnlyLoopbackAddresses())
additional_resolver_flags_ |= HOST_RESOLVER_LOOPBACK_ONLY;
#endif
Expand Down Expand Up @@ -1598,7 +1600,7 @@ void HostResolverImpl::OnIPAddressChanged() {
ipv6_probe_job_ = new IPv6ProbeJob(this);
ipv6_probe_job_->Start();
}
#if defined(OS_LINUX)
#if defined(OS_POSIX) && !defined(OS_MACOSX)
if (HaveOnlyLoopbackAddresses()) {
additional_resolver_flags_ |= HOST_RESOLVER_LOOPBACK_ONLY;
} else {
Expand Down
10 changes: 5 additions & 5 deletions net/base/host_resolver_proc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@

#include "build/build_config.h"

#if defined(OS_POSIX) && !defined(OS_MACOSX)
#include <resolv.h>
#endif

#include "base/logging.h"
#include "net/base/address_list.h"
#include "net/base/dns_reload_timer.h"
#include "net/base/net_errors.h"
#include "net/base/sys_addrinfo.h"

#if defined(OS_POSIX) && !defined(OS_MACOSX)
#include <resolv.h>
#endif

namespace net {

namespace {
Expand Down Expand Up @@ -248,7 +248,7 @@ int SystemHostResolverProc(const std::string& host,
#if defined(OS_WIN)
if (err != WSAHOST_NOT_FOUND && err != WSANO_DATA)
return ERR_NAME_RESOLUTION_FAILED;
#elif defined(OS_POSIX)
#elif defined(OS_POSIX) && !defined(OS_FREEBSD)
if (err != EAI_NONAME && err != EAI_NODATA)
return ERR_NAME_RESOLUTION_FAILED;
#endif
Expand Down
Loading

0 comments on commit 23f7711

Please sign in to comment.