| 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> |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 | 160 |
| 161 CacheManagerHost::GetInstance()->Add(host_id_); | 161 CacheManagerHost::GetInstance()->Add(host_id_); |
| 162 RendererSecurityPolicy::GetInstance()->Add(host_id_); | 162 RendererSecurityPolicy::GetInstance()->Add(host_id_); |
| 163 | 163 |
| 164 PrefService* prefs = profile->GetPrefs(); | 164 PrefService* prefs = profile->GetPrefs(); |
| 165 prefs->AddPrefObserver(prefs::kBlockPopups, this); | 165 prefs->AddPrefObserver(prefs::kBlockPopups, this); |
| 166 widget_helper_->set_block_popups( | 166 widget_helper_->set_block_popups( |
| 167 profile->GetPrefs()->GetBoolean(prefs::kBlockPopups)); | 167 profile->GetPrefs()->GetBoolean(prefs::kBlockPopups)); |
| 168 | 168 |
| 169 NotificationService::current()->AddObserver(this, | 169 NotificationService::current()->AddObserver(this, |
| 170 NOTIFY_NEW_USER_SCRIPTS, | 170 NOTIFY_GREASEMONKEY_SCRIPTS_LOADED, |
| 171 NotificationService::AllSources()); | 171 NotificationService::AllSources()); |
| 172 | 172 |
| 173 // Note: When we create the RenderProcessHost, it's technically backgrounded, | 173 // Note: When we create the RenderProcessHost, it's technically backgrounded, |
| 174 // because it has no visible listeners. But the process doesn't | 174 // because it has no visible listeners. But the process doesn't |
| 175 // actually exist yet, so we'll Background it later, after creation. | 175 // actually exist yet, so we'll Background it later, after creation. |
| 176 } | 176 } |
| 177 | 177 |
| 178 RenderProcessHost::~RenderProcessHost() { | 178 RenderProcessHost::~RenderProcessHost() { |
| 179 // Some tests hold RenderProcessHost in a scoped_ptr, so we must call | 179 // Some tests hold RenderProcessHost in a scoped_ptr, so we must call |
| 180 // Unregister here as well as in response to Release(). | 180 // Unregister here as well as in response to Release(). |
| 181 Unregister(); | 181 Unregister(); |
| 182 | 182 |
| 183 // We may have some unsent messages at this point, but that's OK. | 183 // We may have some unsent messages at this point, but that's OK. |
| 184 channel_.reset(); | 184 channel_.reset(); |
| 185 | 185 |
| 186 if (process_.handle() && !run_renderer_in_process_) { | 186 if (process_.handle() && !run_renderer_in_process_) { |
| 187 watcher_.StopWatching(); | 187 watcher_.StopWatching(); |
| 188 ProcessWatcher::EnsureProcessTerminated(process_.handle()); | 188 ProcessWatcher::EnsureProcessTerminated(process_.handle()); |
| 189 } | 189 } |
| 190 | 190 |
| 191 profile_->GetPrefs()->RemovePrefObserver(prefs::kBlockPopups, this); | 191 profile_->GetPrefs()->RemovePrefObserver(prefs::kBlockPopups, this); |
| 192 | 192 |
| 193 NotificationService::current()->RemoveObserver(this, | 193 NotificationService::current()->RemoveObserver(this, |
| 194 NOTIFY_NEW_USER_SCRIPTS, | 194 NOTIFY_GREASEMONKEY_SCRIPTS_LOADED, |
| 195 NotificationService::AllSources()); | 195 NotificationService::AllSources()); |
| 196 } | 196 } |
| 197 | 197 |
| 198 void RenderProcessHost::Unregister() { | 198 void RenderProcessHost::Unregister() { |
| 199 if (host_id_ >= 0) { | 199 if (host_id_ >= 0) { |
| 200 CacheManagerHost::GetInstance()->Remove(host_id_); | 200 CacheManagerHost::GetInstance()->Remove(host_id_); |
| 201 RendererSecurityPolicy::GetInstance()->Remove(host_id_); | 201 RendererSecurityPolicy::GetInstance()->Remove(host_id_); |
| 202 all_hosts.Remove(host_id_); | 202 all_hosts.Remove(host_id_); |
| 203 host_id_ = -1; | 203 host_id_ = -1; |
| 204 } | 204 } |
| (...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 std::wstring* pref_name_in = Details<std::wstring>(details).ptr(); | 812 std::wstring* pref_name_in = Details<std::wstring>(details).ptr(); |
| 813 DCHECK(Source<PrefService>(source).ptr() == profile()->GetPrefs()); | 813 DCHECK(Source<PrefService>(source).ptr() == profile()->GetPrefs()); |
| 814 if (*pref_name_in == prefs::kBlockPopups) { | 814 if (*pref_name_in == prefs::kBlockPopups) { |
| 815 widget_helper_->set_block_popups( | 815 widget_helper_->set_block_popups( |
| 816 profile()->GetPrefs()->GetBoolean(prefs::kBlockPopups)); | 816 profile()->GetPrefs()->GetBoolean(prefs::kBlockPopups)); |
| 817 } else { | 817 } else { |
| 818 NOTREACHED() << "unexpected pref change notification" << *pref_name_in; | 818 NOTREACHED() << "unexpected pref change notification" << *pref_name_in; |
| 819 } | 819 } |
| 820 break; | 820 break; |
| 821 } | 821 } |
| 822 case NOTIFY_NEW_USER_SCRIPTS: { | 822 case NOTIFY_GREASEMONKEY_SCRIPTS_LOADED: { |
| 823 base::SharedMemory* shared_memory = | 823 base::SharedMemory* shared_memory = |
| 824 Details<base::SharedMemory>(details).ptr(); | 824 Details<base::SharedMemory>(details).ptr(); |
| 825 DCHECK(shared_memory); | 825 DCHECK(shared_memory); |
| 826 if (shared_memory) { | 826 if (shared_memory) { |
| 827 SendGreasemonkeyScriptsUpdate(shared_memory); | 827 SendGreasemonkeyScriptsUpdate(shared_memory); |
| 828 } | 828 } |
| 829 break; | 829 break; |
| 830 } | 830 } |
| 831 default: { | 831 default: { |
| 832 NOTREACHED(); | 832 NOTREACHED(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 843 // NOTE: Sometimes it's necessary to create more render processes than | 843 // NOTE: Sometimes it's necessary to create more render processes than |
| 844 // GetMaxRendererProcessCount(), for instance when we want to create | 844 // GetMaxRendererProcessCount(), for instance when we want to create |
| 845 // a renderer process for a profile that has no existing renderers. | 845 // a renderer process for a profile that has no existing renderers. |
| 846 // This is OK in moderation, since the GetMaxRendererProcessCount() | 846 // This is OK in moderation, since the GetMaxRendererProcessCount() |
| 847 // is conservative. | 847 // is conservative. |
| 848 | 848 |
| 849 return run_renderer_in_process() || | 849 return run_renderer_in_process() || |
| 850 (renderer_process_count >= GetMaxRendererProcessCount()); | 850 (renderer_process_count >= GetMaxRendererProcessCount()); |
| 851 } | 851 } |
| 852 | 852 |
| OLD | NEW |