Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: content/browser/service_worker/embedded_worker_registry.cc

Issue 140893002: Adding slightly clearer separation between SW and EmbeddedWorker (still incomplete) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698