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

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

Issue 212593010: Implement the ServiceWorker "activate" event during activation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ready, set... Created 6 years, 8 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); 62 WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id);
63 if (found == worker_map_.end()) { 63 if (found == worker_map_.end()) {
64 LOG(ERROR) << "Worker " << embedded_worker_id << " not registered"; 64 LOG(ERROR) << "Worker " << embedded_worker_id << " not registered";
65 return; 65 return;
66 } 66 }
67 DCHECK_EQ(found->second->process_id(), process_id); 67 DCHECK_EQ(found->second->process_id(), process_id);
68 worker_process_map_[process_id].erase(embedded_worker_id); 68 worker_process_map_[process_id].erase(embedded_worker_id);
69 found->second->OnStopped(); 69 found->second->OnStopped();
70 } 70 }
71 71
72 void EmbeddedWorkerRegistry::OnSendMessageToBrowser( 72 void EmbeddedWorkerRegistry::OnSendMessageToBrowser(
jschuh 2014/03/28 21:27:29 This seems badly named. Where exactly are we runni
dominicc (has gone to gerrit) 2014/03/31 03:59:33 This method is named OnSendMessageToBrowser becaus
kinuko 2014/03/31 04:31:03 I agree it could be confusing, but so far we don't
jschuh 2014/03/31 13:36:15 Yeah, I'm not worried now that I understand what t
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_ActivateEventFinished::ID ||
jschuh 2014/03/28 21:27:29 Why are we filtering here? Shouldn't found->second
dominicc (has gone to gerrit) 2014/03/31 03:59:33 This class acts as a proxy routing messages to a w
jschuh 2014/03/31 13:36:15 Okay, I guess @tsepez and I disagree on the value
82 message.type() == ServiceWorkerHostMsg_InstallEventFinished::ID ||
82 message.type() == ServiceWorkerHostMsg_FetchEventFinished::ID || 83 message.type() == ServiceWorkerHostMsg_FetchEventFinished::ID ||
83 IPC_MESSAGE_CLASS(message) == TestMsgStart) { 84 IPC_MESSAGE_CLASS(message) == TestMsgStart) {
84 found->second->OnMessageReceived(request_id, message); 85 found->second->OnMessageReceived(request_id, message);
85 return; 86 return;
86 } 87 }
87 NOTREACHED() << "Got unexpected message: " << message.type(); 88 NOTREACHED() << "Got unexpected message: " << message.type();
88 } 89 }
89 90
90 void EmbeddedWorkerRegistry::AddChildProcessSender( 91 void EmbeddedWorkerRegistry::AddChildProcessSender(
91 int process_id, IPC::Sender* sender) { 92 int process_id, IPC::Sender* sender) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 } 134 }
134 135
135 void EmbeddedWorkerRegistry::RemoveWorker(int process_id, 136 void EmbeddedWorkerRegistry::RemoveWorker(int process_id,
136 int embedded_worker_id) { 137 int embedded_worker_id) {
137 DCHECK(ContainsKey(worker_map_, embedded_worker_id)); 138 DCHECK(ContainsKey(worker_map_, embedded_worker_id));
138 worker_map_.erase(embedded_worker_id); 139 worker_map_.erase(embedded_worker_id);
139 worker_process_map_.erase(process_id); 140 worker_process_map_.erase(process_id);
140 } 141 }
141 142
142 } // namespace content 143 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698