summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-23 21:03:04 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-23 21:03:04 +0000
commit6eaddcc1be66c1ffb3980a6b5b1fe0f106be67e9 (patch)
tree69b4e4ef0c667919461d92cc91e020f3b5122ba2 /chrome
parent9f37ca87b7226929d4156a4ad00116f76876404d (diff)
downloadchromium_src-6eaddcc1be66c1ffb3980a6b5b1fe0f106be67e9.zip
chromium_src-6eaddcc1be66c1ffb3980a6b5b1fe0f106be67e9.tar.gz
chromium_src-6eaddcc1be66c1ffb3980a6b5b1fe0f106be67e9.tar.bz2
Make plugin_process_host.cc and child_process_host.cc compile on Posix.
Review URL: http://codereview.chromium.org/27018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10210 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/browser.scons1
-rw-r--r--chrome/browser/plugin_process_host.cc165
-rw-r--r--chrome/browser/plugin_process_host.h14
-rw-r--r--chrome/browser/plugin_service.cc8
-rw-r--r--chrome/chrome.xcodeproj/project.pbxproj6
-rw-r--r--chrome/common/child_process_host.cc19
-rw-r--r--chrome/common/child_process_host.h15
-rw-r--r--chrome/common/common.scons2
-rw-r--r--chrome/common/temp_scaffolding_stubs.h67
9 files changed, 161 insertions, 136 deletions
diff --git a/chrome/browser/browser.scons b/chrome/browser/browser.scons
index 7d2a58c..44bab2c 100644
--- a/chrome/browser/browser.scons
+++ b/chrome/browser/browser.scons
@@ -713,7 +713,6 @@ if not env.Bit('windows'):
'google_update.cc',
'password_manager/encryptor.cc',
'plugin_installer.cc',
- 'plugin_process_host.cc',
'printing/page_overlays.cc',
'printing/print_job.cc',
'printing/print_job_manager.cc',
diff --git a/chrome/browser/plugin_process_host.cc b/chrome/browser/plugin_process_host.cc
index 5cafff1..b54fe20 100644
--- a/chrome/browser/plugin_process_host.cc
+++ b/chrome/browser/plugin_process_host.cc
@@ -2,13 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "build/build_config.h"
+
#include "chrome/browser/plugin_process_host.h"
+#if defined(OS_WIN)
#include <windows.h>
+#endif
+
#include <vector>
#include "base/command_line.h"
#include "base/debug_util.h"
+#include "base/file_path.h"
#include "base/file_util.h"
#include "base/file_version_info.h"
#include "base/logging.h"
@@ -16,7 +22,6 @@
#include "base/process_util.h"
#include "base/scoped_ptr.h"
#include "base/thread.h"
-#include "base/win_util.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_plugin_browsing_context.h"
#include "chrome/browser/chrome_thread.h"
@@ -25,21 +30,27 @@
#include "chrome/browser/renderer_host/browser_render_process_host.h"
#include "chrome/browser/renderer_host/render_process_host.h"
#include "chrome/browser/renderer_host/resource_dispatcher_host.h"
-#include "chrome/browser/sandbox_policy.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_plugin_lib.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/debug_flags.h"
#include "chrome/common/logging_chrome.h"
-#include "chrome/common/plugin_messages.h"
#include "chrome/common/render_messages.h"
-#include "chrome/common/win_util.h"
#include "net/base/cookie_monster.h"
+#include "net/base/file_stream.h"
#include "net/base/io_buffer.h"
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_context.h"
+
+// TODO(port): Port these files.
+#if defined(OS_WIN)
+#include "base/win_util.h"
+#include "chrome/browser/sandbox_policy.h"
+#include "chrome/common/plugin_messages.h"
+#include "chrome/common/win_util.h"
#include "sandbox/src/sandbox.h"
#include "webkit/glue/plugins/plugin_constants_win.h"
+#endif
static const char kDefaultPluginFinderURL[] =
"http://dl.google.com/chrome/plugins/plugins2.xml";
@@ -52,7 +63,7 @@ class PluginDownloadUrlHelper : public URLRequest::Delegate {
static const int kDownloadFileBufferSize = 32768;
public:
PluginDownloadUrlHelper(const std::string& download_url,
- int source_pid, HWND caller_window);
+ int source_pid, gfx::NativeWindow caller_window);
~PluginDownloadUrlHelper();
void InitiateDownload();
@@ -76,14 +87,15 @@ class PluginDownloadUrlHelper : public URLRequest::Delegate {
// The download file request initiated by the plugin.
URLRequest* download_file_request_;
// Handle to the downloaded file.
- HANDLE download_file_;
+ scoped_ptr<net::FileStream> download_file_;
// The full path of the downloaded file.
- std::wstring download_file_path_;
+ FilePath download_file_path_;
// The buffer passed off to URLRequest::Read.
scoped_refptr<net::IOBuffer> download_file_buffer_;
+ // TODO(port): this comment doesn't describe the situation on Posix.
// The window handle for sending the WM_COPYDATA notification,
// indicating that the download completed.
- HWND download_file_caller_window_;
+ gfx::NativeWindow download_file_caller_window_;
std::string download_url_;
int download_source_pid_;
@@ -93,14 +105,17 @@ class PluginDownloadUrlHelper : public URLRequest::Delegate {
PluginDownloadUrlHelper::PluginDownloadUrlHelper(
const std::string& download_url,
- int source_pid, HWND caller_window)
- : download_url_(download_url),
- download_file_request_(NULL),
- download_file_(INVALID_HANDLE_VALUE),
+ int source_pid, gfx::NativeWindow caller_window)
+ : download_file_request_(NULL),
download_file_buffer_(new net::IOBuffer(kDownloadFileBufferSize)),
download_file_caller_window_(caller_window),
+ download_url_(download_url),
download_source_pid_(source_pid) {
+#if defined(OS_WIN)
DCHECK(::IsWindow(caller_window));
+#else
+ // TODO(port): Some window verification for mac and linux.
+#endif
memset(download_file_buffer_->data(), 0, kDownloadFileBufferSize);
}
@@ -109,11 +124,6 @@ PluginDownloadUrlHelper::~PluginDownloadUrlHelper() {
delete download_file_request_;
download_file_request_ = NULL;
}
-
- if (download_file_ != INVALID_HANDLE_VALUE) {
- ::CloseHandle(INVALID_HANDLE_VALUE);
- download_file_ = NULL;
- }
}
void PluginDownloadUrlHelper::InitiateDownload() {
@@ -142,18 +152,20 @@ void PluginDownloadUrlHelper::OnSSLCertificateError(URLRequest* request,
}
void PluginDownloadUrlHelper::OnResponseStarted(URLRequest* request) {
- if (download_file_ == INVALID_HANDLE_VALUE) {
+ if (!download_file_->IsOpen()) {
file_util::GetTempDir(&download_file_path_);
- download_file_path_ += L"\\";
GURL request_url = request->url();
- download_file_path_ += UTF8ToWide(request_url.ExtractFileName());
-
- download_file_ = CreateFile(download_file_path_.c_str(),
- GENERIC_READ | GENERIC_WRITE,
- 0, NULL, CREATE_ALWAYS,
- FILE_ATTRIBUTE_NORMAL, NULL);
- if (download_file_ == INVALID_HANDLE_VALUE) {
+#if defined(OS_WIN)
+ download_file_path_.Append(UTF8ToWide(request_url.ExtractFileName()));
+#else
+ download_file_path_.Append(request_url.ExtractFileName());
+#endif
+
+ download_file_->Open(download_file_path_,
+ base::PLATFORM_FILE_CREATE_ALWAYS |
+ base::PLATFORM_FILE_READ | base::PLATFORM_FILE_WRITE);
+ if (!download_file_->IsOpen()) {
NOTREACHED();
OnDownloadCompleted(request);
return;
@@ -181,7 +193,7 @@ void PluginDownloadUrlHelper::OnResponseStarted(URLRequest* request) {
void PluginDownloadUrlHelper::OnReadCompleted(URLRequest* request,
int bytes_read) {
- DCHECK(download_file_ != INVALID_HANDLE_VALUE);
+ DCHECK(download_file_->IsOpen());
if (bytes_read == 0) {
OnDownloadCompleted(request);
@@ -191,13 +203,11 @@ void PluginDownloadUrlHelper::OnReadCompleted(URLRequest* request,
int request_bytes_read = bytes_read;
while (request->status().is_success()) {
- unsigned long bytes_written = 0;
- BOOL write_result = WriteFile(download_file_,
- download_file_buffer_->data(),
- request_bytes_read, &bytes_written, NULL);
- DCHECK(!write_result || (bytes_written == request_bytes_read));
+ int bytes_written = download_file_->Write(download_file_buffer_->data(),
+ request_bytes_read, NULL);
+ DCHECK((bytes_written < 0) || (bytes_written == request_bytes_read));
- if (!write_result || (bytes_written != request_bytes_read)) {
+ if ((bytes_written < 0) || (bytes_written != request_bytes_read)) {
DownloadCompletedHelper(false);
break;
}
@@ -223,7 +233,7 @@ void PluginDownloadUrlHelper::OnDownloadCompleted(URLRequest* request) {
bool success = true;
if (!request->status().is_success()) {
success = false;
- } else if (download_file_ == INVALID_HANDLE_VALUE) {
+ } else if (!download_file_->IsOpen()) {
success = false;
}
@@ -231,23 +241,27 @@ void PluginDownloadUrlHelper::OnDownloadCompleted(URLRequest* request) {
}
void PluginDownloadUrlHelper::DownloadCompletedHelper(bool success) {
- if (download_file_ != INVALID_HANDLE_VALUE) {
- ::CloseHandle(download_file_);
- download_file_ = INVALID_HANDLE_VALUE;
+ if (download_file_->IsOpen()) {
+ download_file_.reset();
}
+#if defined(OS_WIN)
+ std::wstring path = download_file_path_.value();
COPYDATASTRUCT download_file_data = {0};
download_file_data.cbData =
- static_cast<unsigned long>((download_file_path_.length() + 1) *
- sizeof(wchar_t));
- download_file_data.lpData =
- const_cast<wchar_t *>(download_file_path_.c_str());
+ static_cast<unsigned long>((path.length() + 1) * sizeof(wchar_t));
+ download_file_data.lpData = const_cast<wchar_t *>(path.c_str());
download_file_data.dwData = success;
if (::IsWindow(download_file_caller_window_)) {
::SendMessage(download_file_caller_window_, WM_COPYDATA, NULL,
reinterpret_cast<LPARAM>(&download_file_data));
}
+#else
+ // TODO(port): Send the file data to the caller.
+ NOTIMPLEMENTED();
+#endif
+
// Don't access any members after this.
delete this;
}
@@ -272,6 +286,7 @@ class SendReplyTask : public Task {
IPC::Message* reply_msg_;
};
+#if defined(OS_WIN)
// Creates a child window of the given HWND on the UI thread.
class CreateWindowTask : public Task {
@@ -322,7 +337,7 @@ class CreateWindowTask : public Task {
// Destroys the given window on the UI thread.
class DestroyWindowTask : public Task {
public:
- DestroyWindowTask(HWND window) : window_(window) { }
+ explicit DestroyWindowTask(HWND window) : window_(window) { }
virtual void Run() {
DestroyWindow(window_);
@@ -333,6 +348,19 @@ class DestroyWindowTask : public Task {
HWND window_;
};
+void PluginProcessHost::OnCreateWindow(HWND parent,
+ IPC::Message* reply_msg) {
+ // Need to create this window on the UI thread.
+ PluginService::GetInstance()->main_message_loop()->PostTask(
+ FROM_HERE, new CreateWindowTask(info_.path, parent, reply_msg));
+}
+
+void PluginProcessHost::OnDestroyWindow(HWND window) {
+ PluginService::GetInstance()->main_message_loop()->PostTask(
+ FROM_HERE, new DestroyWindowTask(window));
+}
+
+#endif // defined(OS_WIN)
PluginProcessHost::PluginProcessHost(MessageLoop* main_message_loop)
: ChildProcessHost(PLUGIN_PROCESS, main_message_loop),
@@ -389,7 +417,7 @@ bool PluginProcessHost::Init(const WebPluginInfo& info,
switches::kUseLowFragHeapCrt,
};
- for (int i = 0; i < arraysize(switch_names); ++i) {
+ for (size_t i = 0; i < arraysize(switch_names); ++i) {
if (browser_command_line.HasSwitch(switch_names[i])) {
cmd_line.AppendSwitchWithValue(
switch_names[i],
@@ -429,10 +457,10 @@ bool PluginProcessHost::Init(const WebPluginInfo& info,
bool in_sandbox = !browser_command_line.HasSwitch(switches::kNoSandbox) &&
browser_command_line.HasSwitch(switches::kSafePlugins);
- bool child_needs_help =
- DebugFlags::ProcessDebugFlags(&cmd_line, type(), in_sandbox);
-
if (in_sandbox) {
+#if defined(OS_WIN)
+ bool child_needs_help = DebugFlags::ProcessDebugFlags(&cmd_line, type(),
+ in_sandbox);
// spawn the child process in the sandbox
sandbox::BrokerServices* broker_service =
g_browser_process->broker_services();
@@ -470,9 +498,13 @@ bool PluginProcessHost::Init(const WebPluginInfo& info,
// the process is in a sandbox.
if (child_needs_help)
DebugUtil::SpawnDebuggerOnProcess(target.dwProcessId);
+#else
+ // TODO(port): Implement sandboxing.
+ NOTIMPLEMENTED() << "no support for sandboxing.";
+#endif
} else {
// spawn child process
- HANDLE handle;
+ base::ProcessHandle handle;
if (!base::LaunchApp(cmd_line, false, false, &handle))
return false;
SetHandle(handle);
@@ -494,6 +526,7 @@ bool PluginProcessHost::Init(const WebPluginInfo& info,
}
void PluginProcessHost::OnMessageReceived(const IPC::Message& msg) {
+#if defined(OS_WIN)
IPC_BEGIN_MESSAGE_MAP(PluginProcessHost, msg)
IPC_MESSAGE_HANDLER(PluginProcessHostMsg_ChannelCreated, OnChannelCreated)
IPC_MESSAGE_HANDLER(PluginProcessHostMsg_DownloadUrl, OnDownloadUrl)
@@ -515,6 +548,10 @@ void PluginProcessHost::OnMessageReceived(const IPC::Message& msg) {
IPC_MESSAGE_HANDLER(PluginProcessHostMsg_DestroyWindow, OnDestroyWindow)
IPC_MESSAGE_UNHANDLED_ERROR()
IPC_END_MESSAGE_MAP()
+#else
+ // TODO(port): Port plugin_messages_internal.h.
+ NOTIMPLEMENTED();
+#endif
}
void PluginProcessHost::OnChannelConnected(int32 peer_pid) {
@@ -629,9 +666,14 @@ void PluginProcessHost::OnResolveProxy(const GURL& url,
void PluginProcessHost::OnResolveProxyCompleted(IPC::Message* reply_msg,
int result,
const std::string& proxy_list) {
+#if defined(OS_WIN)
PluginProcessHostMsg_ResolveProxy::WriteReplyParams(
reply_msg, result, proxy_list);
Send(reply_msg);
+#else
+ // TODO(port): Port plugin_messages_internal.h.
+ NOTIMPLEMENTED();
+#endif
}
void PluginProcessHost::ReplyToRenderer(
@@ -646,6 +688,7 @@ void PluginProcessHost::ReplyToRenderer(
void PluginProcessHost::RequestPluginChannel(
ResourceMessageFilter* renderer_message_filter,
const std::string& mime_type, IPC::Message* reply_msg) {
+#if defined(OS_WIN)
// We can't send any sync messages from the browser because it might lead to
// a hang. However this async messages must be answered right away by the
// plugin process (i.e. unblocks a Send() call like a sync message) otherwise
@@ -672,6 +715,10 @@ void PluginProcessHost::RequestPluginChannel(
ReplyToRenderer(renderer_message_filter, std::wstring(), FilePath(),
reply_msg);
}
+#else
+ // TODO(port): Figure out what the plugin process is expecting in this case.
+ NOTIMPLEMENTED();
+#endif
}
void PluginProcessHost::OnChannelCreated(int process_id,
@@ -693,7 +740,8 @@ void PluginProcessHost::OnChannelCreated(int process_id,
}
void PluginProcessHost::OnDownloadUrl(const std::string& url,
- int source_pid, HWND caller_window) {
+ int source_pid,
+ gfx::NativeWindow caller_window) {
PluginDownloadUrlHelper* download_url_helper =
new PluginDownloadUrlHelper(url, source_pid, caller_window);
download_url_helper->InitiateDownload();
@@ -711,6 +759,7 @@ void PluginProcessHost::OnGetPluginFinderUrl(std::string* plugin_finder_url) {
}
void PluginProcessHost::OnPluginShutdownRequest() {
+#if defined(OS_WIN)
DCHECK(MessageLoop::current() ==
ChromeThread::GetMessageLoop(ChromeThread::IO));
@@ -718,6 +767,10 @@ void PluginProcessHost::OnPluginShutdownRequest() {
// refuse the shutdown request from the plugin process.
bool ok_to_shutdown = sent_requests_.empty();
Send(new PluginProcessMsg_ShutdownResponse(ok_to_shutdown));
+#else
+ // TODO(port): Port plugin_messages_internal.h.
+ NOTIMPLEMENTED();
+#endif
}
void PluginProcessHost::OnPluginMessage(
@@ -733,17 +786,11 @@ void PluginProcessHost::OnPluginMessage(
}
}
-void PluginProcessHost::OnCreateWindow(HWND parent, IPC::Message* reply_msg) {
- // Need to create this window on the UI thread.
- PluginService::GetInstance()->main_message_loop()->PostTask(
- FROM_HERE, new CreateWindowTask(info_.path, parent, reply_msg));
-}
-
-void PluginProcessHost::OnDestroyWindow(HWND window) {
- PluginService::GetInstance()->main_message_loop()->PostTask(
- FROM_HERE, new DestroyWindowTask(window));
-}
-
void PluginProcessHost::Shutdown() {
+#if defined(OS_WIN)
Send(new PluginProcessMsg_BrowserShutdown);
+#else
+ // TODO(port): Port plugin_messages_internal.h.
+ NOTIMPLEMENTED();
+#endif
}
diff --git a/chrome/browser/plugin_process_host.h b/chrome/browser/plugin_process_host.h
index 78b4f9d..b9a5681 100644
--- a/chrome/browser/plugin_process_host.h
+++ b/chrome/browser/plugin_process_host.h
@@ -5,9 +5,12 @@
#ifndef CHROME_BROWSER_PLUGIN_PROCESS_HOST_H_
#define CHROME_BROWSER_PLUGIN_PROCESS_HOST_H_
+#include "build/build_config.h"
+
#include <vector>
#include "base/basictypes.h"
+#include "base/gfx/native_widget_types.h"
#include "base/scoped_ptr.h"
#include "base/task.h"
#include "chrome/browser/net/resolve_proxy_msg_helper.h"
@@ -87,7 +90,7 @@ class PluginProcessHost : public ChildProcessHost,
// Message handlers.
void OnChannelCreated(int process_id, const std::wstring& channel_name);
void OnDownloadUrl(const std::string& url, int source_pid,
- HWND caller_window);
+ gfx::NativeWindow caller_window);
void OnGetPluginFinderUrl(std::string* plugin_finder_url);
void OnRequestResource(const IPC::Message& message,
int request_id,
@@ -103,14 +106,17 @@ class PluginProcessHost : public ChildProcessHost,
void OnResolveProxy(const GURL& url, IPC::Message* reply_msg);
void OnPluginShutdownRequest();
void OnPluginMessage(const std::vector<uint8>& data);
+
+#if defined(OS_WIN)
void OnCreateWindow(HWND parent, IPC::Message* reply_msg);
void OnDestroyWindow(HWND window);
+#endif
struct ChannelRequest {
ChannelRequest(ResourceMessageFilter* renderer_message_filter,
- const std::string& m, IPC::Message* r) :
- renderer_message_filter_(renderer_message_filter), mime_type(m),
- reply_msg(r) { }
+ const std::string& m, IPC::Message* r) :
+ mime_type(m), reply_msg(r),
+ renderer_message_filter_(renderer_message_filter) { }
std::string mime_type;
IPC::Message* reply_msg;
scoped_refptr<ResourceMessageFilter> renderer_message_filter_;
diff --git a/chrome/browser/plugin_service.cc b/chrome/browser/plugin_service.cc
index ea25346..584c3d6 100644
--- a/chrome/browser/plugin_service.cc
+++ b/chrome/browser/plugin_service.cc
@@ -11,6 +11,7 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_plugin_host.h"
#include "chrome/browser/chrome_thread.h"
+#include "chrome/browser/plugin_process_host.h"
#include "chrome/browser/renderer_host/render_process_host.h"
#include "chrome/browser/renderer_host/resource_message_filter.h"
#include "chrome/common/chrome_plugin_lib.h"
@@ -18,13 +19,6 @@
#include "chrome/common/logging_chrome.h"
#include "webkit/glue/plugins/plugin_list.h"
-#if defined(OS_WIN)
-// TODO(port): port this file and get rid of child_process_info.h include.
-#include "chrome/browser/plugin_process_host.h"
-#else
-#include "chrome/common/child_process_info.h"
-#endif
-
// static
PluginService* PluginService::GetInstance() {
return Singleton<PluginService>::get();
diff --git a/chrome/chrome.xcodeproj/project.pbxproj b/chrome/chrome.xcodeproj/project.pbxproj
index a111037..5ee9e12 100644
--- a/chrome/chrome.xcodeproj/project.pbxproj
+++ b/chrome/chrome.xcodeproj/project.pbxproj
@@ -82,6 +82,7 @@
0FF05474D5345CABC5C85B5F /* save_package_unittest.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D7BF9DC0E9D48CE009A6919 /* save_package_unittest.cc */; };
1647A33CB5B4B14087BFF5C8 /* dns_global.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D7BFA680E9D4981009A6919 /* dns_global.cc */; };
1C284EB767D0E3D302AC675C /* tab_restore_service.cc in Sources */ = {isa = PBXBuildFile; fileRef = B020A11D500D7519E54F2957 /* tab_restore_service.cc */; };
+ 1FFE452BCABBD0158B029D4D /* plugin_process_host.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D7BF8DD0E9D4839009A6919 /* plugin_process_host.cc */; };
2760C4346D6AB3AD94E9CF05 /* url_fixer_upper.cc in Sources */ = {isa = PBXBuildFile; fileRef = B5D16EF40F2145C600861FAC /* url_fixer_upper.cc */; };
28283DBE4B6DB2B0F9893676 /* dns_master.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D7BFA6D0E9D4981009A6919 /* dns_master.cc */; };
2DF2A9EB8AF96926EE9B6B02 /* ipc_logging.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D7BFBAE0E9D4C9F009A6919 /* ipc_logging.cc */; };
@@ -248,6 +249,7 @@
544FBC49CB83E458B6B7069D /* test_web_contents.cc in Sources */ = {isa = PBXBuildFile; fileRef = 56E1D7DF17D327BFCB0B895D /* test_web_contents.cc */; };
5DD7664089E8660524ED1CBC /* child_thread.cc in Sources */ = {isa = PBXBuildFile; fileRef = E81681ADC802675FE949BC63 /* child_thread.cc */; };
623E5BE905E098E8280304DA /* dns_master_unittest.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D7BFA6F0E9D4981009A6919 /* dns_master_unittest.cc */; };
+ 651621527E9FCD7FB5AF2E14 /* child_process_host.cc in Sources */ = {isa = PBXBuildFile; fileRef = 5EE47CAC5E11F4B35E564CCE /* child_process_host.cc */; };
65930533A98EF22451EEA01D /* history_publisher_none.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7849CCC221723C1BC14D6384 /* history_publisher_none.cc */; };
6685F5375CC4ECE98C4C2213 /* browser_about_handler.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D7BF8320E9D4839009A6919 /* browser_about_handler.cc */; };
671555F7DF06E224B646E5D2 /* backing_store_posix.cc in Sources */ = {isa = PBXBuildFile; fileRef = B94B5B0CBF4D7FAC48BB1AE2 /* backing_store_posix.cc */; };
@@ -2423,6 +2425,7 @@
4F9429998AC2703984BAB828 /* resolve_proxy_msg_helper.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = resolve_proxy_msg_helper.cc; sourceTree = "<group>"; };
534E66C30F311BEC0006B2B2 /* temp_scaffolding_stubs.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = temp_scaffolding_stubs.cc; sourceTree = "<group>"; };
56E1D7DF17D327BFCB0B895D /* test_web_contents.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = test_web_contents.cc; path = tab_contents/test_web_contents.cc; sourceTree = "<group>"; };
+ 5EE47CAC5E11F4B35E564CCE /* child_process_host.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = child_process_host.cc; sourceTree = "<group>"; };
622534301BD3F4A908D426D0 /* user_data_manager.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = user_data_manager.cc; sourceTree = "<group>"; };
629BF493DEA096E2DD844F2B /* autofill_manager.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = autofill_manager.cc; sourceTree = "<group>"; };
6447F24FADC63E58A44DB762 /* url_pattern.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = url_pattern.cc; path = extensions/url_pattern.cc; sourceTree = "<group>"; };
@@ -3650,6 +3653,7 @@
4D7BFB880E9D4C9F009A6919 /* bzip2_unittest.cc */,
4D7BFB890E9D4C9F009A6919 /* child_process.cc */,
4D7BFB8A0E9D4C9F009A6919 /* child_process.h */,
+ 5EE47CAC5E11F4B35E564CCE /* child_process_host.cc */,
BA9BC2620F44DCBE00588450 /* child_process_info.cc */,
BA9BC2630F44DCC400588450 /* child_process_info.h */,
E81681ADC802675FE949BC63 /* child_thread.cc */,
@@ -5440,6 +5444,7 @@
4D7BF98D0E9D485B009A6919 /* cancelable_request.cc in Sources */,
E765478D55A73228BAD044E3 /* cert_store.cc in Sources */,
6A3646C882BD4CC722624544 /* character_encoding.cc in Sources */,
+ 651621527E9FCD7FB5AF2E14 /* child_process_host.cc in Sources */,
E43A770D0F16610300ABD5D1 /* chrome_plugin_browsing_context.cc in Sources */,
4D7BF9920E9D485F009A6919 /* chrome_thread.cc in Sources */,
E43A771C0F1661AF00ABD5D1 /* chrome_url_data_manager.cc in Sources */,
@@ -5498,6 +5503,7 @@
4D7BFA280E9D490C009A6919 /* page_usage_data.cc in Sources */,
E48B6C2C0F27840B002E47EC /* password_form_manager.cc in Sources */,
EA8058FD371756B46906B157 /* password_manager.cc in Sources */,
+ 1FFE452BCABBD0158B029D4D /* plugin_process_host.cc in Sources */,
0A124E6F8B659427ABF96220 /* plugin_service.cc in Sources */,
826847800F2F69D1009F6555 /* profile.cc in Sources */,
8268477F0F2F69D1009F6555 /* profile_manager.cc in Sources */,
diff --git a/chrome/common/child_process_host.cc b/chrome/common/child_process_host.cc
index ac3c681..66d3ebf 100644
--- a/chrome/common/child_process_host.cc
+++ b/chrome/common/child_process_host.cc
@@ -8,6 +8,7 @@
#include "base/logging.h"
#include "base/message_loop.h"
#include "base/singleton.h"
+#include "base/waitable_event.h"
#include "chrome/browser/chrome_thread.h"
#include "chrome/common/ipc_logging.h"
#include "chrome/common/notification_service.h"
@@ -40,9 +41,10 @@ class ChildNotificationTask : public Task {
ChildProcessHost::ChildProcessHost(
ProcessType type, MessageLoop* main_message_loop)
: ChildProcessInfo(type),
+ ALLOW_THIS_IN_INITIALIZER_LIST(listener_(this)),
main_message_loop_(main_message_loop),
opening_channel_(false),
- ALLOW_THIS_IN_INITIALIZER_LIST(listener_(this)) {
+ process_event_(NULL) {
Singleton<ChildProcessList>::get()->push_back(this);
}
@@ -69,9 +71,13 @@ bool ChildProcessHost::CreateChannel() {
}
void ChildProcessHost::SetHandle(base::ProcessHandle process) {
- DCHECK(handle() == NULL);
+#if defined(OS_WIN)
+ process_event_.reset(new base::WaitableEvent(process));
+
+ DCHECK(!handle());
set_handle(process);
- watcher_.StartWatching(process, this);
+ watcher_.StartWatching(process_event_.get(), this);
+#endif
}
void ChildProcessHost::InstanceCreated() {
@@ -91,7 +97,9 @@ void ChildProcessHost::Notify(NotificationType type) {
FROM_HERE, new ChildNotificationTask(type, this));
}
-void ChildProcessHost::OnObjectSignaled(HANDLE object) {
+void ChildProcessHost::OnWaitableEventSignaled(base::WaitableEvent *event) {
+#if defined(OS_WIN)
+ HANDLE object = event->handle();
DCHECK(handle());
DCHECK_EQ(object, handle());
@@ -102,12 +110,11 @@ void ChildProcessHost::OnObjectSignaled(HANDLE object) {
}
// Notify in the main loop of the disconnection.
Notify(NotificationType::CHILD_PROCESS_HOST_DISCONNECTED);
+#endif
delete this;
}
-
-
ChildProcessHost::ListenerHook::ListenerHook(ChildProcessHost* host)
: host_(host) {
}
diff --git a/chrome/common/child_process_host.h b/chrome/common/child_process_host.h
index 01db515..4f173fc 100644
--- a/chrome/common/child_process_host.h
+++ b/chrome/common/child_process_host.h
@@ -5,10 +5,13 @@
#ifndef CHROME_COMMON_CHILD_PROCESS_HOST_H_
#define CHROME_COMMON_CHILD_PROCESS_HOST_H_
+#include "build/build_config.h"
+
#include <list>
#include "base/basictypes.h"
-#include "base/object_watcher.h"
+#include "base/scoped_ptr.h"
+#include "base/waitable_event_watcher.h"
#include "chrome/common/child_process_info.h"
#include "chrome/common/ipc_channel.h"
@@ -18,7 +21,7 @@ class NotificationType;
// Plugins/workers and other child processes that live on the IO thread should
// derive from this class.
class ChildProcessHost : public ChildProcessInfo,
- public base::ObjectWatcher::Delegate,
+ public base::WaitableEventWatcher::Delegate,
public IPC::Channel::Listener,
public IPC::Message::Sender {
public:
@@ -72,8 +75,8 @@ class ChildProcessHost : public ChildProcessInfo,
// Sends the given notification to the notification service on the UI thread.
void Notify(NotificationType type);
- // ObjectWatcher::Delegate implementation:
- virtual void OnObjectSignaled(HANDLE object);
+ // WaitableEventWatcher::Delegate implementation:
+ virtual void OnWaitableEventSignaled(base::WaitableEvent *event);
// By using an internal class as the IPC::Channel::Listener, we can intercept
// OnMessageReceived/OnChannelConnected and do our own processing before
@@ -102,7 +105,9 @@ class ChildProcessHost : public ChildProcessInfo,
std::wstring channel_id_;
// Used to watch the child process handle.
- base::ObjectWatcher watcher_;
+ base::WaitableEventWatcher watcher_;
+
+ scoped_ptr<base::WaitableEvent> process_event_;
};
#endif // CHROME_COMMON_CHILD_PROCESS_HOST_H_
diff --git a/chrome/common/common.scons b/chrome/common/common.scons
index cc5e95d..70775cc 100644
--- a/chrome/common/common.scons
+++ b/chrome/common/common.scons
@@ -238,8 +238,6 @@ if not env.Bit('windows'):
'gfx/path.cc',
'os_exchange_data.cc',
'process_watcher.cc',
- 'child_process_host.cc',
- 'child_process_host.h',
)
if not env.Bit('windows'):
diff --git a/chrome/common/temp_scaffolding_stubs.h b/chrome/common/temp_scaffolding_stubs.h
index 8e70e60..8f8ec0e 100644
--- a/chrome/common/temp_scaffolding_stubs.h
+++ b/chrome/common/temp_scaffolding_stubs.h
@@ -256,6 +256,21 @@ class DownloadRequestManager
namespace sandbox {
+enum ResultCode {
+ SBOX_ALL_OK = 0,
+ SBOX_ERROR_GENERIC = 1,
+ SBOX_ERROR_BAD_PARAMS = 2,
+ SBOX_ERROR_UNSUPPORTED = 3,
+ SBOX_ERROR_NO_SPACE = 4,
+ SBOX_ERROR_INVALID_IPC = 5,
+ SBOX_ERROR_FAILED_IPC = 6,
+ SBOX_ERROR_NO_HANDLE = 7,
+ SBOX_ERROR_UNEXPECTED_CALL = 8,
+ SBOX_ERROR_WAIT_ALREADY_CALLED = 9,
+ SBOX_ERROR_CHANNEL_ERROR = 10,
+ SBOX_ERROR_LAST
+};
+
class BrokerServices {
public:
void Init() { NOTIMPLEMENTED(); }
@@ -568,58 +583,6 @@ class PluginInstaller {
PluginInstaller(WebContents*) { }
};
-class ChildProcessHost : public ChildProcessInfo {
- public:
- class Iterator {
- public:
- explicit Iterator(ProcessType type) { NOTIMPLEMENTED(); }
- ChildProcessInfo* operator->() { return *iterator_; }
- ChildProcessInfo* operator*() { return *iterator_; }
- ChildProcessInfo* operator++() { return NULL; }
- bool Done() {
- NOTIMPLEMENTED();
- return true;
- }
- private:
- std::list<ChildProcessInfo*>::iterator iterator_;
- };
- protected:
- ChildProcessHost(ProcessType type, MessageLoop* main_message_loop)
- : ChildProcessInfo(type) {
- NOTIMPLEMENTED();
- }
-};
-
-class PluginProcessHost : public ChildProcessHost {
- public:
- explicit PluginProcessHost(MessageLoop* main_message_loop)
- : ChildProcessHost(PLUGIN_PROCESS, main_message_loop) {
- NOTIMPLEMENTED();
- }
- bool Init(const WebPluginInfo& info,
- const std::string& activex_clsid,
- const std::wstring& locale) {
- NOTIMPLEMENTED();
- return false;
- }
- void OpenChannelToPlugin(ResourceMessageFilter* renderer_message_filter,
- const std::string& mime_type,
- IPC::Message* reply_msg) {
- NOTIMPLEMENTED();
- }
- static void ReplyToRenderer(ResourceMessageFilter* renderer_message_filter,
- const std::wstring& channel,
- const FilePath& plugin_path,
- IPC::Message* reply_msg) {
- NOTIMPLEMENTED();
- }
- void Shutdown() { NOTIMPLEMENTED(); }
- const WebPluginInfo& info() const { return info_; }
- private:
- WebPluginInfo info_;
- DISALLOW_EVIL_CONSTRUCTORS(PluginProcessHost);
-};
-
class HungRendererWarning {
public:
static void HideForWebContents(WebContents*) { NOTIMPLEMENTED(); }