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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 #include "public/web/WebKit.h" | 48 #include "public/web/WebKit.h" |
49 #include "public/web/WebSharedWorker.h" | 49 #include "public/web/WebSharedWorker.h" |
50 #include "public/web/WebSharedWorkerRepositoryClient.h" | 50 #include "public/web/WebSharedWorkerRepositoryClient.h" |
51 #include "web/WebLocalFrameImpl.h" | 51 #include "web/WebLocalFrameImpl.h" |
52 | 52 |
53 namespace blink { | 53 namespace blink { |
54 | 54 |
55 // Callback class that keeps the SharedWorker and WebSharedWorker objects alive
while connecting. | 55 // Callback class that keeps the SharedWorker and WebSharedWorker objects alive
while connecting. |
56 class SharedWorkerConnector : private WebSharedWorkerConnector::ConnectListener
{ | 56 class SharedWorkerConnector : private WebSharedWorkerConnector::ConnectListener
{ |
57 public: | 57 public: |
58 SharedWorkerConnector(PassRefPtrWillBeRawPtr<SharedWorker> worker, const KUR
L& url, const String& name, PassOwnPtr<WebMessagePortChannel> channel, PassOwnPt
r<WebSharedWorkerConnector> webWorkerConnector) | 58 SharedWorkerConnector(SharedWorker* worker, const KURL& url, const String& n
ame, PassOwnPtr<WebMessagePortChannel> channel, PassOwnPtr<WebSharedWorkerConnec
tor> webWorkerConnector) |
59 : m_worker(worker) | 59 : m_worker(worker) |
60 , m_url(url) | 60 , m_url(url) |
61 , m_name(name) | 61 , m_name(name) |
62 , m_webWorkerConnector(webWorkerConnector) | 62 , m_webWorkerConnector(webWorkerConnector) |
63 , m_channel(channel) { } | 63 , m_channel(channel) { } |
64 | 64 |
65 virtual ~SharedWorkerConnector(); | 65 virtual ~SharedWorkerConnector(); |
66 void connect(); | 66 void connect(); |
67 | 67 |
68 private: | 68 private: |
69 // WebSharedWorkerConnector::ConnectListener overrides. | 69 // WebSharedWorkerConnector::ConnectListener overrides. |
70 void connected() override; | 70 void connected() override; |
71 void scriptLoadFailed() override; | 71 void scriptLoadFailed() override; |
72 | 72 |
73 RefPtrWillBePersistent<SharedWorker> m_worker; | 73 Persistent<SharedWorker> m_worker; |
74 KURL m_url; | 74 KURL m_url; |
75 String m_name; | 75 String m_name; |
76 OwnPtr<WebSharedWorkerConnector> m_webWorkerConnector; | 76 OwnPtr<WebSharedWorkerConnector> m_webWorkerConnector; |
77 OwnPtr<WebMessagePortChannel> m_channel; | 77 OwnPtr<WebMessagePortChannel> m_channel; |
78 }; | 78 }; |
79 | 79 |
80 SharedWorkerConnector::~SharedWorkerConnector() | 80 SharedWorkerConnector::~SharedWorkerConnector() |
81 { | 81 { |
82 m_worker->setIsBeingConnected(false); | 82 m_worker->setIsBeingConnected(false); |
83 } | 83 } |
(...skipping 16 matching lines...) Expand all Loading... |
100 // Free ourselves (this releases the SharedWorker so it can be freed as well
if unreferenced). | 100 // Free ourselves (this releases the SharedWorker so it can be freed as well
if unreferenced). |
101 delete this; | 101 delete this; |
102 } | 102 } |
103 | 103 |
104 static WebSharedWorkerRepositoryClient::DocumentID getId(void* document) | 104 static WebSharedWorkerRepositoryClient::DocumentID getId(void* document) |
105 { | 105 { |
106 ASSERT(document); | 106 ASSERT(document); |
107 return reinterpret_cast<WebSharedWorkerRepositoryClient::DocumentID>(documen
t); | 107 return reinterpret_cast<WebSharedWorkerRepositoryClient::DocumentID>(documen
t); |
108 } | 108 } |
109 | 109 |
110 void SharedWorkerRepositoryClientImpl::connect(PassRefPtrWillBeRawPtr<SharedWork
er> worker, PassOwnPtr<WebMessagePortChannel> port, const KURL& url, const Strin
g& name, ExceptionState& exceptionState) | 110 void SharedWorkerRepositoryClientImpl::connect(SharedWorker* worker, PassOwnPtr<
WebMessagePortChannel> port, const KURL& url, const String& name, ExceptionState
& exceptionState) |
111 { | 111 { |
112 ASSERT(m_client); | 112 ASSERT(m_client); |
113 | 113 |
114 // No nested workers (for now) - connect() should only be called from docume
nt context. | 114 // No nested workers (for now) - connect() should only be called from docume
nt context. |
115 ASSERT(worker->executionContext()->isDocument()); | 115 ASSERT(worker->executionContext()->isDocument()); |
116 Document* document = toDocument(worker->executionContext()); | 116 Document* document = toDocument(worker->executionContext()); |
117 | 117 |
118 // TODO(estark): this is broken, as it only uses the first header | 118 // TODO(estark): this is broken, as it only uses the first header |
119 // when multiple might have been sent. Fix by making the | 119 // when multiple might have been sent. Fix by making the |
120 // SharedWorkerConnector interface take a map that can contain | 120 // SharedWorkerConnector interface take a map that can contain |
(...skipping 25 matching lines...) Expand all Loading... |
146 ASSERT(m_client); | 146 ASSERT(m_client); |
147 m_client->documentDetached(getId(document)); | 147 m_client->documentDetached(getId(document)); |
148 } | 148 } |
149 | 149 |
150 SharedWorkerRepositoryClientImpl::SharedWorkerRepositoryClientImpl(WebSharedWork
erRepositoryClient* client) | 150 SharedWorkerRepositoryClientImpl::SharedWorkerRepositoryClientImpl(WebSharedWork
erRepositoryClient* client) |
151 : m_client(client) | 151 : m_client(client) |
152 { | 152 { |
153 } | 153 } |
154 | 154 |
155 } // namespace blink | 155 } // namespace blink |
OLD | NEW |