WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
27420
Refactor WorkerContext to move DedicatedWorker-specific APIs into DedicatedWorkerContext
https://bugs.webkit.org/show_bug.cgi?id=27420
Summary
Refactor WorkerContext to move DedicatedWorker-specific APIs into DedicatedWo...
Andrew Wilson
Reported
2009-07-18 18:06:52 PDT
There are a set of APIs that are common to both DedicatedWorkerGlobalScope and SharedWorkerGlobalScope. We should keep those in WorkerContext, and refactor the DedicatedWorker-specific APIs (like onmessage/postMessage) into a derived class.
Attachments
proposed patch
(58.08 KB, patch)
2009-07-19 09:07 PDT
,
Andrew Wilson
no flags
Details
Formatted Diff
Diff
Patch addressing levin's comments
(58.30 KB, patch)
2009-07-19 17:47 PDT
,
Andrew Wilson
no flags
Details
Formatted Diff
Diff
Patch addressing dimich's comments
(62.79 KB, patch)
2009-07-23 17:57 PDT
,
Andrew Wilson
abarth
: review+
Details
Formatted Diff
Diff
patch fixing build error from last night's codegen changes
(64.21 KB, patch)
2009-07-24 12:02 PDT
,
Andrew Wilson
no flags
Details
Formatted Diff
Diff
Show Obsolete
(3)
View All
Add attachment
proposed patch, testcase, etc.
Andrew Wilson
Comment 1
2009-07-19 09:07:37 PDT
Created
attachment 33048
[details]
proposed patch I'd like someone with some experience with the JS bindings internals to take a look at WebCore/bindings/js/WorkerScriptController::initScript where I'm setting up the prototype for the global context. I'll try to find someone on IRC on Monday.
David Levin
Comment 2
2009-07-19 11:38:59 PDT
Comment on
attachment 33048
[details]
proposed patch Just some quick style nits that I noticed when I briefly looked at this.
> diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog > + Reviewed by NOBODY (OOPS!). > + > + Refactor WorkerContext to move DedicatedWorker-specific APIs into DedicatedWorkerContext
Off by one space.
> diff --git a/WebCore/bindings/js/JSEventTarget.cpp b/WebCore/bindings/js/JSEventTarget.cpp
> #if ENABLE(WORKERS) > #include "JSWorker.h" > -#include "JSWorkerContext.h" > +#include "JSDedicatedWorkerContext.h" > #include "Worker.h" > -#include "WorkerContext.h" > +#include "DedicatedWorkerContext.h"
Out of sort order.
> diff --git a/WebCore/bindings/v8/V8Index.cpp b/WebCore/bindings/v8/V8Index.cpp > @@ -59,8 +59,8 @@ > -#include "V8CSSVariablesRule.h" > -#include "V8DataGridColumn.h" > +#include "V8CSSVariablesRule.h" > +#include "V8DataGridColumn.h"
> -#if ENABLE(DOM_STORAGE) > -#include "V8Storage.h" > -#include "V8StorageEvent.h" > +#if ENABLE(DOM_STORAGE) > +#include "V8Storage.h" > +#include "V8StorageEvent.h" > #endif
It would be good to not have these unrelated changes in this patch.
> diff --git a/WebCore/bindings/v8/V8Index.h b/WebCore/bindings/v8/V8Index.h
> @@ -79,8 +80,8 @@ typedef v8::Persistent<v8::FunctionTemplate> (*FunctionTemplateFactory)(); > - V(COMMENT, Comment) \ > - V(DATAGRIDCOLUMN, DataGridColumn) \ > + V(COMMENT, Comment) \ > + V(DATAGRIDCOLUMN, DataGridColumn) \
> -#endif > - > -#if ENABLE(DOM_STORAGE) > -#define DOM_OBJECT_STORAGE_TYPES(V) \ > - V(STORAGE, Storage) \ > - V(STORAGEEVENT, StorageEvent) > -#else > -#define DOM_OBJECT_STORAGE_TYPES(V) > +#endif > + > +#if ENABLE(DOM_STORAGE) > +#define DOM_OBJECT_STORAGE_TYPES(V) \ > + V(STORAGE, Storage) \ > + V(STORAGEEVENT, StorageEvent) > +#else > +#define DOM_OBJECT_STORAGE_TYPES(V) > #endif
It would be good to not have these unrelated changes in this patch.
> diff --git a/WebCore/dom/EventTarget.h b/WebCore/dom/EventTarget.h > @@ -48,7 +48,7 @@ namespace WebCore { > class ScriptExecutionContext; > class SharedWorker; > class Worker; > - class WorkerContext; > + class DedicatedWorkerContext;
Out of sort order.
> diff --git a/WebCore/workers/DedicatedWorkerContext.cpp b/WebCore/workers/DedicatedWorkerContext.cpp
> diff --git a/WebCore/workers/WorkerThread.cpp b/WebCore/workers/WorkerThread.cpp > #include "PlatformString.h" > #include "ScriptSourceCode.h" > #include "ScriptValue.h" > -#include "WorkerContext.h" > +#include "DedicatedWorkerContext.h" > #include "WorkerObjectProxy.h"
Out of sort order.
Andrew Wilson
Comment 3
2009-07-19 17:47:25 PDT
Created
attachment 33068
[details]
Patch addressing levin's comments Per our IRC conversation, I'm leaving the changes in this patch that remove the extraneous CRs from V8Index.cpp/h
Dmitry Titov
Comment 4
2009-07-20 13:14:49 PDT
A note about v8-related changes. You might want to ask Mads Ager to take a look, since I feel a better v8 expert could be useful here :-) It doesn't seem that V8ClassIndex::WORKERCONTEXT is removed from everywhere. I think it should be because this is an enum value that is embedded into a v8 wrapper as an id of its type. Lookups and type conversions use that as an enum entry into some switch statements and lookup tables. So if we now have V8ClassIndex::DEDICATEDWORKERCONTEXT, it should replace the old enum value everywhere. Later, you'll also have SHAREDWORKERCONTEXT. For example, v8 version of WorkerContextExecutionProxy::retrieve() won't work since it won't be able to find a WORKERCONTEXT in a current v8 context... It might be easier (maybe) to add a virtual ScriptExecutionContext::IsDedicatedWorkerContext() (in addition to isDocument etc) and have a single type of the v8 wrapper but check and cast in runtime.
David Levin
Comment 5
2009-07-21 12:23:06 PDT
Comment on
attachment 33068
[details]
Patch addressing levin's comments I'm marking this obsolete to move it out of the review queue because I'm fairly certain atwilson is doing some fixes to it. Drew if I got this wrong please undo this :)
Andrew Wilson
Comment 6
2009-07-23 17:57:54 PDT
Created
attachment 33397
[details]
Patch addressing dimich's comments I fixed up a number of places where we were doing the wrong thing in the V8 bindings. Note that V8ClassIndex::WORKERCONTEXT can't go away entirely, as it's still used by the generated code in V8WorkerContext.cpp, and also used for generating the template chain for derived classes like V8DedicatedWorkerContext. Also, it is OK to do lookupDOMWrapper(V8ClassIndex::WORKERCONTEXT, global) in WorkerContextExecutionProxy::retrieve(), because lookupDOMWrapper walks up the prototype chain to determine the class. Likewise for calling convertToNativeObject(WORKERCONTEXT, global) - it still works no matter what type you pass in, derived or base. In fact, convertToNativeObject() mostly just uses the passed-in type for error checking, as it always ends up pulling a pointer to the impl object out of the same place in the wrapper regardless of type anyway.
Adam Barth
Comment 7
2009-07-23 23:42:34 PDT
Comment on
attachment 33397
[details]
Patch addressing dimich's comments Ok. One infinitesimal nit:
> - private: > + protected: > WorkerContext(const KURL&, const String&, WorkerThread*); > + bool isClosing() { return m_closing; } > + private: > > virtual void refScriptExecutionContext() { ref(); } > virtual void derefScriptExecutionContext() { deref(); }
Please move the private to below the blank line.
Dmitry Titov
Comment 8
2009-07-24 10:49:40 PDT
Assigning to
dimich@chromium.org
for landing.
Andrew Wilson
Comment 9
2009-07-24 12:02:08 PDT
Created
attachment 33459
[details]
patch fixing build error from last night's codegen changes
Dmitry Titov
Comment 10
2009-07-24 12:58:56 PDT
Fixed per abarth's comment and landed:
http://trac.webkit.org/changeset/46369
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug