| 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/renderer_host/browser_render_process_host.h" | 8 #include "chrome/browser/renderer_host/browser_render_process_host.h" |
| 9 | 9 |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 826 } | 826 } |
| 827 | 827 |
| 828 void BrowserRenderProcessHost::OnUpdatedCacheStats( | 828 void BrowserRenderProcessHost::OnUpdatedCacheStats( |
| 829 const CacheManager::UsageStats& stats) { | 829 const CacheManager::UsageStats& stats) { |
| 830 CacheManagerHost::GetInstance()->ObserveStats(host_id(), stats); | 830 CacheManagerHost::GetInstance()->ObserveStats(host_id(), stats); |
| 831 } | 831 } |
| 832 | 832 |
| 833 void BrowserRenderProcessHost::SetBackgrounded(bool backgrounded) { | 833 void BrowserRenderProcessHost::SetBackgrounded(bool backgrounded) { |
| 834 // If the process_ is NULL, the process hasn't been created yet. | 834 // If the process_ is NULL, the process hasn't been created yet. |
| 835 if (process_.handle()) { | 835 if (process_.handle()) { |
| 836 bool rv = process_.SetProcessBackgrounded(backgrounded); | 836 bool should_set_backgrounded = true; |
| 837 if (!rv) { | 837 |
| 838 return; | 838 #if defined(OS_WIN) |
| 839 // The cbstext.dll loads as a global GetMessage hook in the browser process |
| 840 // and intercepts/unintercepts the kernel32 API SetPriorityClass in a |
| 841 // background thread. If the UI thread invokes this API just when it is |
| 842 // intercepted the stack is messed up on return from the interceptor |
| 843 // which causes random crashes in the browser process. Our hack for now |
| 844 // is to not invoke the SetPriorityClass API if the dll is loaded. |
| 845 should_set_backgrounded = (GetModuleHandle(L"cbstext.dll") == NULL); |
| 846 #endif // OS_WIN |
| 847 |
| 848 if (should_set_backgrounded) { |
| 849 bool rv = process_.SetProcessBackgrounded(backgrounded); |
| 850 if (!rv) { |
| 851 return; |
| 852 } |
| 839 } | 853 } |
| 840 | 854 |
| 841 // Now tune the memory footprint of the renderer. | 855 // Now tune the memory footprint of the renderer. |
| 842 // If the OS needs to page, we'd rather it page idle renderers. | 856 // If the OS needs to page, we'd rather it page idle renderers. |
| 843 BrowserProcess::MemoryModel model = g_browser_process->memory_model(); | 857 BrowserProcess::MemoryModel model = g_browser_process->memory_model(); |
| 844 if (model < BrowserProcess::HIGH_MEMORY_MODEL) { | 858 if (model < BrowserProcess::HIGH_MEMORY_MODEL) { |
| 845 if (backgrounded) { | 859 if (backgrounded) { |
| 846 if (model == BrowserProcess::LOW_MEMORY_MODEL) | 860 if (model == BrowserProcess::LOW_MEMORY_MODEL) |
| 847 process_.EmptyWorkingSet(); | 861 process_.EmptyWorkingSet(); |
| 848 else if (model == BrowserProcess::MEDIUM_MEMORY_MODEL) | 862 else if (model == BrowserProcess::MEDIUM_MEMORY_MODEL) |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 883 SendUserScriptsUpdate(shared_memory); | 897 SendUserScriptsUpdate(shared_memory); |
| 884 } | 898 } |
| 885 break; | 899 break; |
| 886 } | 900 } |
| 887 default: { | 901 default: { |
| 888 NOTREACHED(); | 902 NOTREACHED(); |
| 889 break; | 903 break; |
| 890 } | 904 } |
| 891 } | 905 } |
| 892 } | 906 } |
| OLD | NEW |