Closed Bug 1113627 Opened 10 years ago Closed 9 years ago

Refactor lifecycle event dispatching and handling

Categories

(Core :: DOM: Workers, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla38

People

(Reporter: nsm, Assigned: nsm)

References

Details

Attachments

(2 files)

install and activate events are handled by common code that then uses a ContinueLifecycleTask to finish the installation on the main thread based on success/error.
Attachment #8539238 - Flags: review?(amarchesini)
Comment on attachment 8539238 [details] [diff] [review]
Refactor lifecycle event dispatching and handling

Review of attachment 8539238 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/workers/ServiceWorkerManager.cpp
@@ +151,5 @@
> +  virtual ~ContinueLifecycleTask()
> +  { }
> +
> +public:
> +  virtual void ContinueAfterWorkerEvent(bool aSuccess, bool aActivateImmediately)

what about:

virtual void ContinueAfterWorkerEvent(bool aSuccess, bool aActivateImmediately) = 0;

@@ +234,1 @@
>        : WorkerRunnable(aWorkerPrivate, WorkerThreadModifyBusyCount),

This indentation is different than what you have in the other classes.
Be consistent with the comma.

@@ +910,5 @@
>      WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
>      MOZ_ASSERT(workerPrivate);
>      workerPrivate->AssertIsOnWorkerThread();
>  
> +    nsRefPtr<ContinueLifecycleRunnable> r = new ContinueLifecycleRunnable(mTask, true /* success */, mActivateImmediately);

80chars

@@ +921,5 @@
> +    WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
> +    MOZ_ASSERT(workerPrivate);
> +    workerPrivate->AssertIsOnWorkerThread();
> +
> +    nsRefPtr<ContinueLifecycleRunnable> r = new ContinueLifecycleRunnable(mTask, false /* success */, mActivateImmediately);

80chars

@@ +985,5 @@
>  
> +  // activateimmediately is only relevant to "install" event.
> +  bool activateImmediately = false;
> +  InstallEvent* downCast = static_cast<InstallEvent*>(event.get());
> +  if (downCast) {

You don't need to do this check. if event exists, downCast will exist.
Attachment #8539238 - Flags: review?(amarchesini) → review+
(In reply to Andrea Marchesini (:baku) from comment #2)
> 
> @@ +985,5 @@
> >  
> > +  // activateimmediately is only relevant to "install" event.
> > +  bool activateImmediately = false;
> > +  InstallEvent* downCast = static_cast<InstallEvent*>(event.get());
> > +  if (downCast) {
> 
> You don't need to do this check. if event exists, downCast will exist.

event is an ExtendableEvent, which may not be an InstallEvent.
(In reply to Nikhil Marathe [:nsm] (needinfo? please) from comment #3)
> (In reply to Andrea Marchesini (:baku) from comment #2)
> > 
> > @@ +985,5 @@
> > >  
> > > +  // activateimmediately is only relevant to "install" event.
> > > +  bool activateImmediately = false;
> > > +  InstallEvent* downCast = static_cast<InstallEvent*>(event.get());
> > > +  if (downCast) {
> > 
> > You don't need to do this check. if event exists, downCast will exist.
> 
> event is an ExtendableEvent, which may not be an InstallEvent.

Right, i found out that static_cast<> doesn't really work the way i thought, the hard way
https://treeherder.mozilla.org/ui/logviewer.html#?job_id=5846471&repo=mozilla-inbound. Will fix on monday
Boris, is this what you meant by adding a As*Event method?
Flags: needinfo?(nsm.nikhil)
Attachment #8554846 - Flags: review?(bzbarsky)
Comment on attachment 8554846 [details] [diff] [review]
fix InstallEvent downcast

Yes, except you can put the version that returns nullptr on Event, right after the place where it #includes mozilla/dom/GeneratedEventList.h.
Attachment #8554846 - Flags: review?(bzbarsky) → review+
https://hg.mozilla.org/mozilla-central/rev/53a300073430
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla38
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: