| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/service_worker/embedded_worker_registry.h" | 5 #include "content/browser/service_worker/embedded_worker_registry.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "content/browser/service_worker/embedded_worker_instance.h" | 8 #include "content/browser/service_worker/embedded_worker_instance.h" |
| 9 #include "content/browser/service_worker/service_worker_context_core.h" | 9 #include "content/browser/service_worker/service_worker_context_core.h" |
| 10 #include "content/common/service_worker/embedded_worker_messages.h" | 10 #include "content/common/service_worker/embedded_worker_messages.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); | 60 WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); |
| 61 if (found == worker_map_.end()) { | 61 if (found == worker_map_.end()) { |
| 62 LOG(ERROR) << "Worker " << embedded_worker_id << " not registered"; | 62 LOG(ERROR) << "Worker " << embedded_worker_id << " not registered"; |
| 63 return; | 63 return; |
| 64 } | 64 } |
| 65 DCHECK_EQ(found->second->process_id(), process_id); | 65 DCHECK_EQ(found->second->process_id(), process_id); |
| 66 worker_process_map_.erase(process_id); | 66 worker_process_map_.erase(process_id); |
| 67 found->second->OnStopped(); | 67 found->second->OnStopped(); |
| 68 } | 68 } |
| 69 | 69 |
| 70 void EmbeddedWorkerRegistry::OnSendMessageToBrowser( |
| 71 int embedded_worker_id, const IPC::Message& message) { |
| 72 WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); |
| 73 if (found == worker_map_.end()) { |
| 74 LOG(ERROR) << "Worker " << embedded_worker_id << " not registered"; |
| 75 return; |
| 76 } |
| 77 found->second->OnMessageReceived(message); |
| 78 } |
| 79 |
| 70 void EmbeddedWorkerRegistry::AddChildProcessSender( | 80 void EmbeddedWorkerRegistry::AddChildProcessSender( |
| 71 int process_id, IPC::Sender* sender) { | 81 int process_id, IPC::Sender* sender) { |
| 72 process_sender_map_[process_id] = sender; | 82 process_sender_map_[process_id] = sender; |
| 73 DCHECK(!ContainsKey(worker_process_map_, process_id)); | 83 DCHECK(!ContainsKey(worker_process_map_, process_id)); |
| 74 } | 84 } |
| 75 | 85 |
| 76 void EmbeddedWorkerRegistry::RemoveChildProcessSender(int process_id) { | 86 void EmbeddedWorkerRegistry::RemoveChildProcessSender(int process_id) { |
| 77 process_sender_map_.erase(process_id); | 87 process_sender_map_.erase(process_id); |
| 78 std::map<int, int>::iterator found = worker_process_map_.find(process_id); | 88 std::map<int, int>::iterator found = worker_process_map_.find(process_id); |
| 79 if (found != worker_process_map_.end()) { | 89 if (found != worker_process_map_.end()) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 96 } | 106 } |
| 97 | 107 |
| 98 void EmbeddedWorkerRegistry::RemoveWorker(int process_id, | 108 void EmbeddedWorkerRegistry::RemoveWorker(int process_id, |
| 99 int embedded_worker_id) { | 109 int embedded_worker_id) { |
| 100 DCHECK(ContainsKey(worker_map_, embedded_worker_id)); | 110 DCHECK(ContainsKey(worker_map_, embedded_worker_id)); |
| 101 worker_map_.erase(embedded_worker_id); | 111 worker_map_.erase(embedded_worker_id); |
| 102 worker_process_map_.erase(process_id); | 112 worker_process_map_.erase(process_id); |
| 103 } | 113 } |
| 104 | 114 |
| 105 } // namespace content | 115 } // namespace content |
| OLD | NEW |