| 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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 // Connect event has been sent, so free ourselves (this releases the SharedW
orker so it can be freed as well if unreferenced). | 148 // Connect event has been sent, so free ourselves (this releases the SharedW
orker so it can be freed as well if unreferenced). |
| 149 delete this; | 149 delete this; |
| 150 } | 150 } |
| 151 | 151 |
| 152 static WebSharedWorkerRepositoryClient::DocumentID getId(void* document) | 152 static WebSharedWorkerRepositoryClient::DocumentID getId(void* document) |
| 153 { | 153 { |
| 154 ASSERT(document); | 154 ASSERT(document); |
| 155 return reinterpret_cast<WebSharedWorkerRepositoryClient::DocumentID>(documen
t); | 155 return reinterpret_cast<WebSharedWorkerRepositoryClient::DocumentID>(documen
t); |
| 156 } | 156 } |
| 157 | 157 |
| 158 void SharedWorkerRepositoryClientImpl::connect(PassRefPtr<SharedWorker> worker,
PassOwnPtr<MessagePortChannel> port, const KURL& url, const String& name, Except
ionState& es) | 158 void SharedWorkerRepositoryClientImpl::connect(PassRefPtr<SharedWorker> worker,
PassOwnPtr<MessagePortChannel> port, const KURL& url, const String& name, Except
ionState& exceptionState) |
| 159 { | 159 { |
| 160 ASSERT(m_client); | 160 ASSERT(m_client); |
| 161 | 161 |
| 162 // No nested workers (for now) - connect() should only be called from docume
nt context. | 162 // No nested workers (for now) - connect() should only be called from docume
nt context. |
| 163 ASSERT(worker->executionContext()->isDocument()); | 163 ASSERT(worker->executionContext()->isDocument()); |
| 164 Document* document = toDocument(worker->executionContext()); | 164 Document* document = toDocument(worker->executionContext()); |
| 165 OwnPtr<WebSharedWorker> webWorker = adoptPtr(m_client->createSharedWorker(ur
l, name, getId(document))); | 165 OwnPtr<WebSharedWorker> webWorker = adoptPtr(m_client->createSharedWorker(ur
l, name, getId(document))); |
| 166 if (!webWorker) { | 166 if (!webWorker) { |
| 167 // Existing worker does not match this url, so return an error back to t
he caller. | 167 // Existing worker does not match this url, so return an error back to t
he caller. |
| 168 es.throwDOMException(URLMismatchError, ExceptionMessages::failedToConstr
uct("SharedWorker", "The location of the SharedWorker named '" + name + "' does
not exactly match the provided URL ('" + url.elidedString() + "').")); | 168 exceptionState.throwDOMException(URLMismatchError, ExceptionMessages::fa
iledToConstruct("SharedWorker", "The location of the SharedWorker named '" + nam
e + "' does not exactly match the provided URL ('" + url.elidedString() + "').")
); |
| 169 return; | 169 return; |
| 170 } | 170 } |
| 171 | 171 |
| 172 // The loader object manages its own lifecycle (and the lifecycles of the tw
o worker objects). | 172 // The loader object manages its own lifecycle (and the lifecycles of the tw
o worker objects). |
| 173 // It will free itself once loading is completed. | 173 // It will free itself once loading is completed. |
| 174 SharedWorkerScriptLoader* loader = new SharedWorkerScriptLoader(worker, url,
name, port, webWorker.release()); | 174 SharedWorkerScriptLoader* loader = new SharedWorkerScriptLoader(worker, url,
name, port, webWorker.release()); |
| 175 loader->load(); | 175 loader->load(); |
| 176 } | 176 } |
| 177 | 177 |
| 178 void SharedWorkerRepositoryClientImpl::documentDetached(Document* document) | 178 void SharedWorkerRepositoryClientImpl::documentDetached(Document* document) |
| 179 { | 179 { |
| 180 ASSERT(m_client); | 180 ASSERT(m_client); |
| 181 m_client->documentDetached(getId(document)); | 181 m_client->documentDetached(getId(document)); |
| 182 } | 182 } |
| 183 | 183 |
| 184 SharedWorkerRepositoryClientImpl::SharedWorkerRepositoryClientImpl(WebSharedWork
erRepositoryClient* client) | 184 SharedWorkerRepositoryClientImpl::SharedWorkerRepositoryClientImpl(WebSharedWork
erRepositoryClient* client) |
| 185 : m_client(client) | 185 : m_client(client) |
| 186 { | 186 { |
| 187 } | 187 } |
| 188 | 188 |
| 189 } // namespace blink | 189 } // namespace blink |
| OLD | NEW |