| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 void EmbeddedWorkerRegistry::OnSendMessageToBrowser( | 72 void EmbeddedWorkerRegistry::OnSendMessageToBrowser( |
| 73 int embedded_worker_id, int request_id, const IPC::Message& message) { | 73 int embedded_worker_id, int request_id, const IPC::Message& message) { |
| 74 WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); | 74 WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); |
| 75 if (found == worker_map_.end()) { | 75 if (found == worker_map_.end()) { |
| 76 LOG(ERROR) << "Worker " << embedded_worker_id << " not registered"; | 76 LOG(ERROR) << "Worker " << embedded_worker_id << " not registered"; |
| 77 return; | 77 return; |
| 78 } | 78 } |
| 79 // Perform security check to filter out any unexpected (and non-test) | 79 // Perform security check to filter out any unexpected (and non-test) |
| 80 // messages. This must list up all message types that can go through here. | 80 // messages. This must list up all message types that can go through here. |
| 81 if (message.type() == ServiceWorkerHostMsg_InstallEventFinished::ID || | 81 if (message.type() == ServiceWorkerHostMsg_InstallEventFinished::ID || |
| 82 message.type() == ServiceWorkerHostMsg_FetchEventFinished::ID || |
| 82 IPC_MESSAGE_CLASS(message) == TestMsgStart) { | 83 IPC_MESSAGE_CLASS(message) == TestMsgStart) { |
| 83 found->second->OnMessageReceived(request_id, message); | 84 found->second->OnMessageReceived(request_id, message); |
| 84 return; | 85 return; |
| 85 } | 86 } |
| 86 NOTREACHED() << "Got unexpected message: " << message.type(); | 87 NOTREACHED() << "Got unexpected message: " << message.type(); |
| 87 } | 88 } |
| 88 | 89 |
| 89 void EmbeddedWorkerRegistry::AddChildProcessSender( | 90 void EmbeddedWorkerRegistry::AddChildProcessSender( |
| 90 int process_id, IPC::Sender* sender) { | 91 int process_id, IPC::Sender* sender) { |
| 91 process_sender_map_[process_id] = sender; | 92 process_sender_map_[process_id] = sender; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 } | 133 } |
| 133 | 134 |
| 134 void EmbeddedWorkerRegistry::RemoveWorker(int process_id, | 135 void EmbeddedWorkerRegistry::RemoveWorker(int process_id, |
| 135 int embedded_worker_id) { | 136 int embedded_worker_id) { |
| 136 DCHECK(ContainsKey(worker_map_, embedded_worker_id)); | 137 DCHECK(ContainsKey(worker_map_, embedded_worker_id)); |
| 137 worker_map_.erase(embedded_worker_id); | 138 worker_map_.erase(embedded_worker_id); |
| 138 worker_process_map_.erase(process_id); | 139 worker_process_map_.erase(process_id); |
| 139 } | 140 } |
| 140 | 141 |
| 141 } // namespace content | 142 } // namespace content |
| OLD | NEW |