OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/worker/webworker_stub.h" | 5 #include "chrome/worker/webworker_stub.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "chrome/common/child_thread.h" | 8 #include "chrome/common/child_thread.h" |
9 #include "chrome/common/chrome_switches.h" | 9 #include "chrome/common/chrome_switches.h" |
10 #include "chrome/common/file_system/file_system_dispatcher.h" | 10 #include "chrome/common/file_system/file_system_dispatcher.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 } | 53 } |
54 | 54 |
55 void WebWorkerStub::OnChannelError() { | 55 void WebWorkerStub::OnChannelError() { |
56 OnTerminateWorkerContext(); | 56 OnTerminateWorkerContext(); |
57 } | 57 } |
58 | 58 |
59 const GURL& WebWorkerStub::url() const { | 59 const GURL& WebWorkerStub::url() const { |
60 return url_; | 60 return url_; |
61 } | 61 } |
62 | 62 |
63 void WebWorkerStub::OnMessageReceived(const IPC::Message& message) { | 63 bool WebWorkerStub::OnMessageReceived(const IPC::Message& message) { |
64 if (!impl_) | 64 if (!impl_) |
65 return; | 65 return false; |
66 | 66 |
| 67 bool handled = true; |
67 IPC_BEGIN_MESSAGE_MAP(WebWorkerStub, message) | 68 IPC_BEGIN_MESSAGE_MAP(WebWorkerStub, message) |
68 IPC_MESSAGE_FORWARD(WorkerMsg_StartWorkerContext, impl_, | 69 IPC_MESSAGE_FORWARD(WorkerMsg_StartWorkerContext, impl_, |
69 WebWorker::startWorkerContext) | 70 WebWorker::startWorkerContext) |
70 IPC_MESSAGE_HANDLER(WorkerMsg_TerminateWorkerContext, | 71 IPC_MESSAGE_HANDLER(WorkerMsg_TerminateWorkerContext, |
71 OnTerminateWorkerContext) | 72 OnTerminateWorkerContext) |
72 IPC_MESSAGE_HANDLER(WorkerMsg_PostMessage, OnPostMessage) | 73 IPC_MESSAGE_HANDLER(WorkerMsg_PostMessage, OnPostMessage) |
73 IPC_MESSAGE_FORWARD(WorkerMsg_WorkerObjectDestroyed, impl_, | 74 IPC_MESSAGE_FORWARD(WorkerMsg_WorkerObjectDestroyed, impl_, |
74 WebWorker::workerObjectDestroyed) | 75 WebWorker::workerObjectDestroyed) |
| 76 IPC_MESSAGE_UNHANDLED(handled = false) |
75 IPC_END_MESSAGE_MAP() | 77 IPC_END_MESSAGE_MAP() |
| 78 return handled; |
76 } | 79 } |
77 | 80 |
78 void WebWorkerStub::OnTerminateWorkerContext() { | 81 void WebWorkerStub::OnTerminateWorkerContext() { |
79 impl_->terminateWorkerContext(); | 82 impl_->terminateWorkerContext(); |
80 | 83 |
81 // Call the client to make sure context exits. | 84 // Call the client to make sure context exits. |
82 EnsureWorkerContextTerminates(); | 85 EnsureWorkerContextTerminates(); |
83 } | 86 } |
84 | 87 |
85 void WebWorkerStub::OnPostMessage( | 88 void WebWorkerStub::OnPostMessage( |
86 const string16& message, | 89 const string16& message, |
87 const std::vector<int>& sent_message_port_ids, | 90 const std::vector<int>& sent_message_port_ids, |
88 const std::vector<int>& new_routing_ids) { | 91 const std::vector<int>& new_routing_ids) { |
89 WebKit::WebMessagePortChannelArray channels(sent_message_port_ids.size()); | 92 WebKit::WebMessagePortChannelArray channels(sent_message_port_ids.size()); |
90 for (size_t i = 0; i < sent_message_port_ids.size(); i++) { | 93 for (size_t i = 0; i < sent_message_port_ids.size(); i++) { |
91 channels[i] = new WebMessagePortChannelImpl( | 94 channels[i] = new WebMessagePortChannelImpl( |
92 new_routing_ids[i], sent_message_port_ids[i]); | 95 new_routing_ids[i], sent_message_port_ids[i]); |
93 } | 96 } |
94 | 97 |
95 impl_->postMessageToWorkerContext(message, channels); | 98 impl_->postMessageToWorkerContext(message, channels); |
96 } | 99 } |
OLD | NEW |