OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc
e-loading | 5 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc
e-loading |
6 | 6 |
7 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" | 7 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 URLRequest* request, | 152 URLRequest* request, |
153 ResourceFunction function, | 153 ResourceFunction function, |
154 ResourceRequestDetails* details) | 154 ResourceRequestDetails* details) |
155 : render_process_host_id_(-1), | 155 : render_process_host_id_(-1), |
156 render_view_host_id_(-1), | 156 render_view_host_id_(-1), |
157 function_(function), | 157 function_(function), |
158 details_(details) { | 158 details_(details) { |
159 if (!ResourceDispatcherHost::RenderViewForRequest(request, | 159 if (!ResourceDispatcherHost::RenderViewForRequest(request, |
160 &render_process_host_id_, | 160 &render_process_host_id_, |
161 &render_view_host_id_)) { | 161 &render_view_host_id_)) { |
162 NOTREACHED(); | 162 // Issue a warning here - this can happen during normal operation (for |
| 163 // example, if a worker exits while a network operation is pending), but |
| 164 // it should be fairly rare. |
| 165 DLOG(WARNING) << "Trying to deliver a message to a RenderViewHost" << |
| 166 " that has already exited or has never existed."; |
163 } | 167 } |
164 } | 168 } |
165 | 169 |
166 virtual void Run() { | 170 virtual void Run() { |
167 RenderViewHost* rvh = RenderViewHost::FromID(render_process_host_id_, | 171 RenderViewHost* rvh = RenderViewHost::FromID(render_process_host_id_, |
168 render_view_host_id_); | 172 render_view_host_id_); |
169 if (rvh) { | 173 if (rvh) { |
170 RenderViewHostDelegate::Resource* resource_delegate = | 174 RenderViewHostDelegate::Resource* resource_delegate = |
171 rvh->delegate()->GetResourceDelegate(); | 175 rvh->delegate()->GetResourceDelegate(); |
172 if (resource_delegate) | 176 if (resource_delegate) |
(...skipping 1271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1444 | 1448 |
1445 // If the request is from the worker process, find a tab that owns the worker. | 1449 // If the request is from the worker process, find a tab that owns the worker. |
1446 if (info->process_type() == ChildProcessInfo::WORKER_PROCESS) { | 1450 if (info->process_type() == ChildProcessInfo::WORKER_PROCESS) { |
1447 const WorkerProcessHost::WorkerInstance* worker_instance = | 1451 const WorkerProcessHost::WorkerInstance* worker_instance = |
1448 WorkerService::GetInstance()->FindWorkerInstance(info->child_id()); | 1452 WorkerService::GetInstance()->FindWorkerInstance(info->child_id()); |
1449 if (!worker_instance) { | 1453 if (!worker_instance) { |
1450 *render_process_host_id = -1; | 1454 *render_process_host_id = -1; |
1451 *render_view_host_id = -1; | 1455 *render_view_host_id = -1; |
1452 return false; | 1456 return false; |
1453 } | 1457 } |
1454 *render_process_host_id = worker_instance->renderer_id(); | 1458 DCHECK(!worker_instance->worker_document_set()->IsEmpty()); |
1455 *render_view_host_id = worker_instance->render_view_route_id(); | 1459 const WorkerDocumentSet::DocumentInfoSet& parents = |
| 1460 worker_instance->worker_document_set()->documents(); |
| 1461 // Need to display some related UI for this network request - pick an |
| 1462 // arbitrary parent to do so. |
| 1463 *render_process_host_id = parents.begin()->renderer_id(); |
| 1464 *render_view_host_id = parents.begin()->render_view_route_id(); |
1456 } else { | 1465 } else { |
1457 *render_process_host_id = info->child_id(); | 1466 *render_process_host_id = info->child_id(); |
1458 *render_view_host_id = info->route_id(); | 1467 *render_view_host_id = info->route_id(); |
1459 } | 1468 } |
1460 return true; | 1469 return true; |
1461 } | 1470 } |
1462 | 1471 |
1463 void ResourceDispatcherHost::AddObserver(Observer* obs) { | 1472 void ResourceDispatcherHost::AddObserver(Observer* obs) { |
1464 observer_list_.AddObserver(obs); | 1473 observer_list_.AddObserver(obs); |
1465 } | 1474 } |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1755 case ViewHostMsg_UploadProgress_ACK::ID: | 1764 case ViewHostMsg_UploadProgress_ACK::ID: |
1756 case ViewHostMsg_SyncLoad::ID: | 1765 case ViewHostMsg_SyncLoad::ID: |
1757 return true; | 1766 return true; |
1758 | 1767 |
1759 default: | 1768 default: |
1760 break; | 1769 break; |
1761 } | 1770 } |
1762 | 1771 |
1763 return false; | 1772 return false; |
1764 } | 1773 } |
OLD | NEW |