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

Side by Side Diff: content/browser/shared_worker/shared_worker_host.cc

Issue 187553002: Tells the crash of SharedWorker to RenderViewHosts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/shared_worker/shared_worker_host.h" 5 #include "content/browser/shared_worker/shared_worker_host.h"
6 6
7 #include "content/browser/frame_host/render_frame_host_delegate.h"
8 #include "content/browser/frame_host/render_frame_host_impl.h"
7 #include "content/browser/message_port_service.h" 9 #include "content/browser/message_port_service.h"
8 #include "content/browser/shared_worker/shared_worker_instance.h" 10 #include "content/browser/shared_worker/shared_worker_instance.h"
9 #include "content/browser/shared_worker/shared_worker_message_filter.h" 11 #include "content/browser/shared_worker/shared_worker_message_filter.h"
10 #include "content/common/view_messages.h" 12 #include "content/common/view_messages.h"
11 #include "content/common/worker_messages.h" 13 #include "content/common/worker_messages.h"
12 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
13 15
14 namespace content { 16 namespace content {
17 namespace {
18
19 // Notifies RenderViewHost that one or more worker objects crashed.
20 void WorkerCrashCallback(int render_process_unique_id, int render_frame_id) {
21 RenderFrameHostImpl* host =
22 RenderFrameHostImpl::FromID(render_process_unique_id, render_frame_id);
23 if (host)
24 host->delegate()->WorkerCrashed(host);
25 }
26
27 } // namespace
15 28
16 SharedWorkerHost::SharedWorkerHost(SharedWorkerInstance* instance) 29 SharedWorkerHost::SharedWorkerHost(SharedWorkerInstance* instance)
17 : instance_(instance), 30 : instance_(instance),
18 container_render_filter_(NULL), 31 container_render_filter_(NULL),
19 worker_route_id_(MSG_ROUTING_NONE) { 32 worker_route_id_(MSG_ROUTING_NONE) {
20 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 33 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
21 } 34 }
22 35
23 SharedWorkerHost::~SharedWorkerHost() { 36 SharedWorkerHost::~SharedWorkerHost() {
24 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 37 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
38 // If we crashed, tell the RenderViewHosts.
39 if (instance_ && !instance_->load_failed()) {
40 const WorkerDocumentSet::DocumentInfoSet& parents =
41 instance_->worker_document_set()->documents();
42 for (WorkerDocumentSet::DocumentInfoSet::const_iterator parent_iter =
43 parents.begin();
44 parent_iter != parents.end();
45 ++parent_iter) {
46 BrowserThread::PostTask(BrowserThread::UI,
47 FROM_HERE,
48 base::Bind(&WorkerCrashCallback,
49 parent_iter->render_process_id(),
50 parent_iter->render_frame_id()));
51 }
52 }
25 } 53 }
26 54
27 bool SharedWorkerHost::Send(IPC::Message* message) { 55 bool SharedWorkerHost::Send(IPC::Message* message) {
28 if (!container_render_filter_) { 56 if (!container_render_filter_) {
29 delete message; 57 delete message;
30 return false; 58 return false;
31 } 59 }
32 return container_render_filter_->Send(message); 60 return container_render_filter_->Send(message);
33 } 61 }
34 62
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 sent_message_port_id); 215 sent_message_port_id);
188 } else { 216 } else {
189 IPC::Message* new_message = new IPC::Message(message); 217 IPC::Message* new_message = new IPC::Message(message);
190 new_message->set_routing_id(worker_route_id_); 218 new_message->set_routing_id(worker_route_id_);
191 Send(new_message); 219 Send(new_message);
192 return; 220 return;
193 } 221 }
194 } 222 }
195 223
196 } // namespace content 224 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698