Source/WebCore/ChangeLog

 12012-12-31 Kenneth Russell <[email protected]>
 2
 3 [chromium] Creation of dedicated workers (isolates) leaks reference to HTMLDocument
 4 https://bugs.webkit.org/show_bug.cgi?id=105367
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Eliminated a Chromium-specific object wrapping WorkerMessagingProxy in order to fix a
 9 lifetime management bug, which leaked every Document which started a dedicated worker.
 10
 11 Test: fast/workers/worker-document-leak.html
 12
 13 * workers/WorkerLoaderProxy.h:
 14 (WorkerLoaderProxy):
 15 Added Chromium-specific casting method to bridge two now-distinct class hierarchies.
 16 * workers/WorkerMessagingProxy.h:
 17 (WorkerMessagingProxy):
 18 Made destructor protected instead of private to allow subclassing.
 19
1202012-12-30 Kondapally Kalyan <[email protected]>
221
322 [EFL] [WebGL] Rename EGLConfigHelper as EGLConfigSelector.

Source/WebKit/chromium/ChangeLog

 12012-12-31 Kenneth Russell <[email protected]>
 2
 3 [chromium] Creation of dedicated workers (isolates) leaks reference to HTMLDocument
 4 https://bugs.webkit.org/show_bug.cgi?id=105367
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Made WebWorkerClientImpl a subclass of WorkerMessagingProxy rather than an object wrapping
 9 WorkerMessagingProxy. WorkerMessagingProxy manages its own lifetime and it is impossible to
 10 properly synchronize the lifetime of WebWorkerClientImpl separately.
 11
 12 This allowed most of WebWorkerClientImpl to be deleted, but forced a divergence in the class
 13 hierarchies of WebWorkerClientImpl and WebSharedWorkerImpl. Conversion methods were added to
 14 WorkerLoaderProxy and WebWorkerBase to bridge the hierarchies of in-process and
 15 out-of-process workers.
 16
 17 * src/DatabaseObserver.cpp:
 18 (WebCore::DatabaseObserver::canEstablishDatabase):
 19 Adjusted how WebWorkerBase is obtained from WorkerLoaderProxy.
 20 * src/IDBFactoryBackendProxy.cpp:
 21 (WebKit::AllowIndexedDBMainThreadBridge::signalCompleted):
 22 Adjusted how WorkerLoaderProxy's methods are called.
 23 (WebKit::IDBFactoryBackendProxy::allowIndexedDB):
 24 Adjusted how WebWorkerBase is obtained from WorkerLoaderProxy.
 25 * src/LocalFileSystemChromium.cpp:
 26 (WebCore::openFileSystemHelper):
 27 Adjusted how WebWorkerBase is obtained from WorkerLoaderProxy.
 28 * src/WebSharedWorkerImpl.cpp:
 29 (WebKit::WebSharedWorkerImpl::toWebWorkerBase):
 30 Implemented new conversion method.
 31 * src/WebSharedWorkerImpl.h:
 32 (WebSharedWorkerImpl):
 33 Explicitly derive from WorkerLoaderProxy now that WebWorkerBase no longer does.
 34 (WebKit::WebSharedWorkerImpl::workerLoaderProxy):
 35 Added new conversion method.
 36 * src/WebWorkerBase.h:
 37 (WebWorkerBase):
 38 Removed derivation from WorkerLoaderProxy. Added method to convert to WorkerLoaderProxy.
 39 * src/WebWorkerClientImpl.cpp:
 40 (WebKit):
 41 Adjusted comment.
 42 (WebKit::WebWorkerClientImpl::createWorkerContextProxy):
 43 Adjusted whitespace.
 44 (WebKit::WebWorkerClientImpl::terminateWorkerContext):
 45 Eliminated delegation to separate object.
 46 (WebKit::WebWorkerClientImpl::toWebWorkerBase):
 47 Implemented new conversion method.
 48 (WebKit::WebWorkerClientImpl::view):
 49 (WebKit::WebWorkerClientImpl::allowDatabase):
 50 (WebKit::WebWorkerClientImpl::allowFileSystem):
 51 (WebKit::WebWorkerClientImpl::openFileSystem):
 52 (WebKit::WebWorkerClientImpl::allowIndexedDB):
 53 Eliminated delegation to separate object.
 54 (WebKit::WebWorkerClientImpl::WebWorkerClientImpl):
 55 * src/WebWorkerClientImpl.h:
 56 (WebKit):
 57 Changed to inherit from WorkerMessagingProxy directly.
 58 (WebWorkerClientImpl):
 59 Deleted most methods previously overridden from WorkerContextProxy, etc.
 60 * src/WorkerAsyncFileSystemChromium.cpp:
 61 (WebCore::WorkerAsyncFileSystemChromium::WorkerAsyncFileSystemChromium):
 62 (WebCore::WorkerAsyncFileSystemChromium::createWorkerFileSystemCallbacksBridge):
 63 Hold on to, and use, WorkerLoaderProxy rather than WebWorkerBase.
 64 * src/WorkerAsyncFileSystemChromium.h:
 65 (WebKit):
 66 (WebCore):
 67 (WorkerAsyncFileSystemChromium):
 68 Hold on to WorkerLoaderProxy rather than WebWorkerBase.
 69
1702012-12-28 Fady Samuel <[email protected]>
271
372 Roll Chromium DEPS to r174739

Source/WebCore/workers/WorkerLoaderProxy.h

@@namespace WebCore {
5555 // specific synchronous loading requests so they can be 'nested', per spec.
5656 // Returns true if the task was posted successfully.
5757 virtual bool postTaskForModeToWorkerContext(PassOwnPtr<ScriptExecutionContext::Task>, const String& mode) = 0;
 58
 59#if PLATFORM(CHROMIUM)
 60 // Spans divergent class hierarchies for dedicated and shared workers. Implementation must
 61 // static_cast to WebWorkerBase*.
 62 virtual void* toWebWorkerBase() = 0;
 63#endif
5864 };
5965
6066} // namespace WebCore

Source/WebCore/workers/WorkerMessagingProxy.h

@@namespace WebCore {
8989 // Only use this method on the worker object thread.
9090 bool askedToTerminate() const { return m_askedToTerminate; }
9191
 92 protected:
 93 virtual ~WorkerMessagingProxy();
 94
9295 private:
9396 friend class MessageWorkerTask;
9497 friend class PostMessageToPageInspectorTask;

@@namespace WebCore {
9699 friend class WorkerExceptionTask;
97100 friend class WorkerThreadActivityReportTask;
98101
99  virtual ~WorkerMessagingProxy();
100 
101102 void workerContextDestroyedInternal();
102103 static void workerObjectDestroyedInternal(ScriptExecutionContext*, WorkerMessagingProxy*);
103104 void reportPendingActivityInternal(bool confirmingMessage, bool hasPendingActivity);

Source/WebKit/chromium/src/DatabaseObserver.cpp

@@bool DatabaseObserver::canEstablishDatabase(ScriptExecutionContext* scriptExecut
164164 } else {
165165#if ENABLE(WORKERS)
166166 WorkerContext* workerContext = static_cast<WorkerContext*>(scriptExecutionContext);
167  WorkerLoaderProxy* workerLoaderProxy = &workerContext->thread()->workerLoaderProxy();
168  WebWorkerBase* webWorker = static_cast<WebWorkerBase*>(workerLoaderProxy);
 167 WebWorkerBase* webWorker = static_cast<WebWorkerBase*>(workerContext->thread()->workerLoaderProxy().toWebWorkerBase());
169168 WebView* view = webWorker->view();
170169 if (!view)
171170 return false;

Source/WebKit/chromium/src/IDBFactoryBackendProxy.cpp

@@public:
111111 {
112112 MutexLocker locker(m_mutex);
113113 if (m_webWorkerBase)
114  m_webWorkerBase->postTaskForModeToWorkerContext(createCallbackTask(&didComplete, this, result), mode);
 114 m_webWorkerBase->workerLoaderProxy()->postTaskForModeToWorkerContext(createCallbackTask(&didComplete, this, result), mode);
115115 }
116116
117117private:

@@bool IDBFactoryBackendProxy::allowIndexedDB(ScriptExecutionContext* context, con
172172 allowed = !webView->permissionClient() || webView->permissionClient()->allowIndexedDB(webFrame, name, origin);
173173 } else {
174174 WorkerContext* workerContext = static_cast<WorkerContext*>(context);
175  WebWorkerBase* webWorkerBase = static_cast<WebWorkerBase*>(&workerContext->thread()->workerLoaderProxy());
 175 WebWorkerBase* webWorkerBase = static_cast<WebWorkerBase*>(workerContext->thread()->workerLoaderProxy().toWebWorkerBase());
176176 WorkerRunLoop& runLoop = workerContext->thread()->runLoop();
177177
178178 String mode = allowIndexedDBMode;

Source/WebKit/chromium/src/LocalFileSystemChromium.cpp

@@static void openFileSystemHelper(ScriptExecutionContext* context, FileSystemType
203203 } else {
204204#if ENABLE(WORKERS)
205205 WorkerContext* workerContext = static_cast<WorkerContext*>(context);
206  WorkerLoaderProxy* workerLoaderProxy = &workerContext->thread()->workerLoaderProxy();
207  WebWorkerBase* webWorker = static_cast<WebWorkerBase*>(workerLoaderProxy);
 206 WebWorkerBase* webWorker = static_cast<WebWorkerBase*>(workerContext->thread()->workerLoaderProxy().toWebWorkerBase());
208207 if (!allowFileSystemForWorker(webWorker->commonClient()))
209208 allowed = false;
210209 else

Source/WebKit/chromium/src/WebSharedWorkerImpl.cpp

@@bool WebSharedWorkerImpl::postTaskForModeToWorkerContext(
324324 return true;
325325}
326326
 327void* WebSharedWorkerImpl::toWebWorkerBase()
 328{
 329 return static_cast<WebWorkerBase*>(this);
 330}
327331
328332
329333bool WebSharedWorkerImpl::isStarted()

Source/WebKit/chromium/src/WebSharedWorkerImpl.h

@@class WebSharedWorkerClient;
6161// It can't use it directly since it uses WebKit types, so this class converts the data types.
6262// When the WebCore::SharedWorker object wants to call WebCore::WorkerReportingProxy, this class will
6363// convert to Chrome data types first and then call the supplied WebCommonWorkerClient.
64 class WebSharedWorkerImpl : public WebCore::WorkerObjectProxy
65  , public WebWorkerBase
66  , public WebFrameClient
67  , public WebSharedWorker {
 64class WebSharedWorkerImpl
 65 : public WebCore::WorkerObjectProxy
 66 , public WebCore::WorkerLoaderProxy
 67 , public WebWorkerBase
 68 , public WebFrameClient
 69 , public WebSharedWorker {
6870public:
6971 explicit WebSharedWorkerImpl(WebSharedWorkerClient*);
7072

@@public:
8890 virtual void postTaskToLoader(PassOwnPtr<WebCore::ScriptExecutionContext::Task>);
8991 virtual bool postTaskForModeToWorkerContext(
9092 PassOwnPtr<WebCore::ScriptExecutionContext::Task>, const WTF::String& mode);
 93 virtual void* toWebWorkerBase() OVERRIDE;
9194
9295 // WebFrameClient methods to support resource loading thru the 'shadow page'.
9396 virtual void didCreateDataSource(WebFrame*, WebDataSource*);

@@public:
111114 virtual void dispatchDevToolsMessage(const WebString&);
112115
113116
114  // NewWebWorkerBase methods:
 117 // WebWorkerBase methods:
 118 WebCore::WorkerLoaderProxy* workerLoaderProxy() { return this; }
115119 WebCommonWorkerClient* commonClient() { return m_client; }
116120
117121private:

Source/WebKit/chromium/src/WebWorkerBase.h

@@class WebView;
4848// containing common interface for shared workers and dedicated in-proc workers implementation.
4949//
5050// FIXME: Rename this class into WebWorkerBase, merge existing WebWorkerBase and WebSharedWorker.
51 class WebWorkerBase : public WebCore::WorkerLoaderProxy {
 51class WebWorkerBase {
5252public:
 53 virtual WebCore::WorkerLoaderProxy* workerLoaderProxy() = 0;
5354 virtual WebCommonWorkerClient* commonClient() = 0;
5455 virtual WebView* view() const = 0;
5556

Source/WebKit/chromium/src/WebWorkerClientImpl.cpp

@@using namespace WebCore;
6969
7070namespace WebKit {
7171
72 // Chromium-specific wrapper over WorkerMessagingProxy.
 72// Chromium-specific decorator of WorkerMessagingProxy.
7373// Delegates implementation of Worker{Loader,Context,Object}Proxy to WorkerMessagingProxy.
7474
7575// static

@@WorkerContextProxy* WebWorkerClientImpl::createWorkerContextProxy(Worker* worker
7979 Document* document = static_cast<Document*>(worker->scriptExecutionContext());
8080 WebFrameImpl* webFrame = WebFrameImpl::fromFrame(document->frame());
8181 WebWorkerClientImpl* proxy = new WebWorkerClientImpl(worker, webFrame);
82  return proxy;
83  }
 82 return proxy;
 83 }
8484 ASSERT_NOT_REACHED();
8585 return 0;
8686}
8787
88 void WebWorkerClientImpl::startWorkerContext(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerThreadStartMode startMode)
89 {
90  ASSERT(m_scriptExecutionContext->isDocument());
91  Document* document = static_cast<Document*>(m_scriptExecutionContext.get());
92  GroupSettings* settings = 0;
93  if (document->page())
94  settings = document->page()->group().groupSettings();
95  RefPtr<DedicatedWorkerThread> thread = DedicatedWorkerThread::create(scriptURL, userAgent, settings, sourceCode, *this, *this, startMode,
96  document->contentSecurityPolicy()->deprecatedHeader(),
97  document->contentSecurityPolicy()->deprecatedHeaderType(),
98  document->topDocument()->securityOrigin());
99  m_proxy->workerThreadCreated(thread);
100  thread->start();
101  InspectorInstrumentation::didStartWorkerContext(m_scriptExecutionContext.get(), m_proxy, scriptURL);
102 }
103 
10488void WebWorkerClientImpl::terminateWorkerContext()
10589{
10690 m_webFrame = 0;
107  m_proxy->terminateWorkerContext();
108 }
109 
110 void WebWorkerClientImpl::postMessageToWorkerContext(
111  PassRefPtr<SerializedScriptValue> value,
112  PassOwnPtr<MessagePortChannelArray> ports)
113 {
114  m_proxy->postMessageToWorkerContext(value, ports);
115 }
116 
117 bool WebWorkerClientImpl::hasPendingActivity() const
118 {
119  return m_proxy->hasPendingActivity();
120 }
121 
122 void WebWorkerClientImpl::workerObjectDestroyed()
123 {
124  m_proxy->workerObjectDestroyed();
125 }
126 
127 #if ENABLE(INSPECTOR)
128 void WebWorkerClientImpl::connectToInspector(PageInspector* inspector)
129 {
130  m_proxy->connectToInspector(inspector);
131 }
132 
133 void WebWorkerClientImpl::disconnectFromInspector()
134 {
135  m_proxy->disconnectFromInspector();
136 }
137 
138 void WebWorkerClientImpl::sendMessageToInspector(const String& message)
139 {
140  m_proxy->sendMessageToInspector(message);
141 }
142 
143 void WebWorkerClientImpl::postMessageToPageInspector(const String& message)
144 {
145  m_proxy->postMessageToPageInspector(message);
146 }
147 
148 void WebWorkerClientImpl::updateInspectorStateCookie(const String& cookie)
149 {
150  m_proxy->updateInspectorStateCookie(cookie);
151 }
152 #endif // ENABLE(INSPECTOR)
153 
154 
155 void WebWorkerClientImpl::postTaskToLoader(PassOwnPtr<ScriptExecutionContext::Task> task)
156 {
157  m_proxy->postTaskToLoader(task);
 91 WebCore::WorkerMessagingProxy::terminateWorkerContext();
15892}
15993
160 bool WebWorkerClientImpl::postTaskForModeToWorkerContext(PassOwnPtr<ScriptExecutionContext::Task> task, const String& mode)
 94void* WebWorkerClientImpl::toWebWorkerBase()
16195{
162  return m_proxy->postTaskForModeToWorkerContext(task, mode);
 96 return static_cast<WebWorkerBase*>(this);
16397}
16498
165 void WebWorkerClientImpl::postMessageToWorkerObject(PassRefPtr<SerializedScriptValue> value, PassOwnPtr<MessagePortChannelArray> ports)
 99WebView* WebWorkerClientImpl::view() const
166100{
167  m_proxy->postMessageToWorkerObject(value, ports);
168 }
169 
170 void WebWorkerClientImpl::confirmMessageFromWorkerObject(bool hasPendingActivity)
171 {
172  m_proxy->confirmMessageFromWorkerObject(hasPendingActivity);
173 }
174 
175 void WebWorkerClientImpl::reportPendingActivity(bool hasPendingActivity)
176 {
177  m_proxy->reportPendingActivity(hasPendingActivity);
178 }
179 
180 void WebWorkerClientImpl::workerContextClosed()
181 {
182  m_proxy->workerContextClosed();
183 }
184 
185 void WebWorkerClientImpl::postExceptionToWorkerObject(const String& errorMessage, int lineNumber, const String& sourceURL)
186 {
187  m_proxy->postExceptionToWorkerObject(errorMessage, lineNumber, sourceURL);
188 }
189 
190 void WebWorkerClientImpl::postConsoleMessageToWorkerObject(MessageSource source, MessageLevel level, const String& message, int lineNumber, const String& sourceURL)
191 {
192  m_proxy->postConsoleMessageToWorkerObject(source, level, message, lineNumber, sourceURL);
 101 if (askedToTerminate())
 102 return 0;
 103 return m_webFrame->view();
193104}
194105
195 void WebWorkerClientImpl::workerContextDestroyed()
 106bool WebWorkerClientImpl::allowDatabase(WebFrame*, const WebString& name, const WebString& displayName, unsigned long estimatedSize)
196107{
197  m_proxy->workerContextDestroyed();
 108 if (askedToTerminate())
 109 return false;
 110 WebKit::WebViewImpl* webView = m_webFrame->viewImpl();
 111 if (!webView)
 112 return false;
 113 return !webView->permissionClient() || webView->permissionClient()->allowDatabase(m_webFrame, name, displayName, estimatedSize);
198114}
199115
200116bool WebWorkerClientImpl::allowFileSystem()
201117{
202  if (m_proxy->askedToTerminate())
 118 if (askedToTerminate())
203119 return false;
204120 WebKit::WebViewImpl* webView = m_webFrame->viewImpl();
205121 if (!webView)

@@bool WebWorkerClientImpl::allowFileSystem()
207123 return !webView->permissionClient() || webView->permissionClient()->allowFileSystem(m_webFrame);
208124}
209125
210 void WebWorkerClientImpl::openFileSystem(WebFileSystem::Type type, long long size, bool create,
 126void WebWorkerClientImpl::openFileSystem(WebFileSystem::Type type, long long size, bool create,
211127 WebFileSystemCallbacks* callbacks)
212128{
213  if (m_proxy->askedToTerminate()) {
 129 if (askedToTerminate()) {
214130 callbacks->didFail(WebFileErrorAbort);
215131 return;
216132 }
217133 m_webFrame->client()->openFileSystem(m_webFrame, type, size, create, callbacks);
218134}
219135
220 bool WebWorkerClientImpl::allowDatabase(WebFrame*, const WebString& name, const WebString& displayName, unsigned long estimatedSize)
221 {
222  if (m_proxy->askedToTerminate())
223  return false;
224  WebKit::WebViewImpl* webView = m_webFrame->viewImpl();
225  if (!webView)
226  return false;
227  return !webView->permissionClient() || webView->permissionClient()->allowDatabase(m_webFrame, name, displayName, estimatedSize);
228 }
229 
230136bool WebWorkerClientImpl::allowIndexedDB(const WebString& name)
231137{
232  if (m_proxy->askedToTerminate())
 138 if (askedToTerminate())
233139 return false;
234140 WebKit::WebViewImpl* webView = m_webFrame->viewImpl();
235141 if (!webView)
236142 return false;
237143 return !webView->permissionClient() || webView->permissionClient()->allowIndexedDB(m_webFrame, name, WebSecurityOrigin());
238144}
239 
240 WebView* WebWorkerClientImpl::view() const
241 {
242  if (m_proxy->askedToTerminate())
243  return 0;
244  return m_webFrame->view();
245 }
246145
247146WebWorkerClientImpl::WebWorkerClientImpl(Worker* worker, WebFrameImpl* webFrame)
248  : m_proxy(new WorkerMessagingProxy(worker))
249  , m_scriptExecutionContext(worker->scriptExecutionContext())
250  , m_webFrame(webFrame)
 147 : WebCore::WorkerMessagingProxy(worker)
 148 , m_webFrame(webFrame)
251149{
252150}
253151

Source/WebKit/chromium/src/WebWorkerClientImpl.h

@@class WebFrameImpl;
5454// for in-proc dedicated workers. It also acts as a bridge for workers to chromium implementation of file systems,
5555// databases and other related functionality.
5656//
57 // In essence, this class wraps WorkerMessagingProxy.
58 class WebWorkerClientImpl : public WebCore::WorkerContextProxy
59  , public WebCore::WorkerObjectProxy
 57// In essence, this class decorates WorkerMessagingProxy.
 58//
 59// It is imperative that this class inherit from WorkerMessagingProxy rather than delegate to an instance of
 60// WorkerMessagingProxy, because that class tracks and reports its activity to outside callers, and manages
 61// its own lifetime, via calls to workerObjectDestroyed, workerContextDestroyed, workerContextClosed, etc. It
 62// is basically impossible to correctly manage the lifetime of this class separately from WorkerMessagingProxy.
 63class WebWorkerClientImpl : public WebCore::WorkerMessagingProxy
6064 , public WebWorkerBase
6165 , public WebCommonWorkerClient {
6266public:

@@public:
6670 // WebCore::WorkerContextProxy methods:
6771 // These are called on the thread that created the worker. In the renderer
6872 // process, this will be the main WebKit thread.
69  virtual void startWorkerContext(const WebCore::KURL&,
70  const WTF::String&,
71  const WTF::String&,
72  WebCore::WorkerThreadStartMode) OVERRIDE;
7373 virtual void terminateWorkerContext() OVERRIDE;
74  virtual void postMessageToWorkerContext(
75  PassRefPtr<WebCore::SerializedScriptValue> message,
76  PassOwnPtr<WebCore::MessagePortChannelArray> channels) OVERRIDE;
77  virtual bool hasPendingActivity() const OVERRIDE;
78  virtual void workerObjectDestroyed() OVERRIDE;
79 
80 #if ENABLE(INSPECTOR)
81  virtual void connectToInspector(WebCore::WorkerContextProxy::PageInspector*) OVERRIDE;
82  virtual void disconnectFromInspector() OVERRIDE;
83  virtual void sendMessageToInspector(const String&) OVERRIDE;
84  virtual void postMessageToPageInspector(const String&) OVERRIDE;
85  virtual void updateInspectorStateCookie(const String&) OVERRIDE;
86 #endif
87  // WebCore::WorkerLoaderProxy methods:
88  virtual void postTaskToLoader(PassOwnPtr<WebCore::ScriptExecutionContext::Task>) OVERRIDE;
89  virtual bool postTaskForModeToWorkerContext(PassOwnPtr<WebCore::ScriptExecutionContext::Task>, const String& mode) OVERRIDE;
90 
91  // WebCore::WorkerObjectProxy methods:
92  virtual void postMessageToWorkerObject(PassRefPtr<WebCore::SerializedScriptValue>, PassOwnPtr<WebCore::MessagePortChannelArray>) OVERRIDE;
93  virtual void postExceptionToWorkerObject(const String& errorMessage, int lineNumber, const String& sourceURL) OVERRIDE;
94 
95  virtual void postConsoleMessageToWorkerObject(WebCore::MessageSource, WebCore::MessageLevel,
96  const String& message, int lineNumber, const String& sourceURL) OVERRIDE;
97  virtual void confirmMessageFromWorkerObject(bool) OVERRIDE;
98  virtual void reportPendingActivity(bool) OVERRIDE;
99  virtual void workerContextClosed() OVERRIDE;
100  virtual void workerContextDestroyed() OVERRIDE;
101 
102  // WebWorkerClientBase methods:
 74
 75 // WebCore::WorkerLoaderProxy methods
 76 virtual void* toWebWorkerBase() OVERRIDE;
 77
 78 // WebWorkerBase methods:
 79 virtual WebCore::WorkerLoaderProxy* workerLoaderProxy() OVERRIDE { return this; }
 80 virtual WebCommonWorkerClient* commonClient() OVERRIDE { return this; }
 81 virtual WebView* view() const OVERRIDE;
 82
 83 // WebCommonWorkerClient methods:
10384 virtual bool allowDatabase(WebFrame*, const WebString& name, const WebString& displayName, unsigned long estimatedSize) OVERRIDE;
10485 virtual bool allowFileSystem();
10586 virtual void openFileSystem(WebFileSystem::Type, long long size, bool create,
10687 WebFileSystemCallbacks*) OVERRIDE;
10788 virtual bool allowIndexedDB(const WebString& name) OVERRIDE;
10889
109  // WebCommentWorkerBase methods:
110  virtual WebCommonWorkerClient* commonClient() OVERRIDE { return this; }
111  virtual WebView* view() const OVERRIDE;
112 
11390private:
11491 WebWorkerClientImpl(WebCore::Worker*, WebFrameImpl*);
11592 virtual ~WebWorkerClientImpl();
11693
117  WebCore::WorkerMessagingProxy* m_proxy;
118  // Guard against context from being destroyed before a worker exits.
119  RefPtr<WebCore::ScriptExecutionContext> m_scriptExecutionContext;
12094 WebFrameImpl* m_webFrame;
12195};
12296

Source/WebKit/chromium/src/WorkerAsyncFileSystemChromium.cpp

4040#include "NotImplemented.h"
4141#include "WebFileSystemCallbacksImpl.h"
4242#include "WebFileWriter.h"
43 #include "WebWorkerBase.h"
4443#include "WorkerAsyncFileWriterChromium.h"
4544#include "WorkerContext.h"
4645#include "WorkerFileSystemCallbacksBridge.h"

@@WorkerAsyncFileSystemChromium::WorkerAsyncFileSystemChromium(ScriptExecutionCont
6261{
6362 ASSERT(m_scriptExecutionContext->isWorkerContext());
6463
65  WorkerLoaderProxy* workerLoaderProxy = &m_workerContext->thread()->workerLoaderProxy();
66  m_worker = static_cast<WebWorkerBase*>(workerLoaderProxy);
 64 m_workerLoaderProxy = &m_workerContext->thread()->workerLoaderProxy();
6765}
6866
6967WorkerAsyncFileSystemChromium::~WorkerAsyncFileSystemChromium()

@@PassRefPtr<WorkerFileSystemCallbacksBridge> WorkerAsyncFileSystemChromium::creat
194192 m_modeForCurrentOperation = fileSystemOperationsMode;
195193 m_modeForCurrentOperation.append(String::number(m_workerContext->thread()->runLoop().createUniqueId()));
196194
197  m_bridgeForCurrentOperation = WorkerFileSystemCallbacksBridge::create(m_worker, m_scriptExecutionContext, new WebKit::WebFileSystemCallbacksImpl(callbacks));
 195 m_bridgeForCurrentOperation = WorkerFileSystemCallbacksBridge::create(m_workerLoaderProxy, m_scriptExecutionContext, new WebKit::WebFileSystemCallbacksImpl(callbacks));
198196 return m_bridgeForCurrentOperation;
199197}
200198

Source/WebKit/chromium/src/WorkerAsyncFileSystemChromium.h

4141namespace WebKit {
4242class WebFileSystem;
4343class WebURL;
44 class WebWorkerBase;
4544class WorkerFileSystemCallbacksBridge;
4645}
4746

@@namespace WebCore {
5049class AsyncFileSystemCallbacks;
5150class ScriptExecutionContext;
5251class WorkerContext;
 52class WorkerLoaderProxy;
5353
5454class WorkerAsyncFileSystemChromium : public AsyncFileSystemChromium {
5555public:

@@private:
8282 PassRefPtr<WebKit::WorkerFileSystemCallbacksBridge> createWorkerFileSystemCallbacksBridge(PassOwnPtr<AsyncFileSystemCallbacks>);
8383
8484 ScriptExecutionContext* m_scriptExecutionContext;
85  WebKit::WebWorkerBase* m_worker;
 85 WorkerLoaderProxy* m_workerLoaderProxy;
8686 WorkerContext* m_workerContext;
8787 RefPtr<WebKit::WorkerFileSystemCallbacksBridge> m_bridgeForCurrentOperation;
8888 String m_modeForCurrentOperation;

LayoutTests/ChangeLog

 12012-12-31 Kenneth Russell <[email protected]>
 2
 3 [chromium] Creation of dedicated workers (isolates) leaks reference to HTMLDocument
 4 https://bugs.webkit.org/show_bug.cgi?id=105367
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 * fast/workers/resources/empty-worker.js: Added.
 9 * fast/workers/resources/worker-document-leak-iframe.html: Added.
 10 * fast/workers/worker-document-leak-expected.txt: Added.
 11 * fast/workers/worker-document-leak.html: Added.
 12
1132012-12-31 Kangil Han <[email protected]>
214
315 [EFL] css3/masking/clip-path-circle-relative-overflow.html needs expected results update after 97217

LayoutTests/fast/workers/resources/empty-worker.js

 1postMessage("closing");
 2close();

LayoutTests/fast/workers/resources/worker-document-leak-iframe.html

 1<!DOCTYPE html>
 2<html>
 3<body>
 4<script src="worker-util.js"></script>
 5<script>
 6var worker = new Worker('empty-worker.js');
 7worker.onmessage = function(event) {
 8 waitUntilWorkerThreadsExit(function() {
 9 parent.postMessage("done", "*");
 10 });
 11};
 12</script>
 13</body>
 14</html>

LayoutTests/fast/workers/worker-document-leak-expected.txt

 1Verify that creation of a worker does not leak its creating document.
 2
 3PASS: did not leak documents during test run
 4

LayoutTests/fast/workers/worker-document-leak.html

 1<!DOCTYPE html>
 2<html>
 3<body>
 4<p>Verify that creation of a worker does not leak its creating document.</p>
 5<div id='console'></div>
 6<script src='resources/worker-util.js'></script>
 7<script>
 8function log(message)
 9{
 10 document.getElementById("console").innerHTML += message + "<br>";
 11}
 12
 13if (window.testRunner) {
 14 testRunner.dumpAsText();
 15 testRunner.waitUntilDone();
 16}
 17
 18// Set this number as high as possible without introducing timeouts in debug builds.
 19// Reducing it does not require rebaselines.
 20var numIterations = 6;
 21
 22var currentIteration = 0;
 23var iframe = null;
 24var numLiveAtStart = 0;
 25var numLiveAtEnd = 0;
 26
 27window.onmessage = function(event) {
 28 if (event.data == "done") {
 29 runOneIteration();
 30 }
 31};
 32
 33function startTest()
 34{
 35 gc();
 36 if (window.internals && window.internals.numberOfLiveDocuments) {
 37 numLiveAtStart = window.internals.numberOfLiveDocuments();
 38 // Depending on which tests ran before this one in DumpRenderTree,
 39 // their Document instances may not have been fully cleaned up yet.
 40 // When this test is run in isolation, there should be only one
 41 // live document at this point.
 42 runOneIteration();
 43 } else {
 44 log("window.internals.numberOfLiveDocuments not available -- no point in running test");
 45 finishTest();
 46 }
 47}
 48
 49function runOneIteration() {
 50 if (currentIteration < numIterations) {
 51 ++currentIteration;
 52
 53 var createdIframe = false;
 54 if (!iframe) {
 55 iframe = document.createElement("iframe");
 56 createdIframe = true;
 57 }
 58 iframe.setAttribute("src", "resources/worker-document-leak-iframe.html");
 59 if (createdIframe)
 60 document.body.appendChild(iframe);
 61 } else {
 62 finishTest();
 63 }
 64}
 65
 66function finishTest()
 67{
 68 gc();
 69
 70 if (window.internals && window.internals.numberOfLiveDocuments) {
 71 numLiveAtEnd = window.internals.numberOfLiveDocuments();
 72 // Under no circumstances should the number of live documents
 73 // at the end be more than 1 greater than the number at the
 74 // beginning (because of the iframe).
 75 if (numLiveAtEnd > numLiveAtStart + 1) {
 76 log("FAIL: leaked documents during test run (started with " + numLiveAtStart + ", ended with " + numLiveAtEnd);
 77 } else {
 78 log("PASS: did not leak documents during test run");
 79 }
 80 }
 81
 82 if (window.testRunner)
 83 testRunner.notifyDone();
 84}
 85
 86window.onload = startTest;
 87</script>
 88</body>
 89</html>