| Index: chrome/browser/worker_process_host.cc
|
| ===================================================================
|
| --- chrome/browser/worker_process_host.cc (revision 0)
|
| +++ chrome/browser/worker_process_host.cc (revision 0)
|
| @@ -0,0 +1,73 @@
|
| +// Copyright (c) 2009 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "chrome/browser/worker_process_host.h"
|
| +
|
| +#include <windows.h>
|
| +
|
| +#include "base/command_line.h"
|
| +#include "base/debug_util.h"
|
| +#include "base/logging.h"
|
| +#include "base/path_service.h"
|
| +#include "base/process_util.h"
|
| +#include "chrome/browser/browser_process.h"
|
| +#include "chrome/browser/worker_service.h"
|
| +#include "chrome/browser/sandbox_policy.h"
|
| +#include "chrome/common/chrome_switches.h"
|
| +#include "chrome/common/debug_flags.h"
|
| +#include "chrome/common/process_watcher.h"
|
| +#include "chrome/common/render_messages.h"
|
| +#include "chrome/common/worker_messages.h"
|
| +#include "sandbox/src/sandbox.h"
|
| +
|
| +
|
| +WorkerProcessHost::WorkerProcessHost(MessageLoop* main_message_loop)
|
| + : ChildProcessHost(WORKER_PROCESS, main_message_loop) {
|
| +}
|
| +
|
| +WorkerProcessHost::~WorkerProcessHost() {
|
| +}
|
| +
|
| +bool WorkerProcessHost::Init() {
|
| + // TODO(jabdelmalek): figure out what to set as the title.
|
| + set_name(L"TBD");
|
| +
|
| + if (!CreateChannel())
|
| + return false;
|
| +
|
| + std::wstring exe_path;
|
| + if (!PathService::Get(base::FILE_EXE, &exe_path))
|
| + return false;
|
| +
|
| + CommandLine cmd_line(exe_path);
|
| +
|
| + // TODO(jabdelmalek): factor out common code from renderer/plugin that does
|
| + // sandboxing and command line copying and reuse here.
|
| + cmd_line.AppendSwitchWithValue(switches::kProcessType,
|
| + switches::kWorkerProcess);
|
| + cmd_line.AppendSwitchWithValue(switches::kProcessChannelID, channel_id());
|
| + HANDLE handle;
|
| + if (!base::LaunchApp(cmd_line, false, false, &handle))
|
| + return false;
|
| + SetHandle(handle);
|
| +
|
| + return true;
|
| +}
|
| +
|
| +void WorkerProcessHost::CreateWorker(const GURL& url, int route_id) {
|
| + route_ids_.insert(route_id);
|
| + Send(new WorkerProcessMsg_CreateWorker(url, route_id));
|
| +}
|
| +
|
| +bool WorkerProcessHost::HasRouteId(int id) {
|
| + return route_ids_.find(id) != route_ids_.end();
|
| +}
|
| +
|
| +void WorkerProcessHost::OnMessageReceived(const IPC::Message& msg) {
|
| +/*
|
| + IPC_BEGIN_MESSAGE_MAP(WorkerProcessHost, msg)
|
| + IPC_MESSAGE_UNHANDLED_ERROR()
|
| + IPC_END_MESSAGE_MAP()
|
| +*/
|
| +}
|
|
|