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

Side by Side Diff: content/browser/service_worker/service_worker_version.cc

Issue 85023003: EmbeddedWorker, browser side code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/browser/service_worker/service_worker_version.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/service_worker/service_worker_version.h" 5 #include "content/browser/service_worker/service_worker_version.h"
6 6
7 #include "base/stl_util.h"
8 #include "content/browser/service_worker/embedded_worker_instance.h"
9 #include "content/browser/service_worker/embedded_worker_registry.h"
10 #include "content/browser/service_worker/service_worker_context_core.h"
7 #include "content/browser/service_worker/service_worker_registration.h" 11 #include "content/browser/service_worker/service_worker_registration.h"
8 12
9 namespace content { 13 namespace content {
10 14
11 ServiceWorkerVersion::ServiceWorkerVersion( 15 ServiceWorkerVersion::ServiceWorkerVersion(
12 ServiceWorkerRegistration* registration) 16 ServiceWorkerRegistration* registration,
13 : is_shutdown_(false), registration_(registration) {} 17 EmbeddedWorkerRegistry* worker_registry,
18 int64 version_id)
19 : version_id_(version_id),
20 is_shutdown_(false),
21 registration_(registration) {
22 if (worker_registry)
23 embedded_worker_ = worker_registry->CreateWorker();
24 }
14 25
15 ServiceWorkerVersion::~ServiceWorkerVersion() { DCHECK(is_shutdown_); } 26 ServiceWorkerVersion::~ServiceWorkerVersion() { DCHECK(is_shutdown_); }
16 27
17 void ServiceWorkerVersion::Shutdown() { 28 void ServiceWorkerVersion::Shutdown() {
18 is_shutdown_ = true; 29 is_shutdown_ = true;
19 registration_ = NULL; 30 registration_ = NULL;
31 embedded_worker_.reset();
32 }
33
34 void ServiceWorkerVersion::StartWorker() {
35 DCHECK(!is_shutdown_);
36 DCHECK(registration_);
37 embedded_worker_->Start(version_id_, registration_->script_url());
38 }
39
40 void ServiceWorkerVersion::StopWorker() {
41 DCHECK(!is_shutdown_);
42 embedded_worker_->Stop();
43 }
44
45 void ServiceWorkerVersion::OnAssociateProvider(
46 ServiceWorkerProviderHost* provider_host) {
47 DCHECK(!is_shutdown_);
48 embedded_worker_->AddProcessReference(provider_host->process_id());
49 }
50
51 void ServiceWorkerVersion::OnUnassociateProvider(
52 ServiceWorkerProviderHost* provider_host) {
53 embedded_worker_->ReleaseProcessReference(provider_host->process_id());
20 } 54 }
21 55
22 } // namespace content 56 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/service_worker/service_worker_version.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698