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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 #include "public/platform/WebString.h" | 53 #include "public/platform/WebString.h" |
54 #include "public/platform/WebURL.h" | 54 #include "public/platform/WebURL.h" |
55 | 55 |
56 using namespace WebCore; | 56 using namespace WebCore; |
57 | 57 |
58 namespace blink { | 58 namespace blink { |
59 | 59 |
60 // Callback class that keeps the SharedWorker and WebSharedWorker objects alive
while connecting. | 60 // Callback class that keeps the SharedWorker and WebSharedWorker objects alive
while connecting. |
61 class SharedWorkerConnector : private WebSharedWorkerConnector::ConnectListener
{ | 61 class SharedWorkerConnector : private WebSharedWorkerConnector::ConnectListener
{ |
62 public: | 62 public: |
63 SharedWorkerConnector(PassRefPtr<SharedWorker> worker, const KURL& url, cons
t String& name, PassOwnPtr<WebMessagePortChannel> channel, PassOwnPtr<WebSharedW
orkerConnector> webWorkerConnector) | 63 SharedWorkerConnector(PassRefPtrWillBeRawPtr<SharedWorker> worker, const KUR
L& url, const String& name, PassOwnPtr<WebMessagePortChannel> channel, PassOwnPt
r<WebSharedWorkerConnector> webWorkerConnector) |
64 : m_worker(worker) | 64 : m_worker(worker) |
65 , m_url(url) | 65 , m_url(url) |
66 , m_name(name) | 66 , m_name(name) |
67 , m_webWorkerConnector(webWorkerConnector) | 67 , m_webWorkerConnector(webWorkerConnector) |
68 , m_channel(channel) { } | 68 , m_channel(channel) { } |
69 | 69 |
70 virtual ~SharedWorkerConnector(); | 70 virtual ~SharedWorkerConnector(); |
71 void connect(); | 71 void connect(); |
72 | 72 |
73 private: | 73 private: |
74 // WebSharedWorkerConnector::ConnectListener overrides. | 74 // WebSharedWorkerConnector::ConnectListener overrides. |
75 virtual void connected() OVERRIDE; | 75 virtual void connected() OVERRIDE; |
76 virtual void scriptLoadFailed() OVERRIDE; | 76 virtual void scriptLoadFailed() OVERRIDE; |
77 | 77 |
78 RefPtr<SharedWorker> m_worker; | 78 RefPtrWillBePersistent<SharedWorker> m_worker; |
79 KURL m_url; | 79 KURL m_url; |
80 String m_name; | 80 String m_name; |
81 OwnPtr<WebSharedWorkerConnector> m_webWorkerConnector; | 81 OwnPtr<WebSharedWorkerConnector> m_webWorkerConnector; |
82 OwnPtr<WebMessagePortChannel> m_channel; | 82 OwnPtr<WebMessagePortChannel> m_channel; |
83 }; | 83 }; |
84 | 84 |
85 SharedWorkerConnector::~SharedWorkerConnector() | 85 SharedWorkerConnector::~SharedWorkerConnector() |
86 { | 86 { |
87 m_worker->unsetPreventGC(); | 87 m_worker->unsetPreventGC(); |
88 } | 88 } |
(...skipping 15 matching lines...) Expand all Loading... |
104 // Free ourselves (this releases the SharedWorker so it can be freed as well
if unreferenced). | 104 // Free ourselves (this releases the SharedWorker so it can be freed as well
if unreferenced). |
105 delete this; | 105 delete this; |
106 } | 106 } |
107 | 107 |
108 static WebSharedWorkerRepositoryClient::DocumentID getId(void* document) | 108 static WebSharedWorkerRepositoryClient::DocumentID getId(void* document) |
109 { | 109 { |
110 ASSERT(document); | 110 ASSERT(document); |
111 return reinterpret_cast<WebSharedWorkerRepositoryClient::DocumentID>(documen
t); | 111 return reinterpret_cast<WebSharedWorkerRepositoryClient::DocumentID>(documen
t); |
112 } | 112 } |
113 | 113 |
114 void SharedWorkerRepositoryClientImpl::connect(PassRefPtr<SharedWorker> worker,
PassOwnPtr<WebMessagePortChannel> port, const KURL& url, const String& name, Exc
eptionState& exceptionState) | 114 void SharedWorkerRepositoryClientImpl::connect(PassRefPtrWillBeRawPtr<SharedWork
er> worker, PassOwnPtr<WebMessagePortChannel> port, const KURL& url, const Strin
g& name, ExceptionState& exceptionState) |
115 { | 115 { |
116 ASSERT(m_client); | 116 ASSERT(m_client); |
117 | 117 |
118 // No nested workers (for now) - connect() should only be called from docume
nt context. | 118 // No nested workers (for now) - connect() should only be called from docume
nt context. |
119 ASSERT(worker->executionContext()->isDocument()); | 119 ASSERT(worker->executionContext()->isDocument()); |
120 Document* document = toDocument(worker->executionContext()); | 120 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()))); | 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()))); |
122 if (!webWorkerConnector) { | 122 if (!webWorkerConnector) { |
123 // Existing worker does not match this url, so return an error back to t
he caller. | 123 // 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() + "')."); | 124 exceptionState.throwDOMException(URLMismatchError, "The location of the
SharedWorker named '" + name + "' does not exactly match the provided URL ('" +
url.elidedString() + "')."); |
(...skipping 11 matching lines...) Expand all Loading... |
136 ASSERT(m_client); | 136 ASSERT(m_client); |
137 m_client->documentDetached(getId(document)); | 137 m_client->documentDetached(getId(document)); |
138 } | 138 } |
139 | 139 |
140 SharedWorkerRepositoryClientImpl::SharedWorkerRepositoryClientImpl(WebSharedWork
erRepositoryClient* client) | 140 SharedWorkerRepositoryClientImpl::SharedWorkerRepositoryClientImpl(WebSharedWork
erRepositoryClient* client) |
141 : m_client(client) | 141 : m_client(client) |
142 { | 142 { |
143 } | 143 } |
144 | 144 |
145 } // namespace blink | 145 } // namespace blink |
OLD | NEW |