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 19 matching lines...) Expand all Loading... | |
30 // Testing profiles can simply be deleted directly. Some tests don't setup | 30 // Testing profiles can simply be deleted directly. Some tests don't setup |
31 // RenderProcessHost correctly and don't necessary run on the UI thread | 31 // RenderProcessHost correctly and don't necessary run on the UI thread |
32 // anyway, so we can't use the AllHostIterator. | 32 // anyway, so we can't use the AllHostIterator. |
33 if (profile->AsTestingProfile() == NULL) { | 33 if (profile->AsTestingProfile() == NULL) { |
34 GetHostsForProfile(profile, &hosts); | 34 GetHostsForProfile(profile, &hosts); |
35 if (!profile->IsOffTheRecord() && profile->HasOffTheRecordProfile()) | 35 if (!profile->IsOffTheRecord() && profile->HasOffTheRecordProfile()) |
36 GetHostsForProfile(profile->GetOffTheRecordProfile(), &hosts); | 36 GetHostsForProfile(profile->GetOffTheRecordProfile(), &hosts); |
37 } | 37 } |
38 // This should never happen for non Off the record profile, this means that | 38 // This should never happen for non Off the record profile, this means that |
39 // there is a leak in a render process host that MUST BE FIXED!!! | 39 // there is a leak in a render process host that MUST BE FIXED!!! |
40 DCHECK(hosts.empty() || profile->IsOffTheRecord()); | 40 DCHECK(content::RenderProcessHost::run_renderer_in_process() || |
MAD
2012/12/15 00:11:22
Can you please add a comment stating why we need t
Jeffrey Yasskin
2012/12/15 00:31:31
Sure. Could you explain why off-the-record profile
MAD
2012/12/15 04:05:31
Good point, this is because we don't want to delay
| |
41 hosts.empty() || profile->IsOffTheRecord()); | |
41 // Note that we still test for !profile->IsOffTheRecord here even though we | 42 // Note that we still test for !profile->IsOffTheRecord here even though we |
42 // DCHECK'd above because we want to protect Release builds against this even | 43 // DCHECK'd above because we want to protect Release builds against this even |
43 // we need to identify if there are leaks when we run Debug builds. | 44 // we need to identify if there are leaks when we run Debug builds. |
44 if (hosts.empty() || !profile->IsOffTheRecord()) { | 45 if (hosts.empty() || !profile->IsOffTheRecord()) { |
45 if (profile->IsOffTheRecord()) | 46 if (profile->IsOffTheRecord()) |
46 profile->GetOriginalProfile()->DestroyOffTheRecordProfile(); | 47 profile->GetOriginalProfile()->DestroyOffTheRecordProfile(); |
47 else | 48 else |
48 delete profile; | 49 delete profile; |
49 } else { | 50 } else { |
50 // The instance will destroy itself once all render process hosts referring | 51 // The instance will destroy itself once all render process hosts referring |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
165 content::RenderProcessHost::AllHostsIterator()); | 166 content::RenderProcessHost::AllHostsIterator()); |
166 !iter.IsAtEnd(); iter.Advance()) { | 167 !iter.IsAtEnd(); iter.Advance()) { |
167 content::RenderProcessHost* render_process_host = iter.GetCurrentValue(); | 168 content::RenderProcessHost* render_process_host = iter.GetCurrentValue(); |
168 if (render_process_host && Profile::FromBrowserContext( | 169 if (render_process_host && Profile::FromBrowserContext( |
169 render_process_host->GetBrowserContext()) == profile) { | 170 render_process_host->GetBrowserContext()) == profile) { |
170 hosts->push_back(render_process_host); | 171 hosts->push_back(render_process_host); |
171 } | 172 } |
172 } | 173 } |
173 return !hosts->empty(); | 174 return !hosts->empty(); |
174 } | 175 } |
OLD | NEW |