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

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

Issue 246183003: DevTools Support for ServiceWoker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 months 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
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/command_line.h" 7 #include "base/command_line.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "base/strings/string16.h" 9 #include "base/strings/string16.h"
10 #include "content/browser/service_worker/embedded_worker_instance.h" 10 #include "content/browser/service_worker/embedded_worker_instance.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 status_(NEW), 89 status_(NEW),
90 context_(context), 90 context_(context),
91 weak_factory_(this) { 91 weak_factory_(this) {
92 DCHECK(context_); 92 DCHECK(context_);
93 if (registration) { 93 if (registration) {
94 registration_id_ = registration->id(); 94 registration_id_ = registration->id();
95 script_url_ = registration->script_url(); 95 script_url_ = registration->script_url();
96 scope_ = registration->pattern(); 96 scope_ = registration->pattern();
97 } 97 }
98 context_->AddLiveVersion(this); 98 context_->AddLiveVersion(this);
99 embedded_worker_ = context_->embedded_worker_registry()->CreateWorker(); 99 embedded_worker_ = context_->embedded_worker_registry()->CreateWorker(scope_);
100 embedded_worker_->AddListener(this); 100 embedded_worker_->AddListener(this);
101 } 101 }
102 102
103 ServiceWorkerVersion::~ServiceWorkerVersion() { 103 ServiceWorkerVersion::~ServiceWorkerVersion() {
104 if (embedded_worker_) { 104 if (embedded_worker_) {
105 embedded_worker_->RemoveListener(this); 105 embedded_worker_->RemoveListener(this);
106 embedded_worker_.reset(); 106 embedded_worker_.reset();
107 } 107 }
108 if (context_) 108 if (context_)
109 context_->RemoveLiveVersion(version_id_); 109 context_->RemoveLiveVersion(version_id_);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 return; 153 return;
154 case STOPPING: 154 case STOPPING:
155 RunSoon(base::Bind(callback, SERVICE_WORKER_ERROR_START_WORKER_FAILED)); 155 RunSoon(base::Bind(callback, SERVICE_WORKER_ERROR_START_WORKER_FAILED));
156 return; 156 return;
157 case STOPPED: 157 case STOPPED:
158 case STARTING: 158 case STARTING:
159 start_callbacks_.push_back(callback); 159 start_callbacks_.push_back(callback);
160 if (running_status() == STOPPED) { 160 if (running_status() == STOPPED) {
161 embedded_worker_->Start( 161 embedded_worker_->Start(
162 version_id_, 162 version_id_,
163 scope_,
164 script_url_, 163 script_url_,
165 possible_process_ids, 164 possible_process_ids,
166 base::Bind(&ServiceWorkerVersion::RunStartWorkerCallbacksOnError, 165 base::Bind(&ServiceWorkerVersion::RunStartWorkerCallbacksOnError,
167 weak_factory_.GetWeakPtr())); 166 weak_factory_.GetWeakPtr()));
168 } 167 }
169 return; 168 return;
170 } 169 }
171 } 170 }
172 171
173 void ServiceWorkerVersion::StopWorker(const StatusCallback& callback) { 172 void ServiceWorkerVersion::StopWorker(const StatusCallback& callback) {
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 ServiceWorkerProviderHost* provider_host = 570 ServiceWorkerProviderHost* provider_host =
572 controllee_by_id_.Lookup(client_id); 571 controllee_by_id_.Lookup(client_id);
573 if (!provider_host) { 572 if (!provider_host) {
574 // The client may already have been closed, just ignore. 573 // The client may already have been closed, just ignore.
575 return; 574 return;
576 } 575 }
577 provider_host->PostMessage(message, sent_message_port_ids); 576 provider_host->PostMessage(message, sent_message_port_ids);
578 } 577 }
579 578
580 } // namespace content 579 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698