OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/worker_process_host.h" |
| 6 |
| 7 #include <windows.h> |
| 8 |
| 9 #include "base/command_line.h" |
| 10 #include "base/debug_util.h" |
| 11 #include "base/logging.h" |
| 12 #include "base/path_service.h" |
| 13 #include "base/process_util.h" |
| 14 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/browser/worker_service.h" |
| 16 #include "chrome/browser/sandbox_policy.h" |
| 17 #include "chrome/common/chrome_switches.h" |
| 18 #include "chrome/common/debug_flags.h" |
| 19 #include "chrome/common/process_watcher.h" |
| 20 #include "chrome/common/render_messages.h" |
| 21 #include "chrome/common/worker_messages.h" |
| 22 #include "sandbox/src/sandbox.h" |
| 23 |
| 24 |
| 25 WorkerProcessHost::WorkerProcessHost(MessageLoop* main_message_loop) |
| 26 : ChildProcessHost(WORKER_PROCESS, main_message_loop) { |
| 27 } |
| 28 |
| 29 WorkerProcessHost::~WorkerProcessHost() { |
| 30 } |
| 31 |
| 32 bool WorkerProcessHost::Init() { |
| 33 // TODO(jabdelmalek): figure out what to set as the title. |
| 34 set_name(L"TBD"); |
| 35 |
| 36 if (!CreateChannel()) |
| 37 return false; |
| 38 |
| 39 std::wstring exe_path; |
| 40 if (!PathService::Get(base::FILE_EXE, &exe_path)) |
| 41 return false; |
| 42 |
| 43 CommandLine cmd_line(exe_path); |
| 44 |
| 45 // TODO(jabdelmalek): factor out common code from renderer/plugin that does |
| 46 // sandboxing and command line copying and reuse here. |
| 47 cmd_line.AppendSwitchWithValue(switches::kProcessType, |
| 48 switches::kWorkerProcess); |
| 49 cmd_line.AppendSwitchWithValue(switches::kProcessChannelID, channel_id()); |
| 50 HANDLE handle; |
| 51 if (!base::LaunchApp(cmd_line, false, false, &handle)) |
| 52 return false; |
| 53 SetHandle(handle); |
| 54 |
| 55 return true; |
| 56 } |
| 57 |
| 58 void WorkerProcessHost::CreateWorker(const GURL& url, int route_id) { |
| 59 route_ids_.insert(route_id); |
| 60 Send(new WorkerProcessMsg_CreateWorker(url, route_id)); |
| 61 } |
| 62 |
| 63 bool WorkerProcessHost::HasRouteId(int id) { |
| 64 return route_ids_.find(id) != route_ids_.end(); |
| 65 } |
| 66 |
| 67 void WorkerProcessHost::OnMessageReceived(const IPC::Message& msg) { |
| 68 /* |
| 69 IPC_BEGIN_MESSAGE_MAP(WorkerProcessHost, msg) |
| 70 IPC_MESSAGE_UNHANDLED_ERROR() |
| 71 IPC_END_MESSAGE_MAP() |
| 72 */ |
| 73 } |
OLD | NEW |