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

Unified Diff: content/browser/service_worker/service_worker_context_wrapper.cc

Issue 251653003: Introduces DevToolsManagerDelegate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/service_worker/service_worker_context_wrapper.cc
diff --git a/content/browser/service_worker/service_worker_context_wrapper.cc b/content/browser/service_worker/service_worker_context_wrapper.cc
index 8f6413428bd0e47072a09eaa577eeff79aa7bd45..bf7c0f2bad82fb26e150cbc3d0624ebdf8b14b6e 100644
--- a/content/browser/service_worker/service_worker_context_wrapper.cc
+++ b/content/browser/service_worker/service_worker_context_wrapper.cc
@@ -18,9 +18,11 @@ ServiceWorkerContextWrapper::ServiceWorkerContextWrapper(
: observer_list_(
new ObserverListThreadSafe<ServiceWorkerContextObserver>()),
browser_context_(browser_context) {
+ observer_list_->AddObserver(this);
michaeln 2014/05/01 02:52:07 this should always be called on the UI thread, we'
horo 2014/05/01 04:52:32 Done. Moved to Init().
}
ServiceWorkerContextWrapper::~ServiceWorkerContextWrapper() {
+ observer_list_->RemoveObserver(this);
michaeln 2014/05/01 02:52:07 does ObserverListThreadSafe require that an observ
horo 2014/05/01 04:52:32 Done. Moved to Shutdown().
}
void ServiceWorkerContextWrapper::Init(
@@ -130,6 +132,26 @@ void ServiceWorkerContextWrapper::UnregisterServiceWorker(
base::Bind(&FinishUnregistrationOnIO, continuation));
}
+void ServiceWorkerContextWrapper::AddStatusChangeCallback(
+ const base::Callback<void(void)>& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ return status_change_callbacks_.push_back(callback);
+}
+
+void ServiceWorkerContextWrapper::RemoveStatusChangeCallback(
+ const base::Callback<void(void)>& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ for (std::vector<base::Callback<void(void)> >::iterator it =
+ status_change_callbacks_.begin();
+ it != status_change_callbacks_.end();) {
+ if (it->Equals(callback)) {
+ it = status_change_callbacks_.erase(it);
+ } else {
+ ++it;
+ }
+ }
+}
+
void ServiceWorkerContextWrapper::AddObserver(
ServiceWorkerContextObserver* observer) {
observer_list_->AddObserver(observer);
@@ -140,4 +162,33 @@ void ServiceWorkerContextWrapper::RemoveObserver(
observer_list_->RemoveObserver(observer);
}
+void ServiceWorkerContextWrapper::GetRunningServiceWorkerInfo(
+ const GetRunningServiceWorkerInfoCallback& callback) {
+ // TODO(horo): Implement this.
+ NOTIMPLEMENTED();
+}
+
+void ServiceWorkerContextWrapper::OnWorkerStarted(int64 version_id,
+ int process_id,
+ int thread_id) {
+ CallStatusChangeCallback();
+}
+
+void ServiceWorkerContextWrapper::OnWorkerStopped(int64 version_id,
+ int process_id,
+ int thread_id) {
+ CallStatusChangeCallback();
+}
+
+void ServiceWorkerContextWrapper::OnVersionStateChanged(int64 version_id) {
+ CallStatusChangeCallback();
+}
+
+void ServiceWorkerContextWrapper::CallStatusChangeCallback() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ for (size_t i = 0; i < status_change_callbacks_.size(); ++i) {
+ status_change_callbacks_[i].Run();
+ }
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698