| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 // Represents the browser side of the browser <--> renderer communication | 5 // Represents the browser side of the browser <--> renderer communication |
| 6 // channel. There will be one RenderProcessHost per renderer process. | 6 // channel. There will be one RenderProcessHost per renderer process. |
| 7 | 7 |
| 8 #include "chrome/browser/render_process_host.h" | 8 #include "chrome/browser/render_process_host.h" |
| 9 | 9 |
| 10 #include <windows.h> | 10 #include <windows.h> |
| 11 #include <wininet.h> | 11 #include <wininet.h> |
| 12 #include <algorithm> | 12 #include <algorithm> |
| 13 #include <sstream> | 13 #include <sstream> |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "base/command_line.h" | 16 #include "base/command_line.h" |
| 17 #include "base/debug_util.h" | 17 #include "base/debug_util.h" |
| 18 #include "base/file_util.h" | 18 #include "base/file_util.h" |
| 19 #include "base/logging.h" | 19 #include "base/logging.h" |
| 20 #include "base/path_service.h" | 20 #include "base/path_service.h" |
| 21 #include "base/process_util.h" | 21 #include "base/process_util.h" |
| 22 #include "base/rand_util.h" |
| 22 #include "base/shared_event.h" | 23 #include "base/shared_event.h" |
| 23 #include "base/shared_memory.h" | 24 #include "base/shared_memory.h" |
| 24 #include "base/string_util.h" | 25 #include "base/string_util.h" |
| 25 #include "base/sys_info.h" | 26 #include "base/sys_info.h" |
| 26 #include "base/thread.h" | 27 #include "base/thread.h" |
| 27 #include "base/win_util.h" | 28 #include "base/win_util.h" |
| 28 #include "chrome/app/result_codes.h" | 29 #include "chrome/app/result_codes.h" |
| 29 #include "chrome/browser/browser.h" | 30 #include "chrome/browser/browser.h" |
| 30 #include "chrome/browser/browser_process.h" | 31 #include "chrome/browser/browser_process.h" |
| 31 #include "chrome/browser/cache_manager_host.h" | 32 #include "chrome/browser/cache_manager_host.h" |
| 32 #include "chrome/browser/history/history.h" | 33 #include "chrome/browser/history/history.h" |
| 33 #include "chrome/browser/plugin_service.h" | 34 #include "chrome/browser/plugin_service.h" |
| 34 #include "chrome/browser/render_widget_helper.h" | 35 #include "chrome/browser/render_widget_helper.h" |
| 35 #include "chrome/browser/render_view_host.h" | 36 #include "chrome/browser/render_view_host.h" |
| 36 #include "chrome/browser/renderer_security_policy.h" | 37 #include "chrome/browser/renderer_security_policy.h" |
| 37 #include "chrome/browser/resource_message_filter.h" | 38 #include "chrome/browser/resource_message_filter.h" |
| 38 #include "chrome/browser/sandbox_policy.h" | 39 #include "chrome/browser/sandbox_policy.h" |
| 39 #include "chrome/browser/spellchecker.h" | 40 #include "chrome/browser/spellchecker.h" |
| 40 #include "chrome/browser/visitedlink_master.h" | 41 #include "chrome/browser/visitedlink_master.h" |
| 41 #include "chrome/browser/web_contents.h" | 42 #include "chrome/browser/web_contents.h" |
| 42 #include "chrome/common/chrome_constants.h" | 43 #include "chrome/common/chrome_constants.h" |
| 43 #include "chrome/common/chrome_paths.h" | 44 #include "chrome/common/chrome_paths.h" |
| 44 #include "chrome/common/chrome_switches.h" | 45 #include "chrome/common/chrome_switches.h" |
| 45 #include "chrome/common/debug_flags.h" | 46 #include "chrome/common/debug_flags.h" |
| 46 #include "chrome/common/env_util.h" | |
| 47 #include "chrome/common/l10n_util.h" | 47 #include "chrome/common/l10n_util.h" |
| 48 #include "chrome/common/logging_chrome.h" | 48 #include "chrome/common/logging_chrome.h" |
| 49 #include "chrome/common/pref_names.h" | 49 #include "chrome/common/pref_names.h" |
| 50 #include "chrome/common/pref_service.h" | 50 #include "chrome/common/pref_service.h" |
| 51 #include "chrome/common/process_watcher.h" | 51 #include "chrome/common/process_watcher.h" |
| 52 #include "chrome/common/win_util.h" | 52 #include "chrome/common/win_util.h" |
| 53 #include "chrome/renderer/render_process.h" | 53 #include "chrome/renderer/render_process.h" |
| 54 #include "net/base/cookie_monster.h" | 54 #include "net/base/cookie_monster.h" |
| 55 #include "net/base/net_util.h" | 55 #include "net/base/net_util.h" |
| 56 #include "sandbox/src/sandbox.h" | 56 #include "sandbox/src/sandbox.h" |
| (...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 | 667 |
| 668 for (IDMap<RenderProcessHost>::const_iterator iter = all_hosts.begin(); | 668 for (IDMap<RenderProcessHost>::const_iterator iter = all_hosts.begin(); |
| 669 iter != all_hosts.end(); ++iter) { | 669 iter != all_hosts.end(); ++iter) { |
| 670 if (IsSuitableHost(profile, iter->second)) | 670 if (IsSuitableHost(profile, iter->second)) |
| 671 suitable_renderers.push_back(iter->second); | 671 suitable_renderers.push_back(iter->second); |
| 672 } | 672 } |
| 673 | 673 |
| 674 // Now pick a random suitable renderer, if we have any | 674 // Now pick a random suitable renderer, if we have any |
| 675 if (!suitable_renderers.empty()) { | 675 if (!suitable_renderers.empty()) { |
| 676 int suitable_count = static_cast<int>(suitable_renderers.size()); | 676 int suitable_count = static_cast<int>(suitable_renderers.size()); |
| 677 int random_index = rand_util::RandInt(0, suitable_count - 1); | 677 int random_index = base::RandInt(0, suitable_count - 1); |
| 678 return suitable_renderers[random_index]; | 678 return suitable_renderers[random_index]; |
| 679 } | 679 } |
| 680 | 680 |
| 681 return NULL; | 681 return NULL; |
| 682 } | 682 } |
| 683 | 683 |
| 684 void RenderProcessHost::SetBackgrounded(bool backgrounded) { | 684 void RenderProcessHost::SetBackgrounded(bool backgrounded) { |
| 685 // If the process_ is NULL, the process hasn't been created yet. | 685 // If the process_ is NULL, the process hasn't been created yet. |
| 686 if (process_.handle()) { | 686 if (process_.handle()) { |
| 687 process_.SetProcessBackgrounded(backgrounded); | 687 process_.SetProcessBackgrounded(backgrounded); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 766 // NOTE: Sometimes it's necessary to create more render processes than | 766 // NOTE: Sometimes it's necessary to create more render processes than |
| 767 // GetMaxRendererProcessCount(), for instance when we want to create | 767 // GetMaxRendererProcessCount(), for instance when we want to create |
| 768 // a renderer process for a profile that has no existing renderers. | 768 // a renderer process for a profile that has no existing renderers. |
| 769 // This is OK in moderation, since the GetMaxRendererProcessCount() | 769 // This is OK in moderation, since the GetMaxRendererProcessCount() |
| 770 // is conservative. | 770 // is conservative. |
| 771 | 771 |
| 772 return run_renderer_in_process() || | 772 return run_renderer_in_process() || |
| 773 (renderer_process_count >= GetMaxRendererProcessCount()); | 773 (renderer_process_count >= GetMaxRendererProcessCount()); |
| 774 } | 774 } |
| 775 | 775 |
| OLD | NEW |