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

Side by Side Diff: content/worker/webworker_stub.cc

Issue 8399007: Removing dedicated worker-related IPC codei (first round). (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: CR feedback Created 9 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
« no previous file with comments | « content/worker/webworker_stub.h ('k') | content/worker/webworker_stub_base.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 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 "content/worker/webworker_stub.h"
6
7 #include "base/command_line.h"
8 #include "content/common/child_thread.h"
9 #include "content/common/file_system/file_system_dispatcher.h"
10 #include "content/common/webmessageportchannel_impl.h"
11 #include "content/common/worker_messages.h"
12 #include "content/public/common/content_client.h"
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h"
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWorker.h"
16
17 using WebKit::WebWorker;
18
19 WebWorkerStub::WebWorkerStub(const GURL& url, int route_id,
20 const WorkerAppCacheInitInfo& appcache_init_info)
21 : WebWorkerStubBase(route_id, appcache_init_info),
22 ALLOW_THIS_IN_INITIALIZER_LIST(impl_(WebWorker::create(client()))),
23 url_(url) {
24 }
25
26 WebWorkerStub::~WebWorkerStub() {
27 impl_->clientDestroyed();
28 }
29
30 void WebWorkerStub::OnChannelError() {
31 OnTerminateWorkerContext();
32 }
33
34 const GURL& WebWorkerStub::url() const {
35 return url_;
36 }
37
38 bool WebWorkerStub::OnMessageReceived(const IPC::Message& message) {
39 if (!impl_)
40 return false;
41
42 bool handled = true;
43 IPC_BEGIN_MESSAGE_MAP(WebWorkerStub, message)
44 IPC_MESSAGE_FORWARD(WorkerMsg_StartWorkerContext, impl_,
45 WebWorker::startWorkerContext)
46 IPC_MESSAGE_HANDLER(WorkerMsg_TerminateWorkerContext,
47 OnTerminateWorkerContext)
48 IPC_MESSAGE_HANDLER(WorkerMsg_PostMessage, OnPostMessage)
49 IPC_MESSAGE_FORWARD(WorkerMsg_WorkerObjectDestroyed, impl_,
50 WebWorker::workerObjectDestroyed)
51 IPC_MESSAGE_UNHANDLED(handled = false)
52 IPC_END_MESSAGE_MAP()
53 return handled;
54 }
55
56 void WebWorkerStub::OnTerminateWorkerContext() {
57 impl_->terminateWorkerContext();
58
59 // Call the client to make sure context exits.
60 EnsureWorkerContextTerminates();
61 }
62
63 void WebWorkerStub::OnPostMessage(
64 const string16& message,
65 const std::vector<int>& sent_message_port_ids,
66 const std::vector<int>& new_routing_ids) {
67 WebKit::WebMessagePortChannelArray channels(sent_message_port_ids.size());
68 for (size_t i = 0; i < sent_message_port_ids.size(); i++) {
69 channels[i] = new WebMessagePortChannelImpl(
70 new_routing_ids[i], sent_message_port_ids[i]);
71 }
72
73 impl_->postMessageToWorkerContext(message, channels);
74 }
OLDNEW
« no previous file with comments | « content/worker/webworker_stub.h ('k') | content/worker/webworker_stub_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698