| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 { | 59 { |
| 60 } | 60 } |
| 61 | 61 |
| 62 bool WebSharedWorkerImpl::isStarted() | 62 bool WebSharedWorkerImpl::isStarted() |
| 63 { | 63 { |
| 64 // Should not ever be called from the worker thread (this API is only called on WebSharedWorkerProxy on the renderer thread). | 64 // Should not ever be called from the worker thread (this API is only called on WebSharedWorkerProxy on the renderer thread). |
| 65 ASSERT_NOT_REACHED(); | 65 ASSERT_NOT_REACHED(); |
| 66 return workerThread(); | 66 return workerThread(); |
| 67 } | 67 } |
| 68 | 68 |
| 69 void WebSharedWorkerImpl::connect(WebMessagePortChannel* webChannel) | 69 void WebSharedWorkerImpl::connect(WebMessagePortChannel* webChannel, ConnectListener* listener) |
| 70 { | 70 { |
| 71 // Convert the WebMessagePortChanel to a WebCore::MessagePortChannel. | 71 // Convert the WebMessagePortChanel to a WebCore::MessagePortChannel. |
| 72 RefPtr<PlatformMessagePortChannel> platform_channel = | 72 RefPtr<PlatformMessagePortChannel> platform_channel = |
| 73 PlatformMessagePortChannel::create(webChannel); | 73 PlatformMessagePortChannel::create(webChannel); |
| 74 webChannel->setClient(platform_channel.get()); | 74 webChannel->setClient(platform_channel.get()); |
| 75 OwnPtr<MessagePortChannel> channel = | 75 OwnPtr<MessagePortChannel> channel = |
| 76 MessagePortChannel::create(platform_channel); | 76 MessagePortChannel::create(platform_channel); |
| 77 | 77 |
| 78 workerThread()->runLoop().postTask( | 78 workerThread()->runLoop().postTask( |
| 79 createCallbackTask(&connectTask, this, channel.release())); | 79 createCallbackTask(&connectTask, this, channel.release())); |
| 80 if (listener) |
| 81 listener->connected(); |
| 80 } | 82 } |
| 81 | 83 |
| 82 void WebSharedWorkerImpl::connectTask(ScriptExecutionContext* context, WebSharedWorkerImpl* worker, PassOwnPtr<MessagePortChannel> channel) | 84 void WebSharedWorkerImpl::connectTask(ScriptExecutionContext* context, WebSharedWorkerImpl* worker, PassOwnPtr<MessagePortChannel> channel) |
| 83 { | 85 { |
| 84 // Wrap the passed-in channel in a MessagePort, and send it off via a connect event. | 86 // Wrap the passed-in channel in a MessagePort, and send it off via a connect event. |
| 85 RefPtr<MessagePort> port = MessagePort::create(*context); | 87 RefPtr<MessagePort> port = MessagePort::create(*context); |
| 86 port->entangle(channel.release()); | 88 port->entangle(channel.release()); |
| 87 ASSERT(context->isWorkerContext()); | 89 ASSERT(context->isWorkerContext()); |
| 88 WorkerContext* workerContext = static_cast<WorkerContext*>(context); | 90 WorkerContext* workerContext = static_cast<WorkerContext*>(context); |
| 89 ASSERT(workerContext->isSharedWorkerContext()); | 91 ASSERT(workerContext->isSharedWorkerContext()); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 116 } | 118 } |
| 117 | 119 |
| 118 WebSharedWorker* WebSharedWorker::create(WebCommonWorkerClient* client) | 120 WebSharedWorker* WebSharedWorker::create(WebCommonWorkerClient* client) |
| 119 { | 121 { |
| 120 return new WebSharedWorkerImpl(client); | 122 return new WebSharedWorkerImpl(client); |
| 121 } | 123 } |
| 122 | 124 |
| 123 #endif // ENABLE(SHARED_WORKERS) | 125 #endif // ENABLE(SHARED_WORKERS) |
| 124 | 126 |
| 125 } // namespace WebKit | 127 } // namespace WebKit |
| OLD | NEW |