| 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 // TODO(kinuko): Filter out unexpected messages here and uncomment below |
| 78 // when we actually define messages that are to be sent from child process |
| 79 // to the browser via this channel. (We don't have any yet) |
| 80 // found->second->OnMessageReceived(message); |
| 81 } |
| 82 |
| 70 void EmbeddedWorkerRegistry::AddChildProcessSender( | 83 void EmbeddedWorkerRegistry::AddChildProcessSender( |
| 71 int process_id, IPC::Sender* sender) { | 84 int process_id, IPC::Sender* sender) { |
| 72 process_sender_map_[process_id] = sender; | 85 process_sender_map_[process_id] = sender; |
| 73 DCHECK(!ContainsKey(worker_process_map_, process_id)); | 86 DCHECK(!ContainsKey(worker_process_map_, process_id)); |
| 74 } | 87 } |
| 75 | 88 |
| 76 void EmbeddedWorkerRegistry::RemoveChildProcessSender(int process_id) { | 89 void EmbeddedWorkerRegistry::RemoveChildProcessSender(int process_id) { |
| 77 process_sender_map_.erase(process_id); | 90 process_sender_map_.erase(process_id); |
| 78 std::map<int, int>::iterator found = worker_process_map_.find(process_id); | 91 std::map<int, int>::iterator found = worker_process_map_.find(process_id); |
| 79 if (found != worker_process_map_.end()) { | 92 if (found != worker_process_map_.end()) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 96 } | 109 } |
| 97 | 110 |
| 98 void EmbeddedWorkerRegistry::RemoveWorker(int process_id, | 111 void EmbeddedWorkerRegistry::RemoveWorker(int process_id, |
| 99 int embedded_worker_id) { | 112 int embedded_worker_id) { |
| 100 DCHECK(ContainsKey(worker_map_, embedded_worker_id)); | 113 DCHECK(ContainsKey(worker_map_, embedded_worker_id)); |
| 101 worker_map_.erase(embedded_worker_id); | 114 worker_map_.erase(embedded_worker_id); |
| 102 worker_process_map_.erase(process_id); | 115 worker_process_map_.erase(process_id); |
| 103 } | 116 } |
| 104 | 117 |
| 105 } // namespace content | 118 } // namespace content |
| OLD | NEW |