| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/shared_worker/shared_worker_service_impl.h" | 5 #include "content/browser/shared_worker/shared_worker_service_impl.h" |
| 6 | 6 |
| 7 #include "content/browser/shared_worker/shared_worker_host.h" | 7 #include "content/browser/shared_worker/shared_worker_host.h" |
| 8 #include "content/browser/shared_worker/shared_worker_instance.h" | 8 #include "content/browser/shared_worker/shared_worker_instance.h" |
| 9 #include "content/browser/shared_worker/shared_worker_message_filter.h" | 9 #include "content/browser/shared_worker/shared_worker_message_filter.h" |
| 10 #include "content/browser/worker_host/worker_document_set.h" | 10 #include "content/browser/worker_host/worker_document_set.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 SharedWorkerServiceImpl::~SharedWorkerServiceImpl() { | 26 SharedWorkerServiceImpl::~SharedWorkerServiceImpl() { |
| 27 } | 27 } |
| 28 | 28 |
| 29 bool SharedWorkerServiceImpl::TerminateWorker(int process_id, int route_id) { | 29 bool SharedWorkerServiceImpl::TerminateWorker(int process_id, int route_id) { |
| 30 // TODO(horo): implement this. | 30 // TODO(horo): implement this. |
| 31 return false; | 31 return false; |
| 32 } | 32 } |
| 33 | 33 |
| 34 std::vector<WorkerService::WorkerInfo> SharedWorkerServiceImpl::GetWorkers() { | 34 std::vector<WorkerService::WorkerInfo> SharedWorkerServiceImpl::GetWorkers() { |
| 35 // TODO(horo): implement this. | |
| 36 std::vector<WorkerService::WorkerInfo> results; | 35 std::vector<WorkerService::WorkerInfo> results; |
| 36 for (WorkerHostMap::const_iterator iter = worker_hosts_.begin(); |
| 37 iter != worker_hosts_.end(); |
| 38 ++iter) { |
| 39 SharedWorkerHost* host = iter->second; |
| 40 const SharedWorkerInstance* instance = host->instance(); |
| 41 if (instance) { |
| 42 WorkerService::WorkerInfo info; |
| 43 info.url = instance->url(); |
| 44 info.name = instance->name(); |
| 45 info.route_id = host->worker_route_id(); |
| 46 info.process_id = host->process_id(); |
| 47 info.handle = host->container_render_filter()->PeerHandle(); |
| 48 results.push_back(info); |
| 49 } |
| 50 } |
| 37 return results; | 51 return results; |
| 38 } | 52 } |
| 39 | 53 |
| 40 void SharedWorkerServiceImpl::AddObserver(WorkerServiceObserver* observer) { | 54 void SharedWorkerServiceImpl::AddObserver(WorkerServiceObserver* observer) { |
| 41 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 55 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 42 observers_.AddObserver(observer); | 56 observers_.AddObserver(observer); |
| 43 } | 57 } |
| 44 | 58 |
| 45 void SharedWorkerServiceImpl::RemoveObserver(WorkerServiceObserver* observer) { | 59 void SharedWorkerServiceImpl::RemoveObserver(WorkerServiceObserver* observer) { |
| 46 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 60 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 iter != worker_hosts_.end(); | 243 iter != worker_hosts_.end(); |
| 230 ++iter) { | 244 ++iter) { |
| 231 SharedWorkerInstance* instance = iter->second->instance(); | 245 SharedWorkerInstance* instance = iter->second->instance(); |
| 232 if (instance && instance->Matches(url, name, partition, resource_context)) | 246 if (instance && instance->Matches(url, name, partition, resource_context)) |
| 233 return instance; | 247 return instance; |
| 234 } | 248 } |
| 235 return NULL; | 249 return NULL; |
| 236 } | 250 } |
| 237 | 251 |
| 238 } // namespace content | 252 } // namespace content |
| OLD | NEW |