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

Issue 238043002: Teach EmbeddedWorkerInstance to create a process when it needs one. (Closed)

Created:
6 years, 8 months ago by Jeffrey Yasskin
Modified:
6 years, 7 months ago
Reviewers:
kinuko, michaeln, jam
CC:
chromium-reviews, jsbell+serviceworker_chromium.org, tzik, serviceworker-reviews, jam, nhiroki, darin-cc_chromium.org, horo+watch_chromium.org, kinuko+watch, alecflett+watch_chromium.org, falken
Visibility:
Public.

Description

Teach EmbeddedWorkerInstance to create a process when it needs one. This saves the BrowserContext into the ServiceWorkerContextWrapper, and uses it when no process is available. We always choose a renderer process on the UI thread and take a reference to it before asking the renderer to start the SW thread. This also fixes a race where a process might die before we have a chance to use it. We'll probably need to thread more process IDs through in cases where there might not be a ProviderHost, but that can wait for a subsequent CL. BUG=359811, 362060, 362058 Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=266825

Patch Set 1 #

Patch Set 2 : Save the BrowserContext into the ServiceWorkerContextWrapper instead. #

Patch Set 3 : Null out browser_context_ in Shutdown #

Total comments: 18

Patch Set 4 : Fix build, introduce ProcessManager, and split DispatchInstall/Activate #

Patch Set 5 : Make StartWorker's process IDs argument optional: most cases are covered by existing ProviderHosts.… #

Patch Set 6 : Fix another compile error. #

Total comments: 22

Patch Set 7 : Sync #

Patch Set 8 : Fix kinuko's comments. #

Total comments: 2

Patch Set 9 : Handle 2 places where context_ could be NULL. #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+774 lines, -266 lines) Patch
M content/browser/service_worker/embedded_worker_instance.h View 1 2 3 5 chunks +19 lines, -8 lines 0 comments Download
M content/browser/service_worker/embedded_worker_instance.cc View 1 2 3 4 3 chunks +51 lines, -31 lines 0 comments Download
M content/browser/service_worker/embedded_worker_instance_unittest.cc View 1 2 3 4 5 6 7 5 chunks +63 lines, -18 lines 0 comments Download
M content/browser/service_worker/embedded_worker_registry.h View 1 2 3 5 chunks +21 lines, -5 lines 0 comments Download
M content/browser/service_worker/embedded_worker_registry.cc View 1 2 3 4 5 6 7 8 4 chunks +67 lines, -11 lines 0 comments Download
M content/browser/service_worker/embedded_worker_test_helper.h View 1 4 chunks +10 lines, -5 lines 0 comments Download
M content/browser/service_worker/embedded_worker_test_helper.cc View 1 2 3 4 5 6 7 3 chunks +26 lines, -6 lines 0 comments Download
M content/browser/service_worker/service_worker_browsertest.cc View 1 2 3 4 3 chunks +11 lines, -5 lines 0 comments Download
M content/browser/service_worker/service_worker_context_core.h View 1 2 3 4 5 chunks +13 lines, -1 line 0 comments Download
M content/browser/service_worker/service_worker_context_core.cc View 1 2 3 2 chunks +9 lines, -4 lines 0 comments Download
M content/browser/service_worker/service_worker_context_unittest.cc View 1 15 chunks +24 lines, -28 lines 0 comments Download
M content/browser/service_worker/service_worker_context_wrapper.h View 1 2 3 5 chunks +14 lines, -9 lines 0 comments Download
M content/browser/service_worker/service_worker_context_wrapper.cc View 1 2 3 5 chunks +17 lines, -8 lines 0 comments Download
M content/browser/service_worker/service_worker_dispatcher_host.h View 1 2 chunks +13 lines, -1 line 0 comments Download
M content/browser/service_worker/service_worker_dispatcher_host.cc View 1 3 chunks +24 lines, -1 line 0 comments Download
M content/browser/service_worker/service_worker_dispatcher_host_unittest.cc View 1 5 chunks +10 lines, -15 lines 0 comments Download
M content/browser/service_worker/service_worker_handle_unittest.cc View 1 2 3 4 3 chunks +9 lines, -10 lines 0 comments Download
M content/browser/service_worker/service_worker_job_unittest.cc View 1 3 chunks +8 lines, -12 lines 0 comments Download
A content/browser/service_worker/service_worker_process_manager.h View 1 2 3 4 5 6 7 1 chunk +84 lines, -0 lines 2 comments Download
A content/browser/service_worker/service_worker_process_manager.cc View 1 2 3 4 5 6 7 1 chunk +145 lines, -0 lines 0 comments Download
M content/browser/service_worker/service_worker_provider_host_unittest.cc View 1 2 3 1 chunk +5 lines, -1 line 0 comments Download
M content/browser/service_worker/service_worker_register_job.h View 1 2 3 4 1 chunk +4 lines, -3 lines 0 comments Download
M content/browser/service_worker/service_worker_register_job.cc View 1 2 3 4 5 6 7 2 chunks +4 lines, -12 lines 0 comments Download
M content/browser/service_worker/service_worker_registration_unittest.cc View 1 2 3 4 1 chunk +5 lines, -1 line 0 comments Download
M content/browser/service_worker/service_worker_storage_unittest.cc View 1 2 3 1 chunk +5 lines, -1 line 0 comments Download
M content/browser/service_worker/service_worker_url_request_job_unittest.cc View 1 2 chunks +7 lines, -10 lines 0 comments Download
M content/browser/service_worker/service_worker_version.h View 1 2 3 4 5 6 7 2 chunks +14 lines, -0 lines 0 comments Download
M content/browser/service_worker/service_worker_version.cc View 1 2 3 4 5 6 7 3 chunks +79 lines, -45 lines 0 comments Download
M content/browser/service_worker/service_worker_version_unittest.cc View 1 2 3 4 3 chunks +6 lines, -9 lines 0 comments Download
M content/browser/storage_partition_impl.cc View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M content/content_browser.gypi View 1 2 3 4 5 6 1 chunk +2 lines, -0 lines 0 comments Download
M content/public/browser/service_worker_context.h View 1 2 3 4 2 chunks +3 lines, -5 lines 0 comments Download
M content/renderer/service_worker/embedded_worker_dispatcher.cc View 1 1 chunk +1 line, -0 lines 0 comments Download

Messages

Total messages: 25 (0 generated)
Jeffrey Yasskin
I haven't fully proofread this yet, so apologies if it has some obvious mistakes. https://codereview.chromium.org/238043002/diff/30001/content/browser/service_worker/service_worker_browsertest.cc ...
6 years, 8 months ago (2014-04-25 04:40:32 UTC) #1
jam
https://codereview.chromium.org/238043002/diff/30001/content/public/browser/service_worker_context.h File content/public/browser/service_worker_context.h (right): https://codereview.chromium.org/238043002/diff/30001/content/public/browser/service_worker_context.h#newcode40 content/public/browser/service_worker_context.h:40: BrowserContext* context, this seems redundant since ServiceWorkerContext should know ...
6 years, 8 months ago (2014-04-25 04:59:30 UTC) #2
kinuko
https://codereview.chromium.org/238043002/diff/30001/content/browser/service_worker/service_worker_context_wrapper.cc File content/browser/service_worker/service_worker_context_wrapper.cc (right): https://codereview.chromium.org/238043002/diff/30001/content/browser/service_worker/service_worker_context_wrapper.cc#newcode20 content/browser/service_worker/service_worker_context_wrapper.cc:20: base::LazyInstance<base::Callback<bool(int)> > s_decrement_worker_refcount; Whoa... ah ok it's for testing. ...
6 years, 8 months ago (2014-04-25 13:46:34 UTC) #3
Jeffrey Yasskin
https://codereview.chromium.org/238043002/diff/30001/content/browser/service_worker/service_worker_context_wrapper.cc File content/browser/service_worker/service_worker_context_wrapper.cc (right): https://codereview.chromium.org/238043002/diff/30001/content/browser/service_worker/service_worker_context_wrapper.cc#newcode20 content/browser/service_worker/service_worker_context_wrapper.cc:20: base::LazyInstance<base::Callback<bool(int)> > s_decrement_worker_refcount; On 2014/04/25 13:46:35, kinuko wrote: > ...
6 years, 8 months ago (2014-04-26 03:52:18 UTC) #4
kinuko
This looks much nicer to me now, a few more nits. https://codereview.chromium.org/238043002/diff/90001/content/browser/service_worker/embedded_worker_registry.cc File content/browser/service_worker/embedded_worker_registry.cc (right): ...
6 years, 8 months ago (2014-04-28 06:58:15 UTC) #5
Jeffrey Yasskin
https://codereview.chromium.org/238043002/diff/90001/content/browser/service_worker/embedded_worker_registry.cc File content/browser/service_worker/embedded_worker_registry.cc (right): https://codereview.chromium.org/238043002/diff/90001/content/browser/service_worker/embedded_worker_registry.cc#newcode51 content/browser/service_worker/embedded_worker_registry.cc:51: void EmbeddedWorkerRegistry::StartWorkerWithProcessId( On 2014/04/28 06:58:16, kinuko wrote: > nit: ...
6 years, 7 months ago (2014-04-28 20:47:40 UTC) #6
kinuko
lgtm https://codereview.chromium.org/238043002/diff/90001/content/browser/service_worker/service_worker_process_manager.h File content/browser/service_worker/service_worker_process_manager.h (right): https://codereview.chromium.org/238043002/diff/90001/content/browser/service_worker/service_worker_process_manager.h#newcode76 content/browser/service_worker/service_worker_process_manager.h:76: void operator()(content::ServiceWorkerProcessManager* ptr) const; On 2014/04/28 20:47:40, Jeffrey ...
6 years, 7 months ago (2014-04-29 01:06:51 UTC) #7
jam
gypi & public lgtm
6 years, 7 months ago (2014-04-29 01:07:54 UTC) #8
Jeffrey Yasskin
Thanks for the review! https://codereview.chromium.org/238043002/diff/130001/content/browser/service_worker/embedded_worker_registry.cc File content/browser/service_worker/embedded_worker_registry.cc (right): https://codereview.chromium.org/238043002/diff/130001/content/browser/service_worker/embedded_worker_registry.cc#newcode182 content/browser/service_worker/embedded_worker_registry.cc:182: context_->process_manager()->ReleaseWorkerProcess(process_id); On 2014/04/29 01:06:52, kinuko ...
6 years, 7 months ago (2014-04-29 01:37:29 UTC) #9
Jeffrey Yasskin
The CQ bit was checked by jyasskin@chromium.org
6 years, 7 months ago (2014-04-29 01:37:35 UTC) #10
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/jyasskin@chromium.org/238043002/150001
6 years, 7 months ago (2014-04-29 01:38:41 UTC) #11
commit-bot: I haz the power
The CQ bit was unchecked by commit-bot@chromium.org
6 years, 7 months ago (2014-04-29 02:59:03 UTC) #12
commit-bot: I haz the power
Try jobs failed on following builders: tryserver.chromium on linux_chromium_chromeos_rel
6 years, 7 months ago (2014-04-29 02:59:04 UTC) #13
Jeffrey Yasskin
The CQ bit was checked by jyasskin@chromium.org
6 years, 7 months ago (2014-04-29 05:21:06 UTC) #14
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/jyasskin@chromium.org/238043002/150001
6 years, 7 months ago (2014-04-29 05:21:53 UTC) #15
commit-bot: I haz the power
Change committed as 266825
6 years, 7 months ago (2014-04-29 10:15:16 UTC) #16
michaeln
https://codereview.chromium.org/238043002/diff/150001/content/browser/service_worker/service_worker_process_manager.h File content/browser/service_worker/service_worker_process_manager.h (right): https://codereview.chromium.org/238043002/diff/150001/content/browser/service_worker/service_worker_process_manager.h#newcode28 content/browser/service_worker/service_worker_process_manager.h:28: // |*this| must be owned by |context_wrapper|->context(). Hmmm... does ...
6 years, 7 months ago (2014-04-29 19:08:44 UTC) #17
michaeln
I don't see how that cycle is broken. > must be owned by |context_wrapper|->context(). > ...
6 years, 7 months ago (2014-04-29 19:10:51 UTC) #18
Jeffrey Yasskin
https://codereview.chromium.org/238043002/diff/150001/content/browser/service_worker/service_worker_process_manager.h File content/browser/service_worker/service_worker_process_manager.h (right): https://codereview.chromium.org/238043002/diff/150001/content/browser/service_worker/service_worker_process_manager.h#newcode28 content/browser/service_worker/service_worker_process_manager.h:28: // |*this| must be owned by |context_wrapper|->context(). On 2014/04/29 ...
6 years, 7 months ago (2014-04-29 19:13:24 UTC) #19
michaeln1
Ah... i see, thanx! > Yes. The cycle is broken in Wrapper::Shutdown(). I forgot to ...
6 years, 7 months ago (2014-04-29 22:14:58 UTC) #20
horo
After this patch is landed, when I close the Chrome browser after registering a ServiceWorker, ...
6 years, 7 months ago (2014-04-30 03:12:29 UTC) #21
kinuko
On 2014/04/30 03:12:29, horo wrote: > After this patch is landed, when I close the ...
6 years, 7 months ago (2014-04-30 05:31:19 UTC) #22
kinuko
On 2014/04/30 05:31:19, kinuko wrote: > On 2014/04/30 03:12:29, horo wrote: > > After this ...
6 years, 7 months ago (2014-04-30 05:32:25 UTC) #23
horo
Filed a bug http://crbug.com/368570.
6 years, 7 months ago (2014-04-30 05:55:50 UTC) #24
Jeffrey Yasskin
6 years, 7 months ago (2014-04-30 07:27:20 UTC) #25
Sorry for the trouble. I'll look into getting this into the right
order tomorrow, unless you've figured it out or rolled it back first.

On Tue, Apr 29, 2014 at 8:12 PM,  <horo@chromium.org> wrote:
> After this patch is landed, when I close the Chrome browser after
> registering a
> ServiceWorker, DCHECK in ProfileDestroyer::DestroyProfileWhenAppropriate()
> fails
> because content::RenderProcessHost::run_renderer_in_process() is 1.
>
> I think this is because the registered ServiceWorker doesn't stop and
> DecrementWorkerRefcount() is not called when I click the close button of
> Chrome.
>
> Is this intended or a bug?
>
> https://codereview.chromium.org/238043002/

To unsubscribe from this group and stop receiving emails from it, send an email
to chromium-reviews+unsubscribe@chromium.org.

Powered by Google App Engine
This is Rietveld 408576698