| 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/chrome_switches.h" | 8 #include "chrome/common/chrome_switches.h" |
| 9 #include "chrome/common/webmessageportchannel_impl.h" | 9 #include "chrome/common/webmessageportchannel_impl.h" |
| 10 #include "chrome/common/worker_messages.h" | 10 #include "chrome/common/worker_messages.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 // a NativeWebWorker (for .nexe) or a WebWorker (for anything else). | 26 // a NativeWebWorker (for .nexe) or a WebWorker (for anything else). |
| 27 const std::string kNativeSuffix(".nexe"); | 27 const std::string kNativeSuffix(".nexe"); |
| 28 std::string worker_url = url.path(); | 28 std::string worker_url = url.path(); |
| 29 // Compute the start index of the suffix. | 29 // Compute the start index of the suffix. |
| 30 std::string::size_type suffix_index = | 30 std::string::size_type suffix_index = |
| 31 worker_url.length() - kNativeSuffix.length(); | 31 worker_url.length() - kNativeSuffix.length(); |
| 32 std::string::size_type pos = worker_url.find(kNativeSuffix, suffix_index); | 32 std::string::size_type pos = worker_url.find(kNativeSuffix, suffix_index); |
| 33 return (suffix_index == pos); | 33 return (suffix_index == pos); |
| 34 } | 34 } |
| 35 | 35 |
| 36 WebWorkerStub::WebWorkerStub(const GURL& url, int route_id) | 36 WebWorkerStub::WebWorkerStub(const GURL& url, int route_id, |
| 37 : WebWorkerStubBase(route_id) { | 37 const WorkerAppCacheInitInfo& appcache_init_info) |
| 38 : WebWorkerStubBase(route_id, appcache_init_info) { |
| 38 if (UrlIsNativeWorker(url)) { | 39 if (UrlIsNativeWorker(url)) { |
| 39 // Launch a native worker. | 40 // Launch a native worker. |
| 40 impl_ = NativeWebWorkerImpl::create(client()); | 41 impl_ = NativeWebWorkerImpl::create(client()); |
| 41 } else { | 42 } else { |
| 42 // Launch a JavaScript worker. | 43 // Launch a JavaScript worker. |
| 43 impl_ = WebKit::WebWorker::create(client()); | 44 impl_ = WebKit::WebWorker::create(client()); |
| 44 } | 45 } |
| 45 } | 46 } |
| 46 | 47 |
| 47 WebWorkerStub::~WebWorkerStub() { | 48 WebWorkerStub::~WebWorkerStub() { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 const std::vector<int>& sent_message_port_ids, | 80 const std::vector<int>& sent_message_port_ids, |
| 80 const std::vector<int>& new_routing_ids) { | 81 const std::vector<int>& new_routing_ids) { |
| 81 WebKit::WebMessagePortChannelArray channels(sent_message_port_ids.size()); | 82 WebKit::WebMessagePortChannelArray channels(sent_message_port_ids.size()); |
| 82 for (size_t i = 0; i < sent_message_port_ids.size(); i++) { | 83 for (size_t i = 0; i < sent_message_port_ids.size(); i++) { |
| 83 channels[i] = new WebMessagePortChannelImpl( | 84 channels[i] = new WebMessagePortChannelImpl( |
| 84 new_routing_ids[i], sent_message_port_ids[i]); | 85 new_routing_ids[i], sent_message_port_ids[i]); |
| 85 } | 86 } |
| 86 | 87 |
| 87 impl_->postMessageToWorkerContext(message, channels); | 88 impl_->postMessageToWorkerContext(message, channels); |
| 88 } | 89 } |
| OLD | NEW |