| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 1500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1511 int* render_view_host_id) { | 1511 int* render_view_host_id) { |
| 1512 const ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); | 1512 const ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); |
| 1513 if (!info) { | 1513 if (!info) { |
| 1514 *render_process_host_id = -1; | 1514 *render_process_host_id = -1; |
| 1515 *render_view_host_id = -1; | 1515 *render_view_host_id = -1; |
| 1516 return false; | 1516 return false; |
| 1517 } | 1517 } |
| 1518 | 1518 |
| 1519 // If the request is from the worker process, find a tab that owns the worker. | 1519 // If the request is from the worker process, find a tab that owns the worker. |
| 1520 if (info->process_type() == ChildProcessInfo::WORKER_PROCESS) { | 1520 if (info->process_type() == ChildProcessInfo::WORKER_PROCESS) { |
| 1521 const WorkerProcessHost::WorkerInstance* worker_instance = | 1521 // Need to display some related UI for this network request - pick an |
| 1522 WorkerService::GetInstance()->FindWorkerInstance(info->child_id()); | 1522 // arbitrary parent to do so. |
| 1523 if (!worker_instance) { | 1523 if (!WorkerService::GetInstance()->GetRendererForWorker( |
| 1524 info->child_id(), render_process_host_id, render_view_host_id)) { |
| 1524 *render_process_host_id = -1; | 1525 *render_process_host_id = -1; |
| 1525 *render_view_host_id = -1; | 1526 *render_view_host_id = -1; |
| 1526 return false; | 1527 return false; |
| 1527 } | 1528 } |
| 1528 DCHECK(!worker_instance->worker_document_set()->IsEmpty()); | |
| 1529 const WorkerDocumentSet::DocumentInfoSet& parents = | |
| 1530 worker_instance->worker_document_set()->documents(); | |
| 1531 // Need to display some related UI for this network request - pick an | |
| 1532 // arbitrary parent to do so. | |
| 1533 *render_process_host_id = parents.begin()->renderer_id(); | |
| 1534 *render_view_host_id = parents.begin()->render_view_route_id(); | |
| 1535 } else { | 1529 } else { |
| 1536 *render_process_host_id = info->child_id(); | 1530 *render_process_host_id = info->child_id(); |
| 1537 *render_view_host_id = info->route_id(); | 1531 *render_view_host_id = info->route_id(); |
| 1538 } | 1532 } |
| 1539 return true; | 1533 return true; |
| 1540 } | 1534 } |
| 1541 | 1535 |
| 1542 void ResourceDispatcherHost::AddObserver(Observer* obs) { | 1536 void ResourceDispatcherHost::AddObserver(Observer* obs) { |
| 1543 observer_list_.AddObserver(obs); | 1537 observer_list_.AddObserver(obs); |
| 1544 } | 1538 } |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1895 return is_prefetch_enabled_; | 1889 return is_prefetch_enabled_; |
| 1896 } | 1890 } |
| 1897 | 1891 |
| 1898 // static | 1892 // static |
| 1899 void ResourceDispatcherHost::set_is_prefetch_enabled(bool value) { | 1893 void ResourceDispatcherHost::set_is_prefetch_enabled(bool value) { |
| 1900 is_prefetch_enabled_ = value; | 1894 is_prefetch_enabled_ = value; |
| 1901 } | 1895 } |
| 1902 | 1896 |
| 1903 // static | 1897 // static |
| 1904 bool ResourceDispatcherHost::is_prefetch_enabled_ = false; | 1898 bool ResourceDispatcherHost::is_prefetch_enabled_ = false; |
| OLD | NEW |