| 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" |
| 11 #include "content/common/view_messages.h" | 11 #include "content/common/view_messages.h" |
| 12 #include "content/common/worker_messages.h" | 12 #include "content/common/worker_messages.h" |
| 13 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
| 14 #include "content/public/browser/worker_service_observer.h" | 14 #include "content/public/browser/worker_service_observer.h" |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 | 17 |
| 18 SharedWorkerServiceImpl* SharedWorkerServiceImpl::GetInstance() { | 18 SharedWorkerServiceImpl* SharedWorkerServiceImpl::GetInstance() { |
| 19 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 19 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 20 return Singleton<SharedWorkerServiceImpl>::get(); | 20 return Singleton<SharedWorkerServiceImpl>::get(); |
| 21 } | 21 } |
| 22 | 22 |
| 23 SharedWorkerServiceImpl::SharedWorkerServiceImpl() { | 23 SharedWorkerServiceImpl::SharedWorkerServiceImpl() { |
| 24 } | 24 } |
| 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 SharedWorkerHost* host = |
| 31 return false; | 31 worker_hosts_.get(std::make_pair(process_id, route_id)); |
| 32 if (!host || !host->instance()) |
| 33 return false; |
| 34 host->TerminateWorker(); |
| 35 return true; |
| 32 } | 36 } |
| 33 | 37 |
| 34 std::vector<WorkerService::WorkerInfo> SharedWorkerServiceImpl::GetWorkers() { | 38 std::vector<WorkerService::WorkerInfo> SharedWorkerServiceImpl::GetWorkers() { |
| 35 // TODO(horo): implement this. | 39 // TODO(horo): implement this. |
| 36 std::vector<WorkerService::WorkerInfo> results; | 40 std::vector<WorkerService::WorkerInfo> results; |
| 37 return results; | 41 return results; |
| 38 } | 42 } |
| 39 | 43 |
| 40 void SharedWorkerServiceImpl::AddObserver(WorkerServiceObserver* observer) { | 44 void SharedWorkerServiceImpl::AddObserver(WorkerServiceObserver* observer) { |
| 41 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 45 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 iter != worker_hosts_.end(); | 233 iter != worker_hosts_.end(); |
| 230 ++iter) { | 234 ++iter) { |
| 231 SharedWorkerInstance* instance = iter->second->instance(); | 235 SharedWorkerInstance* instance = iter->second->instance(); |
| 232 if (instance && instance->Matches(url, name, partition, resource_context)) | 236 if (instance && instance->Matches(url, name, partition, resource_context)) |
| 233 return instance; | 237 return instance; |
| 234 } | 238 } |
| 235 return NULL; | 239 return NULL; |
| 236 } | 240 } |
| 237 | 241 |
| 238 } // namespace content | 242 } // namespace content |
| OLD | NEW |