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/renderer/webworker_context_proxy.h" |
| 6 |
| 7 #include "chrome/common/render_messages.h" |
| 8 #include "chrome/common/worker_messages.h" |
| 9 #include "chrome/renderer/render_view.h" |
| 10 |
| 11 WebWorkerContextProxyImpl::WebWorkerContextProxyImpl(RenderView* render_view) |
| 12 : render_view_(render_view), route_id_(MSG_ROUTING_NONE) { |
| 13 } |
| 14 |
| 15 WebWorkerContextProxyImpl::~WebWorkerContextProxyImpl() { |
| 16 } |
| 17 |
| 18 void WebWorkerContextProxyImpl::StartWorkerContext( |
| 19 const GURL& script_url, |
| 20 const std::string& user_agent, |
| 21 const std::string& source_code) { |
| 22 render_view_->Send( |
| 23 new ViewHostMsg_CreateDedicatedWorker(script_url, &route_id_)); |
| 24 if (route_id_ == MSG_ROUTING_NONE) |
| 25 return; |
| 26 |
| 27 Send(new WorkerMsg_StartContext(route_id_, user_agent, source_code)); |
| 28 } |
| 29 |
| 30 void WebWorkerContextProxyImpl::TerminateWorkerContext() { |
| 31 } |
| 32 |
| 33 void WebWorkerContextProxyImpl::PostMessageToWorkerContext(const std::string&) { |
| 34 } |
| 35 |
| 36 bool WebWorkerContextProxyImpl::HasPendingActivity() const { |
| 37 return true; |
| 38 } |
| 39 |
| 40 void WebWorkerContextProxyImpl::WorkerObjectDestroyed() { |
| 41 } |
| 42 |
| 43 bool WebWorkerContextProxyImpl::Send(IPC::Message* msg) { |
| 44 // For now we proxy all messages to the worker process through the browser. |
| 45 // Revisit if we find this slow. |
| 46 // TODO(jabdelmalek): handle sync messages. |
| 47 IPC::Message* wrapped_msg = new ViewHostMsg_ForwardToWorker(*msg); |
| 48 delete msg; |
| 49 return render_view_->Send(wrapped_msg); |
| 50 } |
OLD | NEW |