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

Side by Side Diff: chrome/renderer/websharedworker_impl.cc

Issue 340036: Initial pass of shared workers renderer-side code (Closed)
Patch Set: Changes reflecting review feedback Created 11 years, 1 month 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 unified diff | Download patch
OLDNEW
(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/websharedworker_impl.h"
6
7 #include "chrome/common/render_messages.h"
8 #include "chrome/common/webmessageportchannel_impl.h"
9 #include "chrome/common/worker_messages.h"
10 #include "webkit/api/public/WebURL.h"
11
12 WebSharedWorkerImpl::WebSharedWorkerImpl(const GURL& url,
13 const string16& name,
14 ChildThread* child_thread,
15 int route_id,
16 int render_view_route_id)
17 : WebWorkerBase(child_thread, route_id, render_view_route_id),
18 url_(url),
19 name_(name) {
20 }
21
22 bool WebSharedWorkerImpl::isStarted() {
23 return IsStarted();
24 }
25
26 void WebSharedWorkerImpl::startWorkerContext(
27 const WebKit::WebURL& script_url,
28 const WebKit::WebString& user_agent,
29 const WebKit::WebString& source_code) {
30 DCHECK(url_ == script_url);
31 IPC::Message* create_message = new ViewHostMsg_CreateSharedWorker(
32 url_, name_, render_view_route_id_, &route_id_);
33 CreateWorkerContext(create_message, script_url, user_agent, source_code);
34 }
35
36 void WebSharedWorkerImpl::connect(WebKit::WebMessagePortChannel* channel) {
37 WebMessagePortChannelImpl* webchannel =
38 static_cast<WebMessagePortChannelImpl*>(channel);
39
40 int message_port_id = webchannel->message_port_id();
41 DCHECK(message_port_id != MSG_ROUTING_NONE);
42 webchannel->QueueMessages();
43
44 Send(new WorkerMsg_Connect(route_id_, message_port_id, MSG_ROUTING_NONE));
45 }
46
47 void WebSharedWorkerImpl::OnMessageReceived(const IPC::Message& message) {
48 IPC_BEGIN_MESSAGE_MAP(WebSharedWorkerImpl, message)
49 IPC_MESSAGE_HANDLER(ViewMsg_WorkerCreated, OnWorkerCreated)
50 IPC_END_MESSAGE_MAP()
51 }
52
53 void WebSharedWorkerImpl::OnWorkerCreated() {
54 // The worker is created - now send off the CreateWorkerContext message and
55 // any other queued messages
56 SendQueuedMessages();
57 }
58
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698