Index: chrome/renderer/webworker_context_proxy.cc |
=================================================================== |
--- chrome/renderer/webworker_context_proxy.cc (revision 0) |
+++ chrome/renderer/webworker_context_proxy.cc (revision 0) |
@@ -0,0 +1,50 @@ |
+// 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/renderer/webworker_context_proxy.h" |
+ |
+#include "chrome/common/render_messages.h" |
+#include "chrome/common/worker_messages.h" |
+#include "chrome/renderer/render_view.h" |
+ |
+WebWorkerContextProxyImpl::WebWorkerContextProxyImpl(RenderView* render_view) |
+ : render_view_(render_view), route_id_(MSG_ROUTING_NONE) { |
+} |
+ |
+WebWorkerContextProxyImpl::~WebWorkerContextProxyImpl() { |
+} |
+ |
+void WebWorkerContextProxyImpl::StartWorkerContext( |
+ const GURL& script_url, |
+ const std::string& user_agent, |
+ const std::string& source_code) { |
+ render_view_->Send( |
+ new ViewHostMsg_CreateDedicatedWorker(script_url, &route_id_)); |
+ if (route_id_ == MSG_ROUTING_NONE) |
+ return; |
+ |
+ Send(new WorkerMsg_StartContext(route_id_, user_agent, source_code)); |
+} |
+ |
+void WebWorkerContextProxyImpl::TerminateWorkerContext() { |
+} |
+ |
+void WebWorkerContextProxyImpl::PostMessageToWorkerContext(const std::string&) { |
+} |
+ |
+bool WebWorkerContextProxyImpl::HasPendingActivity() const { |
+ return true; |
+} |
+ |
+void WebWorkerContextProxyImpl::WorkerObjectDestroyed() { |
+} |
+ |
+bool WebWorkerContextProxyImpl::Send(IPC::Message* msg) { |
+ // For now we proxy all messages to the worker process through the browser. |
+ // Revisit if we find this slow. |
+ // TODO(jabdelmalek): handle sync messages. |
+ IPC::Message* wrapped_msg = new ViewHostMsg_ForwardToWorker(*msg); |
+ delete msg; |
+ return render_view_->Send(wrapped_msg); |
+} |