OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/browser/profiles/profile_destroyer.h" | 5 #include "chrome/browser/profiles/profile_destroyer.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 const content::NotificationSource& source, | 134 const content::NotificationSource& source, |
135 const content::NotificationDetails& details) { | 135 const content::NotificationDetails& details) { |
136 DCHECK(type == content::NOTIFICATION_RENDERER_PROCESS_TERMINATED); | 136 DCHECK(type == content::NOTIFICATION_RENDERER_PROCESS_TERMINATED); |
137 registrar_.Remove(this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, | 137 registrar_.Remove(this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, |
138 source); | 138 source); |
139 DCHECK(num_hosts_ > 0); | 139 DCHECK(num_hosts_ > 0); |
140 --num_hosts_; | 140 --num_hosts_; |
141 if (num_hosts_ == 0) { | 141 if (num_hosts_ == 0) { |
142 // Delay the destruction one step further in case other observers of this | 142 // Delay the destruction one step further in case other observers of this |
143 // notification need to look at the profile attached to the host. | 143 // notification need to look at the profile attached to the host. |
144 MessageLoop::current()->PostTask( | 144 base::MessageLoop::current()->PostTask( |
145 FROM_HERE, base::Bind(&ProfileDestroyer::DestroyProfile, this)); | 145 FROM_HERE, base::Bind(&ProfileDestroyer::DestroyProfile, this)); |
146 } | 146 } |
147 } | 147 } |
148 | 148 |
149 void ProfileDestroyer::DestroyProfile() { | 149 void ProfileDestroyer::DestroyProfile() { |
150 // We might have been cancelled externally before the timer expired. | 150 // We might have been cancelled externally before the timer expired. |
151 if (profile_ == NULL) | 151 if (profile_ == NULL) |
152 return; | 152 return; |
153 DCHECK(profile_->IsOffTheRecord()); | 153 DCHECK(profile_->IsOffTheRecord()); |
154 DCHECK(profile_->GetOriginalProfile()); | 154 DCHECK(profile_->GetOriginalProfile()); |
(...skipping 16 matching lines...) Expand all Loading... |
171 content::RenderProcessHost::AllHostsIterator()); | 171 content::RenderProcessHost::AllHostsIterator()); |
172 !iter.IsAtEnd(); iter.Advance()) { | 172 !iter.IsAtEnd(); iter.Advance()) { |
173 content::RenderProcessHost* render_process_host = iter.GetCurrentValue(); | 173 content::RenderProcessHost* render_process_host = iter.GetCurrentValue(); |
174 if (render_process_host && Profile::FromBrowserContext( | 174 if (render_process_host && Profile::FromBrowserContext( |
175 render_process_host->GetBrowserContext()) == profile) { | 175 render_process_host->GetBrowserContext()) == profile) { |
176 hosts->push_back(render_process_host); | 176 hosts->push_back(render_process_host); |
177 } | 177 } |
178 } | 178 } |
179 return !hosts->empty(); | 179 return !hosts->empty(); |
180 } | 180 } |
OLD | NEW |