summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authortony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-31 22:38:29 +0000
committertony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-31 22:38:29 +0000
commite63c4d7351d7ced6667d8d61a9971587c9779e5e (patch)
treebfc7bce4be941eb85955089dfd7d95312c4fec0d /content
parentb7b678f549e7a622615e6488d8e36fe998f85aec (diff)
downloadchromium_src-e63c4d7351d7ced6667d8d61a9971587c9779e5e.zip
chromium_src-e63c4d7351d7ced6667d8d61a9971587c9779e5e.tar.gz
chromium_src-e63c4d7351d7ced6667d8d61a9971587c9779e5e.tar.bz2
Replace OS_LINUX ifdefs with OS_POSIX & !OS_MACOSX, TOOLKIT_USES_GTK, or
USE_X11 where possible. An earlier version of this patch was used to build Chromium on FreeBSD, OpenBSD, and Solaris. Patch by ruben (chromium@hybridsource.org) Review URL: http://codereview.chromium.org/7006006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@87382 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/browser/child_process_launcher.cc34
-rw-r--r--content/browser/content_browser_client.cc2
-rw-r--r--content/browser/content_browser_client.h2
-rw-r--r--content/browser/gpu/gpu_process_host.cc22
-rw-r--r--content/browser/gpu/gpu_process_host.h2
-rw-r--r--content/browser/gpu/gpu_process_host_ui_shim.cc10
-rw-r--r--content/browser/gpu/gpu_process_host_ui_shim.h2
-rw-r--r--content/browser/plugin_service.cc24
-rw-r--r--content/browser/plugin_service.h6
-rw-r--r--content/browser/renderer_host/render_sandbox_host_linux.cc7
-rw-r--r--content/browser/renderer_host/render_widget_host_unittest.cc2
-rw-r--r--content/browser/zygote_host_linux.cc7
-rw-r--r--content/browser/zygote_main_linux.cc25
-rw-r--r--content/common/gpu/gpu_channel_manager.cc2
-rw-r--r--content/common/gpu/gpu_command_buffer_stub.cc4
-rw-r--r--content/common/gpu/gpu_messages.h4
-rw-r--r--content/common/gpu/x_util.h4
-rw-r--r--content/common/native_web_keyboard_event.h2
-rw-r--r--content/common/native_web_keyboard_event_views.cc4
-rw-r--r--content/gpu/gpu_child_thread.cc2
-rw-r--r--content/plugin/plugin_thread.cc4
-rw-r--r--content/ppapi_plugin/ppapi_webkitclient_impl.cc6
-rw-r--r--content/renderer/render_thread.cc2
-rw-r--r--content/renderer/render_view.h2
-rw-r--r--content/renderer/render_view_browsertest.cc4
-rw-r--r--content/renderer/renderer_main.cc4
-rw-r--r--content/renderer/renderer_webkitclient_impl.cc60
-rw-r--r--content/worker/worker_uitest.cc4
28 files changed, 133 insertions, 120 deletions
diff --git a/content/browser/child_process_launcher.cc b/content/browser/child_process_launcher.cc
index 6955ec3..d8618e2 100644
--- a/content/browser/child_process_launcher.cc
+++ b/content/browser/child_process_launcher.cc
@@ -21,16 +21,14 @@
#if defined(OS_WIN)
#include "base/file_path.h"
#include "content/common/sandbox_policy.h"
-#elif defined(OS_LINUX)
+#elif defined(OS_MACOSX)
+#include "chrome/browser/mach_broker_mac.h"
+#elif defined(OS_POSIX)
#include "base/memory/singleton.h"
#include "content/browser/zygote_host_linux.h"
#include "content/browser/renderer_host/render_sandbox_host_linux.h"
#endif
-#if defined(OS_MACOSX)
-#include "chrome/browser/mach_broker_mac.h"
-#endif
-
#if defined(OS_POSIX)
#include "base/global_descriptors_posix.h"
#endif
@@ -46,7 +44,7 @@ class ChildProcessLauncher::Context
client_thread_id_(BrowserThread::UI),
starting_(true),
terminate_child_on_shutdown_(true)
-#if defined(OS_LINUX)
+#if defined(OS_POSIX) && !defined(OS_MACOSX)
, zygote_(false)
#endif
{
@@ -115,7 +113,7 @@ class ChildProcessLauncher::Context
handle = sandbox::StartProcessWithAccess(cmd_line, exposed_dir);
#elif defined(OS_POSIX)
-#if defined(OS_LINUX)
+#if defined(OS_POSIX) && !defined(OS_MACOSX)
// On Linux, we need to add some extra file descriptors for crash handling.
std::string process_type =
cmd_line->GetSwitchValueASCII(switches::kProcessType);
@@ -139,7 +137,7 @@ class ChildProcessLauncher::Context
ipcfd,
kPrimaryIPCChannel + base::GlobalDescriptors::kBaseDescriptor));
-#if defined(OS_LINUX)
+#if defined(OS_POSIX) && !defined(OS_MACOSX)
if (crash_signal_fd >= 0) {
fds_to_map.push_back(std::make_pair(
crash_signal_fd,
@@ -152,7 +150,7 @@ class ChildProcessLauncher::Context
sandbox_fd,
kSandboxIPCChannel + base::GlobalDescriptors::kBaseDescriptor));
}
-#endif // defined(OS_LINUX)
+#endif // defined(OS_POSIX) && !defined(OS_MACOSX)
bool launched = false;
#if defined(OS_MACOSX)
@@ -188,20 +186,20 @@ class ChildProcessLauncher::Context
NewRunnableMethod(
this,
&ChildProcessLauncher::Context::Notify,
-#if defined(OS_LINUX)
+#if defined(OS_POSIX) && !defined(OS_MACOSX)
use_zygote,
#endif
handle));
}
void Notify(
-#if defined(OS_LINUX)
+#if defined(OS_POSIX) && !defined(OS_MACOSX)
bool zygote,
#endif
base::ProcessHandle handle) {
starting_ = false;
process_.set_handle(handle);
-#if defined(OS_LINUX)
+#if defined(OS_POSIX) && !defined(OS_MACOSX)
zygote_ = zygote;
#endif
if (client_) {
@@ -224,7 +222,7 @@ class ChildProcessLauncher::Context
BrowserThread::PROCESS_LAUNCHER, FROM_HERE,
NewRunnableFunction(
&ChildProcessLauncher::Context::TerminateInternal,
-#if defined(OS_LINUX)
+#if defined(OS_POSIX) && !defined(OS_MACOSX)
zygote_,
#endif
process_.handle()));
@@ -244,7 +242,7 @@ class ChildProcessLauncher::Context
#endif
static void TerminateInternal(
-#if defined(OS_LINUX)
+#if defined(OS_POSIX) && !defined(OS_MACOSX)
bool zygote,
#endif
base::ProcessHandle handle) {
@@ -254,13 +252,13 @@ class ChildProcessLauncher::Context
process.Terminate(ResultCodes::NORMAL_EXIT);
// On POSIX, we must additionally reap the child.
#if defined(OS_POSIX)
-#if defined(OS_LINUX)
+#if !defined(OS_MACOSX)
if (zygote) {
// If the renderer was created via a zygote, we have to proxy the reaping
// through the zygote process.
ZygoteHost::GetInstance()->EnsureProcessTerminated(handle);
} else
-#endif // OS_LINUX
+#endif // !OS_MACOSX
{
ProcessWatcher::EnsureProcessTerminated(handle);
}
@@ -280,7 +278,7 @@ class ChildProcessLauncher::Context
// shutdown. Default behavior is to terminate the child.
bool terminate_child_on_shutdown_;
-#if defined(OS_LINUX)
+#if defined(OS_POSIX) && !defined(OS_MACOSX)
bool zygote_;
#endif
};
@@ -326,7 +324,7 @@ base::TerminationStatus ChildProcessLauncher::GetChildTerminationStatus(
int* exit_code) {
base::TerminationStatus status;
base::ProcessHandle handle = context_->process_.handle();
-#if defined(OS_LINUX)
+#if defined(OS_POSIX) && !defined(OS_MACOSX)
if (context_->zygote_) {
status = ZygoteHost::GetInstance()->GetTerminationStatus(handle, exit_code);
} else
diff --git a/content/browser/content_browser_client.cc b/content/browser/content_browser_client.cc
index 121991e..0541735 100644
--- a/content/browser/content_browser_client.cc
+++ b/content/browser/content_browser_client.cc
@@ -87,7 +87,7 @@ QuotaPermissionContext* ContentBrowserClient::CreateQuotaPermissionContext() {
void ContentBrowserClient::RevealFolderInOS(const FilePath& path) {
}
-#if defined(OS_LINUX)
+#if defined(OS_POSIX) && !defined(OS_MACOSX)
int ContentBrowserClient::GetCrashSignalFD(const std::string& process_type) {
return -1;
}
diff --git a/content/browser/content_browser_client.h b/content/browser/content_browser_client.h
index 47f26105..169d4d6 100644
--- a/content/browser/content_browser_client.h
+++ b/content/browser/content_browser_client.h
@@ -109,7 +109,7 @@ class ContentBrowserClient {
// Shows the given path using the OS file manager.
virtual void RevealFolderInOS(const FilePath& path);
-#if defined(OS_LINUX)
+#if defined(OS_POSIX) && !defined(OS_MACOSX)
// Can return an optional fd for crash handling, otherwise returns -1.
virtual int GetCrashSignalFD(const std::string& process_type);
#endif
diff --git a/content/browser/gpu/gpu_process_host.cc b/content/browser/gpu/gpu_process_host.cc
index 343d459..6778095 100644
--- a/content/browser/gpu/gpu_process_host.cc
+++ b/content/browser/gpu/gpu_process_host.cc
@@ -27,9 +27,9 @@
#include "ui/gfx/gl/gl_context.h"
#include "ui/gfx/gl/gl_switches.h"
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_USES_GTK)
#include "ui/gfx/gtk_native_view_id_manager.h"
-#endif // defined(OS_LINUX)
+#endif
namespace {
@@ -54,7 +54,7 @@ static const int kGpuMaxCrashCount = 3;
int g_last_host_id = 0;
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_USES_GTK)
class ReleasePermanentXIDDispatcher: public Task {
public:
@@ -90,7 +90,7 @@ void SendGpuProcessMessage(int renderer_id,
} // anonymous namespace
-#if defined(OS_LINUX) && !defined(TOUCH_UI)
+#if defined(TOOLKIT_USES_GTK) && !defined(TOUCH_UI)
// Used to put a lock on surfaces so that the window to which the GPU
// process is drawing to doesn't disappear while it is drawing when
// a tab is closed.
@@ -115,7 +115,7 @@ GpuProcessHost::SurfaceRef::~SurfaceRef() {
FROM_HERE,
new ReleasePermanentXIDDispatcher(surface_));
}
-#endif // defined(OS_LINUX) && !defined(TOUCH_UI)
+#endif // defined(TOOLKIT_USES_GTK) && !defined(TOUCH_UI)
// This class creates a GPU thread (instead of a GPU process), when running
// with --in-process-gpu or --single-process.
@@ -378,7 +378,7 @@ void GpuProcessHost::CreateViewCommandBuffer(
DCHECK(CalledOnValidThread());
linked_ptr<CreateCommandBufferCallback> wrapped_callback(callback);
-#if defined(OS_LINUX) && !defined(TOUCH_UI)
+#if defined(TOOLKIT_USES_GTK) && !defined(TOUCH_UI)
ViewID view_id(renderer_id, render_view_id);
// There should only be one such command buffer (for the compositor). In
@@ -391,16 +391,16 @@ void GpuProcessHost::CreateViewCommandBuffer(
surface_ref = (*it).second;
else
surface_ref.reset(new SurfaceRef(compositing_surface));
-#endif // defined(OS_LINUX) && defined(TOUCH_UI)
+#endif // defined(TOOLKIT_USES_GTK) && defined(TOUCH_UI)
if (compositing_surface != gfx::kNullPluginWindow &&
Send(new GpuMsg_CreateViewCommandBuffer(
compositing_surface, render_view_id, renderer_id, init_params))) {
create_command_buffer_requests_.push(wrapped_callback);
-#if defined(OS_LINUX) && !defined(TOUCH_UI)
+#if defined(TOOLKIT_USES_GTK) && !defined(TOUCH_UI)
surface_refs_.insert(std::pair<ViewID, linked_ptr<SurfaceRef> >(
view_id, surface_ref));
-#endif // defined(OS_LINUX) && !defined(TOUCH_UI)
+#endif
} else {
CreateCommandBufferError(wrapped_callback.release(), MSG_ROUTING_NONE);
}
@@ -459,12 +459,12 @@ void GpuProcessHost::OnCommandBufferCreated(const int32 route_id) {
void GpuProcessHost::OnDestroyCommandBuffer(
gfx::PluginWindowHandle window, int32 renderer_id,
int32 render_view_id) {
-#if defined(OS_LINUX) && !defined(TOUCH_UI)
+#if defined(TOOLKIT_USES_GTK) && !defined(TOUCH_UI)
ViewID view_id(renderer_id, render_view_id);
SurfaceRefMap::iterator it = surface_refs_.find(view_id);
if (it != surface_refs_.end())
surface_refs_.erase(it);
-#endif // defined(OS_LINUX) && !defined(TOUCH_UI)
+#endif // defined(TOOLKIT_USES_GTK) && !defined(TOUCH_UI)
}
void GpuProcessHost::OnGraphicsInfoCollected(const GPUInfo& gpu_info) {
diff --git a/content/browser/gpu/gpu_process_host.h b/content/browser/gpu/gpu_process_host.h
index 491eab2..47f88fb 100644
--- a/content/browser/gpu/gpu_process_host.h
+++ b/content/browser/gpu/gpu_process_host.h
@@ -131,7 +131,7 @@ class GpuProcessHost : public BrowserChildProcessHost,
std::queue<linked_ptr<CreateCommandBufferCallback> >
create_command_buffer_requests_;
-#if defined(OS_LINUX) && !defined(TOUCH_UI)
+#if defined(TOOLKIT_USES_GTK) && !defined(TOUCH_UI)
typedef std::pair<int32 /* renderer_id */,
int32 /* render_view_id */> ViewID;
diff --git a/content/browser/gpu/gpu_process_host_ui_shim.cc b/content/browser/gpu/gpu_process_host_ui_shim.cc
index 312ca9f..a356f3b 100644
--- a/content/browser/gpu/gpu_process_host_ui_shim.cc
+++ b/content/browser/gpu/gpu_process_host_ui_shim.cc
@@ -15,13 +15,13 @@
#include "content/browser/renderer_host/render_widget_host_view.h"
#include "content/common/gpu/gpu_messages.h"
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_USES_GTK)
// These two #includes need to come after gpu_messages.h.
#include <gdk/gdkwindow.h> // NOLINT
#include <gdk/gdkx.h> // NOLINT
#include "ui/base/x/x11_util.h"
#include "ui/gfx/size.h"
-#endif // defined(OS_LINUX)
+#endif
namespace {
// One of the linux specific headers defines this as a macro.
@@ -145,7 +145,7 @@ bool GpuProcessHostUIShim::OnControlMessageReceived(
IPC_BEGIN_MESSAGE_MAP(GpuProcessHostUIShim, message)
IPC_MESSAGE_HANDLER(GpuHostMsg_OnLogMessage,
OnLogMessage)
-#if defined(OS_LINUX) && !defined(TOUCH_UI) || defined(OS_WIN)
+#if defined(TOOLKIT_USES_GTK) && !defined(TOUCH_UI) || defined(OS_WIN)
IPC_MESSAGE_HANDLER(GpuHostMsg_ResizeView, OnResizeView)
#elif defined(OS_MACOSX)
IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceSetIOSurface,
@@ -170,7 +170,7 @@ void GpuProcessHostUIShim::OnLogMessage(
GpuDataManager::GetInstance()->AddLogMessage(dict);
}
-#if defined(OS_LINUX) && !defined(TOUCH_UI) || defined(OS_WIN)
+#if defined(TOOLKIT_USES_GTK) && !defined(TOUCH_UI) || defined(OS_WIN)
void GpuProcessHostUIShim::OnResizeView(int32 renderer_id,
int32 render_view_id,
@@ -185,7 +185,7 @@ void GpuProcessHostUIShim::OnResizeView(int32 renderer_id,
// Resize the window synchronously. The GPU process must not issue GL
// calls on the command buffer until the window is the size it expects it
// to be.
-#if defined(OS_LINUX) && !defined(TOUCH_UI)
+#if defined(TOOLKIT_USES_GTK) && !defined(TOUCH_UI)
GdkWindow* window = reinterpret_cast<GdkWindow*>(
gdk_xid_table_lookup(handle));
if (window) {
diff --git a/content/browser/gpu/gpu_process_host_ui_shim.h b/content/browser/gpu/gpu_process_host_ui_shim.h
index f50ee95..02d8d79 100644
--- a/content/browser/gpu/gpu_process_host_ui_shim.h
+++ b/content/browser/gpu/gpu_process_host_ui_shim.h
@@ -92,7 +92,7 @@ class GpuProcessHostUIShim
void OnLogMessage(int level, const std::string& header,
const std::string& message);
-#if defined(OS_LINUX) && !defined(TOUCH_UI) || defined(OS_WIN)
+#if defined(TOOLKIT_USES_GTK) && !defined(TOUCH_UI) || defined(OS_WIN)
void OnResizeView(int32 renderer_id,
int32 render_view_id,
int32 command_buffer_route_id,
diff --git a/content/browser/plugin_service.cc b/content/browser/plugin_service.cc
index f4c293f..1cfea31 100644
--- a/content/browser/plugin_service.cc
+++ b/content/browser/plugin_service.cc
@@ -31,7 +31,7 @@
#include "webkit/plugins/npapi/plugin_list.h"
#include "webkit/plugins/npapi/webplugininfo.h"
-#if defined(OS_LINUX)
+#if defined(OS_POSIX) && !defined(OS_MACOSX)
using ::base::files::FilePathWatcher;
#endif
@@ -45,9 +45,7 @@ static void NotifyPluginsOfActivation() {
plugin->OnAppActivation();
}
}
-#endif
-
-#if defined(OS_LINUX)
+#elif defined(OS_POSIX)
// Delegate class for monitoring directories.
class PluginDirWatcherDelegate : public FilePathWatcher::Delegate {
virtual void OnFilePathChanged(const FilePath& path) OVERRIDE {
@@ -102,7 +100,12 @@ PluginService::PluginService()
hklm_watcher_.StartWatching(hklm_event_.get(), this);
}
}
-#elif defined(OS_POSIX) && !defined(OS_MACOSX)
+#elif defined(OS_MACOSX)
+ // We need to know when the browser comes forward so we can bring modal plugin
+ // windows forward too.
+ registrar_.Add(this, NotificationType::APP_ACTIVATED,
+ NotificationService::AllSources());
+#elif defined(OS_POSIX)
// Also find plugins in a user-specific plugins dir,
// e.g. ~/.config/chromium/Plugins.
FilePath user_data_dir;
@@ -110,12 +113,11 @@ PluginService::PluginService()
webkit::npapi::PluginList::Singleton()->AddExtraPluginDir(
user_data_dir.Append("Plugins"));
}
-#endif
+
// The FilePathWatcher produces too many false positives on MacOS (access time
// updates?) which will lead to enforcing updates of the plugins way too often.
// On ChromeOS the user can't install plugins anyway and on Windows all
// important plugins register themselves in the registry so no need to do that.
-#if defined(OS_LINUX)
file_watcher_delegate_ = new PluginDirWatcherDelegate();
// Get the list of all paths for registering the FilePathWatchers
// that will track and if needed reload the list of plugins on runtime.
@@ -141,12 +143,6 @@ PluginService::PluginService()
file_watchers_.push_back(watcher);
}
#endif
-#if defined(OS_MACOSX)
- // We need to know when the browser comes forward so we can bring modal plugin
- // windows forward too.
- registrar_.Add(this, NotificationType::APP_ACTIVATED,
- NotificationService::AllSources());
-#endif
registrar_.Add(this, NotificationType::PLUGIN_ENABLE_STATUS_CHANGED,
NotificationService::AllSources());
registrar_.Add(this,
@@ -497,7 +493,7 @@ PepperPluginInfo* PluginService::GetRegisteredPpapiPluginInfo(
return info;
}
-#if defined(OS_LINUX)
+#if defined(OS_POSIX) && !defined(OS_MACOSX)
// static
void PluginService::RegisterFilePathWatcher(
FilePathWatcher *watcher,
diff --git a/content/browser/plugin_service.h b/content/browser/plugin_service.h
index cc039d6..399055e 100644
--- a/content/browser/plugin_service.h
+++ b/content/browser/plugin_service.h
@@ -33,7 +33,7 @@
#include "base/win/registry.h"
#endif
-#if defined(OS_LINUX)
+#if defined(OS_POSIX) && !defined(OS_MACOSX)
#include "base/files/file_path_watcher.h"
#endif
@@ -151,7 +151,7 @@ class PluginService
const FilePath& plugin_path,
PluginProcessHost::Client* client);
-#if defined(OS_LINUX)
+#if defined(OS_POSIX) && !defined(OS_MACOSX)
// Registers a new FilePathWatcher for a given path.
static void RegisterFilePathWatcher(
base::files::FilePathWatcher* watcher,
@@ -179,7 +179,7 @@ class PluginService
base::WaitableEventWatcher hklm_watcher_;
#endif
-#if defined(OS_LINUX)
+#if defined(OS_POSIX) && !defined(OS_MACOSX)
ScopedVector<base::files::FilePathWatcher> file_watchers_;
scoped_refptr<PluginDirWatcherDelegate> file_watcher_delegate_;
#endif
diff --git a/content/browser/renderer_host/render_sandbox_host_linux.cc b/content/browser/renderer_host/render_sandbox_host_linux.cc
index d0b85c12..16fa2c4 100644
--- a/content/browser/renderer_host/render_sandbox_host_linux.cc
+++ b/content/browser/renderer_host/render_sandbox_host_linux.cc
@@ -665,7 +665,14 @@ void RenderSandboxHostLinux::Init(const std::string& sandbox_path) {
// inherit some sockets. With PF_UNIX+SOCK_DGRAM, it can call sendmsg to send
// a datagram to any (abstract) socket on the same system. With
// SOCK_SEQPACKET, this is prevented.
+#if defined(OS_FREEBSD) || defined(OS_OPENBSD)
+ // The BSDs often don't support SOCK_SEQPACKET yet, so fall back to
+ // SOCK_DGRAM if necessary.
+ if (socketpair(AF_UNIX, SOCK_SEQPACKET, 0, fds) != 0)
+ CHECK(socketpair(AF_UNIX, SOCK_DGRAM, 0, fds) == 0);
+#else
CHECK(socketpair(AF_UNIX, SOCK_SEQPACKET, 0, fds) == 0);
+#endif
renderer_socket_ = fds[0];
const int browser_socket = fds[1];
diff --git a/content/browser/renderer_host/render_widget_host_unittest.cc b/content/browser/renderer_host/render_widget_host_unittest.cc
index ab7ea54..8ded247 100644
--- a/content/browser/renderer_host/render_widget_host_unittest.cc
+++ b/content/browser/renderer_host/render_widget_host_unittest.cc
@@ -427,7 +427,7 @@ TEST_F(RenderWidgetHostTest, ResizeThenCrash) {
// Tests setting custom background
TEST_F(RenderWidgetHostTest, Background) {
-#if defined(OS_WIN) || defined(OS_LINUX)
+#if !defined(OS_MACOSX)
scoped_ptr<RenderWidgetHostView> view(
RenderWidgetHostView::CreateViewForWidget(host_.get()));
host_->set_view(view.get());
diff --git a/content/browser/zygote_host_linux.cc b/content/browser/zygote_host_linux.cc
index 4a51436..0469a97 100644
--- a/content/browser/zygote_host_linux.cc
+++ b/content/browser/zygote_host_linux.cc
@@ -81,7 +81,14 @@ void ZygoteHost::Init(const std::string& sandbox_cmd) {
cmd_line.AppendSwitchASCII(switches::kProcessType, switches::kZygoteProcess);
int fds[2];
+#if defined(OS_FREEBSD) || defined(OS_OPENBSD)
+ // The BSDs often don't support SOCK_SEQPACKET yet, so fall back to
+ // SOCK_DGRAM if necessary.
+ if (socketpair(PF_UNIX, SOCK_SEQPACKET, 0, fds) != 0)
+ CHECK(socketpair(PF_UNIX, SOCK_DGRAM, 0, fds) == 0);
+#else
CHECK(socketpair(PF_UNIX, SOCK_SEQPACKET, 0, fds) == 0);
+#endif
base::file_handle_mapping_vector fds_to_map;
fds_to_map.push_back(std::make_pair(fds[1], 3));
diff --git a/content/browser/zygote_main_linux.cc b/content/browser/zygote_main_linux.cc
index ef9dd0b..b01e2ed 100644
--- a/content/browser/zygote_main_linux.cc
+++ b/content/browser/zygote_main_linux.cc
@@ -2,25 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "content/browser/zygote_host_linux.h"
+
#include <dlfcn.h>
#include <fcntl.h>
#include <pthread.h>
-#include <sys/epoll.h>
-#include <sys/prctl.h>
-#include <sys/signal.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
-#if defined(CHROMIUM_SELINUX)
-#include <selinux/selinux.h>
-#include <selinux/context.h>
-#endif
-
-#include "content/browser/zygote_host_linux.h"
-
#include "base/basictypes.h"
#include "base/command_line.h"
#include "base/eintr_wrapper.h"
@@ -52,6 +44,19 @@
#include "skia/ext/SkFontHost_fontconfig_control.h"
#include "unicode/timezone.h"
+#if defined(OS_LINUX)
+#include <sys/epoll.h>
+#include <sys/prctl.h>
+#include <sys/signal.h>
+#else
+#include <signal.h>
+#endif
+
+#if defined(CHROMIUM_SELINUX)
+#include <selinux/selinux.h>
+#include <selinux/context.h>
+#endif
+
#if defined(ARCH_CPU_X86_FAMILY) && !defined(CHROMIUM_SELINUX) && \
!defined(__clang__)
// The seccomp sandbox is enabled on all ia32 and x86-64 processor as long as
diff --git a/content/common/gpu/gpu_channel_manager.cc b/content/common/gpu/gpu_channel_manager.cc
index d772f48..849e456 100644
--- a/content/common/gpu/gpu_channel_manager.cc
+++ b/content/common/gpu/gpu_channel_manager.cc
@@ -49,7 +49,7 @@ bool GpuChannelManager::OnMessageReceived(const IPC::Message& msg) {
OnCreateViewCommandBuffer)
IPC_MESSAGE_HANDLER(GpuMsg_Synchronize, OnSynchronize)
IPC_MESSAGE_HANDLER(GpuMsg_VisibilityChanged, OnVisibilityChanged)
-#if defined(OS_LINUX) && !defined(TOUCH_UI) || defined(OS_WIN)
+#if defined(TOOLKIT_USES_GTK) && !defined(TOUCH_UI) || defined(OS_WIN)
IPC_MESSAGE_HANDLER(GpuMsg_ResizeViewACK, OnResizeViewACK);
#elif defined(OS_MACOSX)
IPC_MESSAGE_HANDLER(GpuMsg_AcceleratedSurfaceBuffersSwappedACK,
diff --git a/content/common/gpu/gpu_command_buffer_stub.cc b/content/common/gpu/gpu_command_buffer_stub.cc
index 8483147..531e2ac 100644
--- a/content/common/gpu/gpu_command_buffer_stub.cc
+++ b/content/common/gpu/gpu_command_buffer_stub.cc
@@ -406,7 +406,7 @@ void GpuCommandBufferStub::ResizeCallback(gfx::Size size) {
scheduler_->decoder()->ResizeOffscreenFrameBuffer(size);
scheduler_->decoder()->UpdateOffscreenFrameBufferSize();
} else {
-#if defined(OS_LINUX) && !defined(TOUCH_UI) || defined(OS_WIN)
+#if defined(TOOLKIT_USES_GTK) && !defined(TOUCH_UI) || defined(OS_WIN)
GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager();
gpu_channel_manager->Send(
new GpuHostMsg_ResizeView(renderer_id_,
@@ -420,7 +420,7 @@ void GpuCommandBufferStub::ResizeCallback(gfx::Size size) {
}
void GpuCommandBufferStub::ViewResized() {
-#if defined(OS_LINUX) && !defined(TOUCH_UI) || defined(OS_WIN)
+#if defined(TOOLKIT_USES_GTK) && !defined(TOUCH_UI) || defined(OS_WIN)
DCHECK(handle_ != gfx::kNullPluginWindow);
scheduler_->SetScheduled(true);
diff --git a/content/common/gpu/gpu_messages.h b/content/common/gpu/gpu_messages.h
index 3d154ef..017c876 100644
--- a/content/common/gpu/gpu_messages.h
+++ b/content/common/gpu/gpu_messages.h
@@ -161,7 +161,7 @@ IPC_MESSAGE_CONTROL4(GpuMsg_CreateViewCommandBuffer,
// information.
IPC_MESSAGE_CONTROL0(GpuMsg_CollectGraphicsInfo)
-#if defined(OS_LINUX) && !defined(TOUCH_UI) || defined(OS_WIN)
+#if defined(TOOLKIT_USES_GTK) && !defined(TOUCH_UI) || defined(OS_WIN)
// Tells the GPU process that the browser process has finished resizing the
// view.
IPC_MESSAGE_CONTROL2(GpuMsg_ResizeViewACK,
@@ -253,7 +253,7 @@ IPC_MESSAGE_CONTROL3(GpuHostMsg_OnLogMessage,
// Response from GPU to a GpuMsg_Synchronize message.
IPC_MESSAGE_CONTROL0(GpuHostMsg_SynchronizeReply)
-#if defined(OS_LINUX) && !defined(TOUCH_UI) || defined(OS_WIN)
+#if defined(TOOLKIT_USES_GTK) && !defined(TOUCH_UI) || defined(OS_WIN)
// Resize the window that is being drawn into. It's important that this
// resize be synchronized with the swapping of the front and back buffers.
IPC_MESSAGE_CONTROL4(GpuHostMsg_ResizeView,
diff --git a/content/common/gpu/x_util.h b/content/common/gpu/x_util.h
index c6305c5..6e2423c 100644
--- a/content/common/gpu/x_util.h
+++ b/content/common/gpu/x_util.h
@@ -12,7 +12,7 @@
#include "build/build_config.h"
#include "content/common/gpu/gpu_config.h"
-#if defined(OS_LINUX)
+#if defined(USE_X11)
// Forward declares ------------------------------------------------------------
//
@@ -42,6 +42,6 @@ class ScopedPtrXFree {
void operator()(void* x) const;
};
-#endif // OS_LINUX
+#endif // USE_X11
#endif // CHROME_GPU_X_UTIL_H_
diff --git a/content/common/native_web_keyboard_event.h b/content/common/native_web_keyboard_event.h
index 6e94a34..21e358a 100644
--- a/content/common/native_web_keyboard_event.h
+++ b/content/common/native_web_keyboard_event.h
@@ -86,7 +86,7 @@ struct NativeWebKeyboardEvent : public WebKit::WebKeyboardEvent {
// Currently, it's only used by Linux and Mac ports.
bool skip_in_browser;
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_USES_GTK)
// True if the key event matches an edit command. In order to ensure the edit
// command always work in web page, the browser should not pre-handle this key
// event as a reserved accelerator. See http://crbug.com/54573
diff --git a/content/common/native_web_keyboard_event_views.cc b/content/common/native_web_keyboard_event_views.cc
index 8c6eb12..b9c2eea 100644
--- a/content/common/native_web_keyboard_event_views.cc
+++ b/content/common/native_web_keyboard_event_views.cc
@@ -55,7 +55,7 @@ NativeWebKeyboardEvent::NativeWebKeyboardEvent(
}
#endif
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_USES_GTK)
match_edit_command = false;
#endif
}
@@ -80,7 +80,7 @@ NativeWebKeyboardEvent::NativeWebKeyboardEvent(uint16 character,
os_event = NULL;
#endif
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_USES_GTK)
match_edit_command = false;
#endif
}
diff --git a/content/gpu/gpu_child_thread.cc b/content/gpu/gpu_child_thread.cc
index d3e6e94..b84ac0f 100644
--- a/content/gpu/gpu_child_thread.cc
+++ b/content/gpu/gpu_child_thread.cc
@@ -89,7 +89,7 @@ bool GpuChildThread::Send(IPC::Message* msg) {
// process. This could result in deadlock. Unfortunately linux does this for
// GpuHostMsg_ResizeXID. TODO(apatrick): fix this before issuing any GL calls
// on the browser process' GPU thread.
-#if !defined(OS_LINUX)
+#if !defined(TOOLKIT_USES_GTK)
DCHECK(!msg->is_sync());
#endif
diff --git a/content/plugin/plugin_thread.cc b/content/plugin/plugin_thread.cc
index eda6c92..18455d2 100644
--- a/content/plugin/plugin_thread.cc
+++ b/content/plugin/plugin_thread.cc
@@ -6,7 +6,7 @@
#include "build/build_config.h"
-#if defined(USE_X11)
+#if defined(TOOLKIT_USES_GTK)
#include <gtk/gtk.h>
#elif defined(OS_MACOSX)
#include <CoreFoundation/CoreFoundation.h>
@@ -49,7 +49,7 @@ PluginThread::PluginThread()
switches::kPluginPath);
lazy_tls.Pointer()->Set(this);
-#if defined(OS_LINUX)
+#if defined(TOOLKIT_USES_GTK)
{
// XEmbed plugins assume they are hosted in a Gtk application, so we need
// to initialize Gtk in the plugin process.
diff --git a/content/ppapi_plugin/ppapi_webkitclient_impl.cc b/content/ppapi_plugin/ppapi_webkitclient_impl.cc
index 1abbe94..7908e0c 100644
--- a/content/ppapi_plugin/ppapi_webkitclient_impl.cc
+++ b/content/ppapi_plugin/ppapi_webkitclient_impl.cc
@@ -17,7 +17,7 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/win/WebSandboxSupport.h"
#elif defined(OS_MACOSX)
#include "third_party/WebKit/Source/WebKit/chromium/public/mac/WebSandboxSupport.h"
-#elif defined(OS_LINUX)
+#elif defined(OS_POSIX)
#include "content/common/child_process_sandbox_support_linux.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebSandboxSupport.h"
#endif
@@ -32,7 +32,7 @@ class PpapiWebKitClientImpl::SandboxSupport : public WebSandboxSupport {
virtual bool ensureFontLoaded(HFONT);
#elif defined(OS_MACOSX)
virtual bool loadFont(NSFont* srcFont, ATSFontContainerRef* out);
-#elif defined(OS_LINUX)
+#elif defined(OS_POSIX)
virtual WebString getFontFamilyForCharacters(
const WebUChar* characters,
size_t numCharacters,
@@ -69,7 +69,7 @@ bool PpapiWebKitClientImpl::SandboxSupport::loadFont(NSFont* srcFont,
return false;
}
-#elif defined(OS_LINUX)
+#elif defined(OS_POSIX)
WebString PpapiWebKitClientImpl::SandboxSupport::getFontFamilyForCharacters(
const WebUChar* characters,
diff --git a/content/renderer/render_thread.cc b/content/renderer/render_thread.cc
index 0e75b48..616fb8e 100644
--- a/content/renderer/render_thread.cc
+++ b/content/renderer/render_thread.cc
@@ -609,7 +609,7 @@ void RenderThread::EnsureWebKitInitialized() {
}
void RenderThread::IdleHandler() {
-#if (defined(OS_WIN) || defined(OS_LINUX)) && defined(USE_TCMALLOC)
+#if !defined(OS_MACOSX) && defined(USE_TCMALLOC)
MallocExtension::instance()->ReleaseFreeMemory();
#endif
diff --git a/content/renderer/render_view.h b/content/renderer/render_view.h
index 1b56068..2db3e1f 100644
--- a/content/renderer/render_view.h
+++ b/content/renderer/render_view.h
@@ -881,7 +881,7 @@ class RenderView : public RenderWidget,
// periodic timer so we don't send too many messages.
void SyncNavigationState();
-#if defined(OS_LINUX)
+#if defined(OS_POSIX) && !defined(OS_MACOSX)
void UpdateFontRenderingFromRendererPrefs();
#else
void UpdateFontRenderingFromRendererPrefs() {}
diff --git a/content/renderer/render_view_browsertest.cc b/content/renderer/render_view_browsertest.cc
index cbb796e..d06251e 100644
--- a/content/renderer/render_view_browsertest.cc
+++ b/content/renderer/render_view_browsertest.cc
@@ -376,7 +376,7 @@ TEST_F(RenderViewTest, OnSetTextDirection) {
// Test that we can receive correct DOM events when we send input events
// through the RenderWidget::OnHandleInputEvent() function.
TEST_F(RenderViewTest, OnHandleKeyboardEvent) {
-#if defined(OS_WIN) || defined(OS_LINUX)
+#if !defined(OS_MACOSX)
// Load an HTML page consisting of one <input> element and three
// contentediable <div> elements.
// The <input> element is used for sending keyboard events, and the <div>
@@ -524,7 +524,7 @@ TEST_F(RenderViewTest, OnHandleKeyboardEvent) {
// This test is for preventing regressions caused only when we use non-US
// keyboards, such as Issue 10846.
TEST_F(RenderViewTest, InsertCharacters) {
-#if defined(OS_WIN) || defined(OS_LINUX)
+#if !defined(OS_MACOSX)
static const struct {
MockKeyboard::Layout layout;
const wchar_t* expected_result;
diff --git a/content/renderer/renderer_main.cc b/content/renderer/renderer_main.cc
index 2551e14..9ce70b5 100644
--- a/content/renderer/renderer_main.cc
+++ b/content/renderer/renderer_main.cc
@@ -207,7 +207,7 @@ int RendererMain(const MainFunctionParams& parameters) {
PepperPluginRegistry::GetInstance();
{
-#if !defined(OS_LINUX)
+#if defined(OS_WIN) || defined(OS_MACOSX)
// TODO(markus): Check if it is OK to unconditionally move this
// instruction down.
RenderProcessImpl render_process;
@@ -219,7 +219,7 @@ int RendererMain(const MainFunctionParams& parameters) {
} else {
LOG(ERROR) << "Running without renderer sandbox";
}
-#if defined(OS_LINUX)
+#if defined(OS_POSIX) && !defined(OS_MACOSX)
RenderProcessImpl render_process;
render_process.set_main_thread(new RenderThread());
#endif
diff --git a/content/renderer/renderer_webkitclient_impl.cc b/content/renderer/renderer_webkitclient_impl.cc
index 33c8673..55db5f7 100644
--- a/content/renderer/renderer_webkitclient_impl.cc
+++ b/content/renderer/renderer_webkitclient_impl.cc
@@ -56,7 +56,7 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/mac/WebSandboxSupport.h"
#endif
-#if defined(OS_LINUX)
+#if defined(OS_POSIX) && !defined(OS_MACOSX)
#include <string>
#include <map>
@@ -117,7 +117,7 @@ class RendererWebKitClientImpl::SandboxSupport
virtual bool loadFont(NSFont* srcFont, ATSFontContainerRef* out);
virtual bool loadFont(
NSFont* srcFont, ATSFontContainerRef* container, uint32* fontID);
-#elif defined(OS_LINUX)
+#elif defined(OS_POSIX)
virtual WebKit::WebString getFontFamilyForCharacters(
const WebKit::WebUChar* characters,
size_t numCharacters,
@@ -436,34 +436,6 @@ bool RendererWebKitClientImpl::SandboxSupport::ensureFontLoaded(HFONT font) {
return RenderThread::current()->Send(new ViewHostMsg_PreCacheFont(logfont));
}
-#elif defined(OS_LINUX)
-
-WebString RendererWebKitClientImpl::SandboxSupport::getFontFamilyForCharacters(
- const WebKit::WebUChar* characters,
- size_t num_characters,
- const char* preferred_locale) {
- base::AutoLock lock(unicode_font_families_mutex_);
- const string16 key(characters, num_characters);
- const std::map<string16, std::string>::const_iterator iter =
- unicode_font_families_.find(key);
- if (iter != unicode_font_families_.end())
- return WebString::fromUTF8(iter->second);
-
- const std::string family_name =
- child_process_sandbox_support::getFontFamilyForCharacters(
- characters,
- num_characters,
- preferred_locale);
- unicode_font_families_.insert(make_pair(key, family_name));
- return WebString::fromUTF8(family_name);
-}
-
-void RendererWebKitClientImpl::SandboxSupport::getRenderStyleForStrike(
- const char* family, int sizeAndStyle, WebKit::WebFontRenderStyle* out) {
- child_process_sandbox_support::getRenderStyleForStrike(family, sizeAndStyle,
- out);
-}
-
#elif defined(OS_MACOSX)
// TODO(jeremy): Remove once WebKit side of patch lands - crbug.com/72727 .
@@ -507,6 +479,34 @@ bool RendererWebKitClientImpl::SandboxSupport::loadFont(
container);
}
+#elif defined(OS_POSIX)
+
+WebString RendererWebKitClientImpl::SandboxSupport::getFontFamilyForCharacters(
+ const WebKit::WebUChar* characters,
+ size_t num_characters,
+ const char* preferred_locale) {
+ base::AutoLock lock(unicode_font_families_mutex_);
+ const string16 key(characters, num_characters);
+ const std::map<string16, std::string>::const_iterator iter =
+ unicode_font_families_.find(key);
+ if (iter != unicode_font_families_.end())
+ return WebString::fromUTF8(iter->second);
+
+ const std::string family_name =
+ child_process_sandbox_support::getFontFamilyForCharacters(
+ characters,
+ num_characters,
+ preferred_locale);
+ unicode_font_families_.insert(make_pair(key, family_name));
+ return WebString::fromUTF8(family_name);
+}
+
+void RendererWebKitClientImpl::SandboxSupport::getRenderStyleForStrike(
+ const char* family, int sizeAndStyle, WebKit::WebFontRenderStyle* out) {
+ child_process_sandbox_support::getRenderStyleForStrike(family, sizeAndStyle,
+ out);
+}
+
#endif
//------------------------------------------------------------------------------
diff --git a/content/worker/worker_uitest.cc b/content/worker/worker_uitest.cc
index 6099a05..3691072 100644
--- a/content/worker/worker_uitest.cc
+++ b/content/worker/worker_uitest.cc
@@ -88,8 +88,8 @@ class WorkerTest : public UILayoutTest {
// The 1 is for the browser process.
int number_of_processes = 1 + workers +
(ProxyLauncher::in_process_renderer() ? 0 : tabs);
-#if defined(OS_LINUX)
- // On Linux, we also have a zygote process and a sandbox host process.
+#if defined(OS_POSIX) && !defined(OS_MACOSX)
+ // On Unix, we also have a zygote process and a sandbox host process.
number_of_processes += 2;
#endif