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

Unified Diff: content/browser/shared_worker/shared_worker_service_impl.cc

Issue 182693002: Implement some mothods in SharedWorkerHost and SharedWorkerServiceImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 10 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/shared_worker/shared_worker_service_impl.cc
diff --git a/content/browser/shared_worker/shared_worker_service_impl.cc b/content/browser/shared_worker/shared_worker_service_impl.cc
index 12c3ebbfe54696ecdc390533f7810802357f81db..f87d7cfc12754129e5b137e1e0472108a7de8000 100644
--- a/content/browser/shared_worker/shared_worker_service_impl.cc
+++ b/content/browser/shared_worker/shared_worker_service_impl.cc
@@ -104,51 +104,85 @@ void SharedWorkerServiceImpl::CreateWorker(
void SharedWorkerServiceImpl::ForwardToWorker(
const IPC::Message& message,
SharedWorkerMessageFilter* filter) {
- // TODO(horo): implement this.
- NOTIMPLEMENTED();
+ for (ScopedVector<SharedWorkerHost>::const_iterator iter =
+ worker_hosts_.begin();
+ iter != worker_hosts_.end();
+ ++iter) {
+ if ((*iter)->FilterMessage(message, filter))
+ return;
+ }
}
void SharedWorkerServiceImpl::DocumentDetached(
unsigned long long document_id,
SharedWorkerMessageFilter* filter) {
- // TODO(horo): implement this.
- NOTIMPLEMENTED();
+ for (ScopedVector<SharedWorkerHost>::const_iterator iter =
+ worker_hosts_.begin();
+ iter != worker_hosts_.end();
+ ++iter) {
+ (*iter)->DocumentDetached(filter, document_id);
+ }
}
void SharedWorkerServiceImpl::WorkerContextClosed(
int worker_route_id,
SharedWorkerMessageFilter* filter) {
- // TODO(horo): implement this.
- NOTIMPLEMENTED();
+ if (SharedWorkerHost* host = FindSharedWorkerHost(filter, worker_route_id)) {
+ host->WorkerContextClosed();
+ }
kinuko 2014/02/27 11:34:44 nit: no need of { } for one-line (unless you're wr
horo 2014/02/28 04:59:14 Done.
}
void SharedWorkerServiceImpl::WorkerContextDestroyed(
int worker_route_id,
SharedWorkerMessageFilter* filter) {
- // TODO(horo): implement this.
- NOTIMPLEMENTED();
+ SharedWorkerHost* host = FindSharedWorkerHost(filter, worker_route_id);
+ if (!host)
+ return;
+ host->WorkerContextDestroyed();
+ for (ScopedVector<SharedWorkerHost>::iterator iter =
+ worker_hosts_.begin();
+ iter != worker_hosts_.end();) {
+ if (*iter == host) {
+ iter = worker_hosts_.erase(iter);
+ } else {
+ ++iter;
+ }
+ }
}
void SharedWorkerServiceImpl::WorkerScriptLoaded(
int worker_route_id,
SharedWorkerMessageFilter* filter) {
- // TODO(horo): implement this.
- NOTIMPLEMENTED();
+ if (SharedWorkerHost* host = FindSharedWorkerHost(filter, worker_route_id)) {
+ host->WorkerScriptLoaded();
+ }
}
void SharedWorkerServiceImpl::WorkerScriptLoadFailed(
int worker_route_id,
SharedWorkerMessageFilter* filter) {
- // TODO(horo): implement this.
- NOTIMPLEMENTED();
+ SharedWorkerHost* host = FindSharedWorkerHost(filter, worker_route_id);
+ if (!host)
+ return;
+ host->WorkerScriptLoadFailed();
+ for (ScopedVector<SharedWorkerHost>::iterator iter =
+ worker_hosts_.begin();
+ iter != worker_hosts_.end();) {
+ if (*iter == host) {
+ iter = worker_hosts_.erase(iter);
+ } else {
+ ++iter;
+ }
+ }
}
void SharedWorkerServiceImpl::WorkerConnected(
int message_port_id,
int worker_route_id,
SharedWorkerMessageFilter* filter) {
- // TODO(horo): implement this.
- NOTIMPLEMENTED();
+ if (SharedWorkerHost* host = FindSharedWorkerHost(filter, worker_route_id)) {
+ host->WorkerConnected(message_port_id);
+ }
}
void SharedWorkerServiceImpl::AllowDatabase(
@@ -159,8 +193,9 @@ void SharedWorkerServiceImpl::AllowDatabase(
unsigned long estimated_size,
bool* result,
SharedWorkerMessageFilter* filter) {
- // TODO(horo): implement this.
- NOTIMPLEMENTED();
+ if (SharedWorkerHost* host = FindSharedWorkerHost(filter, worker_route_id)) {
+ host->AllowDatabase(url, name, display_name, estimated_size, result);
+ }
}
void SharedWorkerServiceImpl::AllowFileSystem(
@@ -168,8 +203,9 @@ void SharedWorkerServiceImpl::AllowFileSystem(
const GURL& url,
bool* result,
SharedWorkerMessageFilter* filter) {
- // TODO(horo): implement this.
- NOTIMPLEMENTED();
+ if (SharedWorkerHost* host = FindSharedWorkerHost(filter, worker_route_id)) {
+ host->AllowFileSystem(url, result);
+ }
}
void SharedWorkerServiceImpl::AllowIndexedDB(
@@ -178,14 +214,39 @@ void SharedWorkerServiceImpl::AllowIndexedDB(
const base::string16& name,
bool* result,
SharedWorkerMessageFilter* filter) {
- // TODO(horo): implement this.
- NOTIMPLEMENTED();
+ if (SharedWorkerHost* host = FindSharedWorkerHost(filter, worker_route_id)) {
+ host->AllowIndexedDB(url, name, result);
+ }
}
void SharedWorkerServiceImpl::OnSharedWorkerMessageFilterClosing(
SharedWorkerMessageFilter* filter) {
- // TODO(horo): implement this.
- NOTIMPLEMENTED();
+ for (ScopedVector<SharedWorkerHost>::iterator iter =
+ worker_hosts_.begin();
+ iter != worker_hosts_.end();) {
+ (*iter)->FilterShutdown(filter);
+ if ((*iter)->parent_render_filter() == filter) {
+ iter = worker_hosts_.erase(iter);
+ } else {
+ ++iter;
+ }
+ }
+}
+
+SharedWorkerHost* SharedWorkerServiceImpl::FindSharedWorkerHost(
+ SharedWorkerMessageFilter* filter,
+ int worker_route_id) {
+ for (ScopedVector<SharedWorkerHost>::iterator iter =
+ worker_hosts_.begin();
+ iter != worker_hosts_.end();
+ ++iter) {
+ if ((*iter)->parent_render_filter() == filter &&
+ (*iter)->instance() &&
+ (*iter)->worker_route_id() == worker_route_id) {
+ return *iter;
+ }
+ }
kinuko 2014/02/27 11:34:44 Since we often call this (and also sometimes walk
horo 2014/02/28 04:59:14 Changed to use base::ScopedPtrHashMap with <Proces
+ return NULL;
}
SharedWorkerInstance* SharedWorkerServiceImpl::FindSharedWorkerInstance(

Powered by Google App Engine
This is Rietveld 408576698