Commit e0c06c7a authored by mcgrathr@chromium.org's avatar mcgrathr@chromium.org

Clean up disable_nacl

The status quo is to compile in a bunch of dead code under disable_nacl.
It's then littered with conditionals to avoid using things not linked
in.  That's just silly.  When NaCl is disabled, we should not compile
any of it in.

BUG= none
TEST= builds with and without GYP_DEFINES=disable_nacl=1

R=mseaborn@chromium.org

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110712 0039d316-1c4b-4281-b951-d872f2087c98
parent 01c505c4
...@@ -36,7 +36,6 @@ using content::BrowserThread; ...@@ -36,7 +36,6 @@ using content::BrowserThread;
namespace { namespace {
#if !defined(DISABLE_NACL)
void SetCloseOnExec(nacl::Handle fd) { void SetCloseOnExec(nacl::Handle fd) {
#if defined(OS_POSIX) #if defined(OS_POSIX)
int flags = fcntl(fd, F_GETFD); int flags = fcntl(fd, F_GETFD);
...@@ -45,7 +44,6 @@ void SetCloseOnExec(nacl::Handle fd) { ...@@ -45,7 +44,6 @@ void SetCloseOnExec(nacl::Handle fd) {
CHECK_EQ(rc, 0); CHECK_EQ(rc, 0);
#endif #endif
} }
#endif
// Represents shared state for all NaClProcessHost objects in the browser. // Represents shared state for all NaClProcessHost objects in the browser.
// Currently this just handles holding onto the file descriptor for the IRT. // Currently this just handles holding onto the file descriptor for the IRT.
...@@ -118,10 +116,6 @@ NaClProcessHost::NaClProcessHost(const std::wstring& url) ...@@ -118,10 +116,6 @@ NaClProcessHost::NaClProcessHost(const std::wstring& url)
} }
NaClProcessHost::~NaClProcessHost() { NaClProcessHost::~NaClProcessHost() {
// nacl::Close() is not available at link time if DISABLE_NACL is
// defined, but we still compile a bunch of other code from this
// file anyway. TODO(mseaborn): Make this less messy.
#ifndef DISABLE_NACL
for (size_t i = 0; i < internal_->sockets_for_renderer.size(); i++) { for (size_t i = 0; i < internal_->sockets_for_renderer.size(); i++) {
if (nacl::Close(internal_->sockets_for_renderer[i]) != 0) { if (nacl::Close(internal_->sockets_for_renderer[i]) != 0) {
LOG(ERROR) << "nacl::Close() failed"; LOG(ERROR) << "nacl::Close() failed";
...@@ -132,7 +126,6 @@ NaClProcessHost::~NaClProcessHost() { ...@@ -132,7 +126,6 @@ NaClProcessHost::~NaClProcessHost() {
LOG(ERROR) << "nacl::Close() failed"; LOG(ERROR) << "nacl::Close() failed";
} }
} }
#endif
if (reply_msg_) { if (reply_msg_) {
// The process failed to launch for some reason. // The process failed to launch for some reason.
...@@ -174,10 +167,6 @@ bool NaClProcessHost::Launch( ...@@ -174,10 +167,6 @@ bool NaClProcessHost::Launch(
ChromeRenderMessageFilter* chrome_render_message_filter, ChromeRenderMessageFilter* chrome_render_message_filter,
int socket_count, int socket_count,
IPC::Message* reply_msg) { IPC::Message* reply_msg) {
#ifdef DISABLE_NACL
NOTIMPLEMENTED() << "Native Client disabled at build time";
return false;
#else
// Place an arbitrary limit on the number of sockets to limit // Place an arbitrary limit on the number of sockets to limit
// exposure in case the renderer is compromised. We can increase // exposure in case the renderer is compromised. We can increase
// this if necessary. // this if necessary.
...@@ -220,7 +209,6 @@ bool NaClProcessHost::Launch( ...@@ -220,7 +209,6 @@ bool NaClProcessHost::Launch(
reply_msg_ = reply_msg; reply_msg_ = reply_msg;
return true; return true;
#endif // DISABLE_NACL
} }
bool NaClProcessHost::LaunchSelLdr() { bool NaClProcessHost::LaunchSelLdr() {
......
...@@ -66,7 +66,9 @@ bool ChromeRenderMessageFilter::OnMessageReceived(const IPC::Message& message, ...@@ -66,7 +66,9 @@ bool ChromeRenderMessageFilter::OnMessageReceived(const IPC::Message& message,
bool* message_was_ok) { bool* message_was_ok) {
bool handled = true; bool handled = true;
IPC_BEGIN_MESSAGE_MAP_EX(ChromeRenderMessageFilter, message, *message_was_ok) IPC_BEGIN_MESSAGE_MAP_EX(ChromeRenderMessageFilter, message, *message_was_ok)
#if !defined(DISABLE_NACL)
IPC_MESSAGE_HANDLER_DELAY_REPLY(ChromeViewHostMsg_LaunchNaCl, OnLaunchNaCl) IPC_MESSAGE_HANDLER_DELAY_REPLY(ChromeViewHostMsg_LaunchNaCl, OnLaunchNaCl)
#endif
IPC_MESSAGE_HANDLER(ChromeViewHostMsg_DnsPrefetch, OnDnsPrefetch) IPC_MESSAGE_HANDLER(ChromeViewHostMsg_DnsPrefetch, OnDnsPrefetch)
IPC_MESSAGE_HANDLER(ChromeViewHostMsg_RendererHistograms, IPC_MESSAGE_HANDLER(ChromeViewHostMsg_RendererHistograms,
OnRendererHistograms) OnRendererHistograms)
...@@ -146,11 +148,13 @@ void ChromeRenderMessageFilter::OverrideThreadForMessage( ...@@ -146,11 +148,13 @@ void ChromeRenderMessageFilter::OverrideThreadForMessage(
} }
} }
#if !defined(DISABLE_NACL)
void ChromeRenderMessageFilter::OnLaunchNaCl( void ChromeRenderMessageFilter::OnLaunchNaCl(
const std::wstring& url, int socket_count, IPC::Message* reply_msg) { const std::wstring& url, int socket_count, IPC::Message* reply_msg) {
NaClProcessHost* host = new NaClProcessHost(url); NaClProcessHost* host = new NaClProcessHost(url);
host->Launch(this, socket_count, reply_msg); host->Launch(this, socket_count, reply_msg);
} }
#endif
void ChromeRenderMessageFilter::OnDnsPrefetch( void ChromeRenderMessageFilter::OnDnsPrefetch(
const std::vector<std::string>& hostnames) { const std::vector<std::string>& hostnames) {
......
...@@ -46,9 +46,11 @@ class ChromeRenderMessageFilter : public BrowserMessageFilter { ...@@ -46,9 +46,11 @@ class ChromeRenderMessageFilter : public BrowserMessageFilter {
virtual ~ChromeRenderMessageFilter(); virtual ~ChromeRenderMessageFilter();
#if !defined(DISABLE_NACL)
void OnLaunchNaCl(const std::wstring& url, void OnLaunchNaCl(const std::wstring& url,
int socket_count, int socket_count,
IPC::Message* reply_msg); IPC::Message* reply_msg);
#endif
void OnDnsPrefetch(const std::vector<std::string>& hostnames); void OnDnsPrefetch(const std::vector<std::string>& hostnames);
void OnRendererHistograms(int sequence_number, void OnRendererHistograms(int sequence_number,
const std::vector<std::string>& histogram_info); const std::vector<std::string>& histogram_info);
......
...@@ -1546,12 +1546,6 @@ ...@@ -1546,12 +1546,6 @@
'browser/metrics/thread_watcher.h', 'browser/metrics/thread_watcher.h',
'browser/mock_keychain_mac.cc', 'browser/mock_keychain_mac.cc',
'browser/mock_keychain_mac.h', 'browser/mock_keychain_mac.h',
'browser/nacl_host/nacl_broker_host_win.cc',
'browser/nacl_host/nacl_broker_host_win.h',
'browser/nacl_host/nacl_broker_service_win.cc',
'browser/nacl_host/nacl_broker_service_win.h',
'browser/nacl_host/nacl_process_host.cc',
'browser/nacl_host/nacl_process_host.h',
'browser/native_window_notification_source.h', 'browser/native_window_notification_source.h',
'browser/net/browser_url_util.cc', 'browser/net/browser_url_util.cc',
'browser/net/browser_url_util.h', 'browser/net/browser_url_util.h',
...@@ -4003,6 +3997,16 @@ ...@@ -4003,6 +3997,16 @@
'<(SHARED_INTERMEDIATE_DIR)/autofill_regex_constants.cc', '<(SHARED_INTERMEDIATE_DIR)/autofill_regex_constants.cc',
], ],
'conditions': [ 'conditions': [
['disable_nacl==0', {
'sources': [
'browser/nacl_host/nacl_broker_host_win.cc',
'browser/nacl_host/nacl_broker_host_win.h',
'browser/nacl_host/nacl_broker_service_win.cc',
'browser/nacl_host/nacl_broker_service_win.h',
'browser/nacl_host/nacl_process_host.cc',
'browser/nacl_host/nacl_process_host.h',
],
}],
['buildtype=="Official"', { ['buildtype=="Official"', {
'sources!': [ 'sources!': [
'browser/protector/keys.cc', 'browser/protector/keys.cc',
......
...@@ -25,11 +25,11 @@ using content::RenderThread; ...@@ -25,11 +25,11 @@ using content::RenderThread;
namespace chrome { namespace chrome {
#if !defined(DISABLE_NACL)
// Launch NaCl's sel_ldr process. // Launch NaCl's sel_ldr process.
bool LaunchSelLdr(const char* alleged_url, int socket_count, bool LaunchSelLdr(const char* alleged_url, int socket_count,
void* imc_handles, void* nacl_process_handle, void* imc_handles, void* nacl_process_handle,
int* nacl_process_id) { int* nacl_process_id) {
#if !defined(DISABLE_NACL)
std::vector<nacl::FileDescriptor> sockets; std::vector<nacl::FileDescriptor> sockets;
base::ProcessHandle nacl_process; base::ProcessHandle nacl_process;
if (!RenderThread::Get()->Send( if (!RenderThread::Get()->Send(
...@@ -48,9 +48,6 @@ bool LaunchSelLdr(const char* alleged_url, int socket_count, ...@@ -48,9 +48,6 @@ bool LaunchSelLdr(const char* alleged_url, int socket_count,
} }
*static_cast<nacl::Handle*>(nacl_process_handle) = nacl_process; *static_cast<nacl::Handle*>(nacl_process_handle) = nacl_process;
return true; return true;
#else
return false;
#endif
} }
int UrandomFD(void) { int UrandomFD(void) {
...@@ -79,10 +76,13 @@ class PPB_NaCl_Impl { ...@@ -79,10 +76,13 @@ class PPB_NaCl_Impl {
return &ppb_nacl; return &ppb_nacl;
} }
}; };
#endif // DISABLE_NACL
const void* ChromePPAPIInterfaceFactory(const std::string& interface_name) { const void* ChromePPAPIInterfaceFactory(const std::string& interface_name) {
#if !defined(DISABLE_NACL)
if (interface_name == PPB_NACL_PRIVATE_INTERFACE) if (interface_name == PPB_NACL_PRIVATE_INTERFACE)
return chrome::PPB_NaCl_Impl::GetInterface(); return chrome::PPB_NaCl_Impl::GetInterface();
#endif // DISABLE_NACL
if (interface_name == PPB_PDF_INTERFACE) if (interface_name == PPB_PDF_INTERFACE)
return chrome::PPB_PDF_Impl::GetInterface(); return chrome::PPB_PDF_Impl::GetInterface();
return NULL; return NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment