Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Issue 309503014: Make ServiceWorkerDispatcher reuse existing WebServiceWorkerImpls. (Closed)

Created:
6 years, 6 months ago by dominicc (has gone to gerrit)
Modified:
6 years, 6 months ago
Reviewers:
falken, michaeln
CC:
chromium-reviews, jsbell+serviceworker_chromium.org, tzik, serviceworker-reviews, jam, kinuko+serviceworker, nhiroki, darin-cc_chromium.org, horo+watch_chromium.org, alecflett+watch_chromium.org
Visibility:
Public.

Description

Make ServiceWorkerDispatcher reuse existing WebServiceWorkerImpls. ServiceWorkerDispatcher used to mint new WebServiceWorkerImpl instances every time it was passed a representation of a Service Worker. Ultimately, this causes user script to see distinct objects representing the same Service Worker, which is Confusing and Wrong. This patch makes ServiceWorkerDispatcher use its table of existing WebServiceWorkerImpls to consistently represent a ServiceWorker with the same object. A chunk of this patch is concerned with making it explicit when a ServiceWorkerHandleReference, which a WebServiceWorkerImpl wraps, is being created in the renderer (and should send an add-ref message to the browser) versus being adopted in the renderer. BUG=361907 TEST=ServiceWorker* Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=274477

Patch Set 1 #

Total comments: 5

Patch Set 2 : Correct comment. #

Messages

Total messages: 18 (0 generated)
dominicc (has gone to gerrit)
PTAL
6 years, 6 months ago (2014-06-02 04:37:29 UTC) #1
falken
I think this looks good but have a question. https://codereview.chromium.org/309503014/diff/1/content/child/service_worker/service_worker_dispatcher.cc File content/child/service_worker/service_worker_dispatcher.cc (right): https://codereview.chromium.org/309503014/diff/1/content/child/service_worker/service_worker_dispatcher.cc#newcode161 content/child/service_worker/service_worker_dispatcher.cc:161: ...
6 years, 6 months ago (2014-06-02 05:40:10 UTC) #2
falken
https://codereview.chromium.org/309503014/diff/1/content/child/service_worker/service_worker_dispatcher.cc File content/child/service_worker/service_worker_dispatcher.cc (right): https://codereview.chromium.org/309503014/diff/1/content/child/service_worker/service_worker_dispatcher.cc#newcode161 content/child/service_worker/service_worker_dispatcher.cc:161: ServiceWorkerHandleReference::Adopt(info, thread_safe_sender_); On 2014/06/02 05:40:11, falken wrote: > I'm ...
6 years, 6 months ago (2014-06-02 05:56:18 UTC) #3
dominicc (has gone to gerrit)
Fixed the comment. On 2014/06/02 05:56:18, falken wrote: > https://codereview.chromium.org/309503014/diff/1/content/child/service_worker/service_worker_dispatcher.cc > File content/child/service_worker/service_worker_dispatcher.cc (right): > ...
6 years, 6 months ago (2014-06-02 13:44:33 UTC) #4
falken
lgtm
6 years, 6 months ago (2014-06-02 15:58:21 UTC) #5
michaeln
this looks like a work in progress. can you outline what you have in mind ...
6 years, 6 months ago (2014-06-02 21:11:18 UTC) #6
michaeln
nm... i see the bug and history there
6 years, 6 months ago (2014-06-02 21:35:44 UTC) #7
dominicc (has gone to gerrit)
On 2014/06/02 21:11:18, michaeln wrote: > this looks like a work in progress. can you ...
6 years, 6 months ago (2014-06-03 00:39:39 UTC) #8
dominicc (has gone to gerrit)
The CQ bit was checked by dominicc@chromium.org
6 years, 6 months ago (2014-06-03 00:39:49 UTC) #9
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/dominicc@chromium.org/309503014/20001
6 years, 6 months ago (2014-06-03 00:41:49 UTC) #10
commit-bot: I haz the power
FYI, CQ is re-trying this CL (attempt #1). The failing builders are: linux_chromium_chromeos_clang_dbg on tryserver.chromium ...
6 years, 6 months ago (2014-06-03 04:31:35 UTC) #11
commit-bot: I haz the power
The CQ bit was unchecked by commit-bot@chromium.org
6 years, 6 months ago (2014-06-03 06:18:06 UTC) #12
commit-bot: I haz the power
Try jobs failed on following builders: linux_chromium_chromeos_clang_dbg on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/linux_chromium_chromeos_clang_dbg/builds/20538)
6 years, 6 months ago (2014-06-03 06:18:06 UTC) #13
dominicc (has gone to gerrit)
The CQ bit was checked by dominicc@chromium.org
6 years, 6 months ago (2014-06-03 06:22:04 UTC) #14
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/dominicc@chromium.org/309503014/20001
6 years, 6 months ago (2014-06-03 06:23:31 UTC) #15
commit-bot: I haz the power
Change committed as 274477
6 years, 6 months ago (2014-06-03 12:12:27 UTC) #16
michaeln
On 2014/06/03 00:39:39, dominicc wrote: > On 2014/06/02 21:11:18, michaeln wrote: > > this looks ...
6 years, 6 months ago (2014-06-03 20:07:53 UTC) #17
dominicc (has gone to gerrit)
6 years, 6 months ago (2014-06-04 01:42:48 UTC) #18
Message was sent while issue was closed.
On 2014/06/03 20:07:53, michaeln wrote:
> On 2014/06/03 00:39:39, dominicc wrote:
> > On 2014/06/02 21:11:18, michaeln wrote:
> > > this looks like a work in progress. can you outline what you have in mind
> for
> > > this?
> > 
> > I'm poking at it. It might make sense to move this map of
> > handle->WebServiceWorkerImpl from the dispatcher to the provider.
> 
> Maybe we can chat about how that gets put together next week?

SG

> > >
> >
>
https://codereview.chromium.org/309503014/diff/1/content/child/service_worker...
> > > File content/child/service_worker/service_worker_dispatcher.h (right):
> > > 
> > >
> >
>
https://codereview.chromium.org/309503014/diff/1/content/child/service_worker...
> > > content/child/service_worker/service_worker_dispatcher.h:73: // If an
> existing
> > > WebServiceWorkerImpl exists for the Service
> > > fyi: eventually, i think we'll have consumers of this class on both the
main
> > > thread and on background thread.
> > 
> > You mean for dedicated workers?
> 
> I mean for workers in general. Presumably a serviceworker script can call
> register() in some future,

Maybe. In the short to medium term it looks like they can update and unregister,
but not register.

Are you suggesting something like "stacked" Service Workers? It would make sense
to explore something like that in the implementation by reimplementing AppCache
with Service Worker machinery and make AppCache and Service Workers work
together (which would imply a stack of two.)

> and a sharedworker can have a 'controller'. In both
> cases we have instances of WebCore::ServiceWorker backed by
WebServiceWorkerImpl
> objects.

The SharedWorker case is just like a page and its controller in that respect. I
think that the SharedWorker would have its own ServiceWorker and
WebServiceWorkerImpl object; I do not think we should be sharing these. Remember
that the WebCore::ServiceWorker observes an ExecutionContext, it isn't agile
across contexts.

Multiple WebCore::ServiceWorkers sharing a WebServiceWorkerImpl is a possible
alternate design. It is more complicated but may mean slightly less IPC.

Let's discuss in person.

> > >
> >
>
https://codereview.chromium.org/309503014/diff/1/content/child/service_worker...
> > > content/child/service_worker/service_worker_dispatcher.h:79: //
> > TODO(dominicc):
> > > The lifetime of WebServiceWorkerImpl is too tricky; this
> > > how does the caller know when ownership is transferred vs not?
> > 
> > The caller knows by the type of message received.
> > 
> > I think I will write this up in a doc. I think I understand this well now.
It
> is
> > not tricky but perhaps not obvious from casual code reading.
> 
> Would it make sense to create two different methods for the different type of
> callsites?

We could. I think this patch makes the situation clearer than before; we could
take that Boolean parameter and make them separate entrypoints which would be
even more explicit.

Does Mojo have something to keep a remote object alive? I wonder if this is
something we outsource instead of working so hard at it ourselves...

Powered by Google App Engine
This is Rietveld 408576698