| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 #include "public/platform/WebMessagePortChannel.h" | 45 #include "public/platform/WebMessagePortChannel.h" |
| 46 #include "public/platform/WebString.h" | 46 #include "public/platform/WebString.h" |
| 47 #include "public/platform/WebURL.h" | 47 #include "public/platform/WebURL.h" |
| 48 #include "public/web/WebContentSecurityPolicy.h" | 48 #include "public/web/WebContentSecurityPolicy.h" |
| 49 #include "public/web/WebFrameClient.h" | 49 #include "public/web/WebFrameClient.h" |
| 50 #include "public/web/WebKit.h" | 50 #include "public/web/WebKit.h" |
| 51 #include "public/web/WebSharedWorker.h" | 51 #include "public/web/WebSharedWorker.h" |
| 52 #include "public/web/WebSharedWorkerRepositoryClient.h" | 52 #include "public/web/WebSharedWorkerRepositoryClient.h" |
| 53 #include "web/WebLocalFrameImpl.h" | 53 #include "web/WebLocalFrameImpl.h" |
| 54 | 54 |
| 55 using namespace blink; | |
| 56 | |
| 57 namespace blink { | 55 namespace blink { |
| 58 | 56 |
| 59 // Callback class that keeps the SharedWorker and WebSharedWorker objects alive
while connecting. | 57 // Callback class that keeps the SharedWorker and WebSharedWorker objects alive
while connecting. |
| 60 class SharedWorkerConnector : private WebSharedWorkerConnector::ConnectListener
{ | 58 class SharedWorkerConnector : private WebSharedWorkerConnector::ConnectListener
{ |
| 61 public: | 59 public: |
| 62 SharedWorkerConnector(PassRefPtrWillBeRawPtr<SharedWorker> worker, const KUR
L& url, const String& name, PassOwnPtr<WebMessagePortChannel> channel, PassOwnPt
r<WebSharedWorkerConnector> webWorkerConnector) | 60 SharedWorkerConnector(PassRefPtrWillBeRawPtr<SharedWorker> worker, const KUR
L& url, const String& name, PassOwnPtr<WebMessagePortChannel> channel, PassOwnPt
r<WebSharedWorkerConnector> webWorkerConnector) |
| 63 : m_worker(worker) | 61 : m_worker(worker) |
| 64 , m_url(url) | 62 , m_url(url) |
| 65 , m_name(name) | 63 , m_name(name) |
| 66 , m_webWorkerConnector(webWorkerConnector) | 64 , m_webWorkerConnector(webWorkerConnector) |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 return reinterpret_cast<WebSharedWorkerRepositoryClient::DocumentID>(documen
t); | 109 return reinterpret_cast<WebSharedWorkerRepositoryClient::DocumentID>(documen
t); |
| 112 } | 110 } |
| 113 | 111 |
| 114 void SharedWorkerRepositoryClientImpl::connect(PassRefPtrWillBeRawPtr<SharedWork
er> worker, PassOwnPtr<WebMessagePortChannel> port, const KURL& url, const Strin
g& name, ExceptionState& exceptionState) | 112 void SharedWorkerRepositoryClientImpl::connect(PassRefPtrWillBeRawPtr<SharedWork
er> worker, PassOwnPtr<WebMessagePortChannel> port, const KURL& url, const Strin
g& name, ExceptionState& exceptionState) |
| 115 { | 113 { |
| 116 ASSERT(m_client); | 114 ASSERT(m_client); |
| 117 | 115 |
| 118 // No nested workers (for now) - connect() should only be called from docume
nt context. | 116 // No nested workers (for now) - connect() should only be called from docume
nt context. |
| 119 ASSERT(worker->executionContext()->isDocument()); | 117 ASSERT(worker->executionContext()->isDocument()); |
| 120 Document* document = toDocument(worker->executionContext()); | 118 Document* document = toDocument(worker->executionContext()); |
| 121 OwnPtr<WebSharedWorkerConnector> webWorkerConnector = adoptPtr(m_client->cre
ateSharedWorkerConnector(url, name, getId(document), worker->executionContext()-
>contentSecurityPolicy()->deprecatedHeader(), static_cast<blink::WebContentSecur
ityPolicyType>(worker->executionContext()->contentSecurityPolicy()->deprecatedHe
aderType()))); | 119 OwnPtr<WebSharedWorkerConnector> webWorkerConnector = adoptPtr(m_client->cre
ateSharedWorkerConnector(url, name, getId(document), worker->executionContext()-
>contentSecurityPolicy()->deprecatedHeader(), static_cast<WebContentSecurityPoli
cyType>(worker->executionContext()->contentSecurityPolicy()->deprecatedHeaderTyp
e()))); |
| 122 if (!webWorkerConnector) { | 120 if (!webWorkerConnector) { |
| 123 // Existing worker does not match this url, so return an error back to t
he caller. | 121 // Existing worker does not match this url, so return an error back to t
he caller. |
| 124 exceptionState.throwDOMException(URLMismatchError, "The location of the
SharedWorker named '" + name + "' does not exactly match the provided URL ('" +
url.elidedString() + "')."); | 122 exceptionState.throwDOMException(URLMismatchError, "The location of the
SharedWorker named '" + name + "' does not exactly match the provided URL ('" +
url.elidedString() + "')."); |
| 125 return; | 123 return; |
| 126 } | 124 } |
| 127 | 125 |
| 128 // The connector object manages its own lifecycle (and the lifecycles of the
two worker objects). | 126 // The connector object manages its own lifecycle (and the lifecycles of the
two worker objects). |
| 129 // It will free itself once connecting is completed. | 127 // It will free itself once connecting is completed. |
| 130 SharedWorkerConnector* connector = new SharedWorkerConnector(worker, url, na
me, port, webWorkerConnector.release()); | 128 SharedWorkerConnector* connector = new SharedWorkerConnector(worker, url, na
me, port, webWorkerConnector.release()); |
| 131 connector->connect(); | 129 connector->connect(); |
| 132 } | 130 } |
| 133 | 131 |
| 134 void SharedWorkerRepositoryClientImpl::documentDetached(Document* document) | 132 void SharedWorkerRepositoryClientImpl::documentDetached(Document* document) |
| 135 { | 133 { |
| 136 ASSERT(m_client); | 134 ASSERT(m_client); |
| 137 m_client->documentDetached(getId(document)); | 135 m_client->documentDetached(getId(document)); |
| 138 } | 136 } |
| 139 | 137 |
| 140 SharedWorkerRepositoryClientImpl::SharedWorkerRepositoryClientImpl(WebSharedWork
erRepositoryClient* client) | 138 SharedWorkerRepositoryClientImpl::SharedWorkerRepositoryClientImpl(WebSharedWork
erRepositoryClient* client) |
| 141 : m_client(client) | 139 : m_client(client) |
| 142 { | 140 { |
| 143 } | 141 } |
| 144 | 142 |
| 145 } // namespace blink | 143 } // namespace blink |
| OLD | NEW |