| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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( | 70 void EmbeddedWorkerRegistry::OnSendMessageToBrowser( |
| 71 int embedded_worker_id, const IPC::Message& message) { | 71 int embedded_worker_id, int request_id, const IPC::Message& message) { |
| 72 WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); | 72 WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); |
| 73 if (found == worker_map_.end()) { | 73 if (found == worker_map_.end()) { |
| 74 LOG(ERROR) << "Worker " << embedded_worker_id << " not registered"; | 74 LOG(ERROR) << "Worker " << embedded_worker_id << " not registered"; |
| 75 return; | 75 return; |
| 76 } | 76 } |
| 77 // TODO(kinuko): Filter out unexpected messages here and uncomment below | 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 | 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) | 79 // to the browser via this channel. (We don't have any yet) |
| 80 // found->second->OnMessageReceived(message); | 80 found->second->OnMessageReceived(request_id, message); |
| 81 } | 81 } |
| 82 | 82 |
| 83 void EmbeddedWorkerRegistry::AddChildProcessSender( | 83 void EmbeddedWorkerRegistry::AddChildProcessSender( |
| 84 int process_id, IPC::Sender* sender) { | 84 int process_id, IPC::Sender* sender) { |
| 85 process_sender_map_[process_id] = sender; | 85 process_sender_map_[process_id] = sender; |
| 86 DCHECK(!ContainsKey(worker_process_map_, process_id)); | 86 DCHECK(!ContainsKey(worker_process_map_, process_id)); |
| 87 } | 87 } |
| 88 | 88 |
| 89 void EmbeddedWorkerRegistry::RemoveChildProcessSender(int process_id) { | 89 void EmbeddedWorkerRegistry::RemoveChildProcessSender(int process_id) { |
| 90 process_sender_map_.erase(process_id); | 90 process_sender_map_.erase(process_id); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 120 } | 120 } |
| 121 | 121 |
| 122 void EmbeddedWorkerRegistry::RemoveWorker(int process_id, | 122 void EmbeddedWorkerRegistry::RemoveWorker(int process_id, |
| 123 int embedded_worker_id) { | 123 int embedded_worker_id) { |
| 124 DCHECK(ContainsKey(worker_map_, embedded_worker_id)); | 124 DCHECK(ContainsKey(worker_map_, embedded_worker_id)); |
| 125 worker_map_.erase(embedded_worker_id); | 125 worker_map_.erase(embedded_worker_id); |
| 126 worker_process_map_.erase(process_id); | 126 worker_process_map_.erase(process_id); |
| 127 } | 127 } |
| 128 | 128 |
| 129 } // namespace content | 129 } // namespace content |
| OLD | NEW |