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

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: #include <vector> 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 e6a9004d8ab2397c8f4fcd28a96d16b1ba50ba12..03efcd16fdb9d4934b54d5d8b1e761e443f6f7ae 100644
--- a/content/browser/service_worker/service_worker_context_wrapper.cc
+++ b/content/browser/service_worker/service_worker_context_wrapper.cc
@@ -36,6 +36,7 @@ void ServiceWorkerContextWrapper::Init(
make_scoped_refptr(quota_manager_proxy)));
return;
}
+ observer_list_->AddObserver(this);
DCHECK(!context_core_);
context_core_.reset(new ServiceWorkerContextCore(
user_data_directory,
@@ -53,6 +54,7 @@ void ServiceWorkerContextWrapper::Shutdown() {
base::Bind(&ServiceWorkerContextWrapper::Shutdown, this));
return;
}
+ observer_list_->RemoveObserver(this);
// Breaks the reference cycle through ServiceWorkerProcessManager.
context_core_.reset();
}
@@ -127,6 +129,18 @@ void ServiceWorkerContextWrapper::UnregisterServiceWorker(
base::Bind(&FinishUnregistrationOnIO, continuation));
}
+void ServiceWorkerContextWrapper::AddStatusChangeObserver(
+ StatusChangeObserver* observer) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ status_change_observers_.AddObserver(observer);
+}
+
+void ServiceWorkerContextWrapper::RemoveStatusChangeObserver(
+ StatusChangeObserver* observer) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ status_change_observers_.RemoveObserver(observer);
+}
+
void ServiceWorkerContextWrapper::AddObserver(
ServiceWorkerContextObserver* observer) {
observer_list_->AddObserver(observer);
@@ -137,4 +151,40 @@ 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) {
+ NotifyStatusChangeObservers();
+}
+
+void ServiceWorkerContextWrapper::OnWorkerStopped(int64 version_id,
+ int process_id,
+ int thread_id) {
+ NotifyStatusChangeObservers();
+}
+
+void ServiceWorkerContextWrapper::OnVersionStateChanged(int64 version_id) {
michaeln 2014/05/05 21:01:15 does the devtools use case care about this one?
+ NotifyStatusChangeObservers();
+}
+
+void ServiceWorkerContextWrapper::NotifyStatusChangeObservers() {
+ if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
+ BrowserThread::PostTask(
+ BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(&ServiceWorkerContextWrapper::NotifyStatusChangeObservers,
+ this));
+ return;
+ }
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ FOR_EACH_OBSERVER(
+ StatusChangeObserver, status_change_observers_, OnStatusChanged());
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698