Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4888)

Unified Diff: chrome/browser/worker_host/worker_service.cc

Issue 27157: Initial checkin of the out of process worker implementation.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/worker_host/worker_service.h ('k') | chrome/chrome.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/worker_host/worker_service.cc
===================================================================
--- chrome/browser/worker_host/worker_service.cc (revision 0)
+++ chrome/browser/worker_host/worker_service.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_host/worker_service.h"
+
+#include "base/singleton.h"
+#include "base/thread.h"
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/plugin_service.h"
+#include "chrome/browser/worker_host/worker_process_host.h"
+#include "chrome/browser/renderer_host/render_process_host.h"
+#include "chrome/browser/renderer_host/resource_message_filter.h"
+
+WorkerService* WorkerService::GetInstance() {
+ return Singleton<WorkerService>::get();
+}
+
+WorkerService::WorkerService() : next_worker_route_id_(0) {
+}
+
+WorkerService::~WorkerService() {
+}
+
+bool WorkerService::CreateDedicatedWorker(const GURL &url,
+ ResourceMessageFilter* filter,
+ int renderer_route_id) {
+ WorkerProcessHost* worker = NULL;
+ // One worker process for quick bringup!
+ for (ChildProcessHost::Iterator iter(ChildProcessInfo::WORKER_PROCESS);
+ !iter.Done(); ++iter) {
+ worker = static_cast<WorkerProcessHost*>(*iter);
+ break;
+ }
+
+ if (!worker) {
+ // TODO(jabdelmalek): there has to be a better way to get the main message
+ // loop than to go through PluginService.
+ worker = new WorkerProcessHost(
+ PluginService::GetInstance()->main_message_loop());
+ if (!worker->Init()) {
+ delete worker;
+ return false;
+ }
+ }
+
+ // Generate a unique route id for the browser-worker communication that's
+ // unique among all worker processes. That way when the worker process sends
+ // a wrapped IPC message through us, we know which WorkerProcessHost to give
+ // it to.
+ worker->CreateWorker(url, ++next_worker_route_id_, renderer_route_id, filter);
+
+ return true;
+}
+
+void WorkerService::ForwardMessage(const IPC::Message& message) {
+ for (ChildProcessHost::Iterator iter(ChildProcessInfo::WORKER_PROCESS);
+ !iter.Done(); ++iter) {
+ WorkerProcessHost* worker = static_cast<WorkerProcessHost*>(*iter);
+ if (worker->FilterMessage(message))
+ return;
+ }
+
+ // TODO(jabdelmalek): tell sender that callee is gone
+}
+
+void WorkerService::RendererShutdown(ResourceMessageFilter* filter) {
+ for (ChildProcessHost::Iterator iter(ChildProcessInfo::WORKER_PROCESS);
+ !iter.Done(); ++iter) {
+ WorkerProcessHost* worker = static_cast<WorkerProcessHost*>(*iter);
+ worker->RendererShutdown(filter);
+ }
+}
« no previous file with comments | « chrome/browser/worker_host/worker_service.h ('k') | chrome/chrome.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698