Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(230)

Side by Side Diff: chrome/browser/profiles/profile_destroyer.cc

Issue 11567053: Fix test-running in --single-process mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Improve comment Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/test/base/in_process_browser_test.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 17 matching lines...) Expand all
28 28
29 std::vector<content::RenderProcessHost*> hosts; 29 std::vector<content::RenderProcessHost*> hosts;
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 // Generally, !hosts.empty() means that there is a leak in a render process
39 // there is a leak in a render process host that MUST BE FIXED!!! 39 // host that MUST BE FIXED!!!
40 DCHECK(hosts.empty() || profile->IsOffTheRecord()); 40 //
41 // However, off-the-record profiles are destroyed before their
42 // RenderProcessHosts in order to erase private data quickly, and
43 // RenderProcessHostImpl::Release() avoids destroying RenderProcessHosts in
44 // --single-process mode to avoid race conditions.
45 DCHECK(hosts.empty() || profile->IsOffTheRecord() ||
46 content::RenderProcessHost::run_renderer_in_process());
41 // Note that we still test for !profile->IsOffTheRecord here even though we 47 // 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 48 // 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. 49 // we need to identify if there are leaks when we run Debug builds.
44 if (hosts.empty() || !profile->IsOffTheRecord()) { 50 if (hosts.empty() || !profile->IsOffTheRecord()) {
45 if (profile->IsOffTheRecord()) 51 if (profile->IsOffTheRecord())
46 profile->GetOriginalProfile()->DestroyOffTheRecordProfile(); 52 profile->GetOriginalProfile()->DestroyOffTheRecordProfile();
47 else 53 else
48 delete profile; 54 delete profile;
49 } else { 55 } else {
50 // The instance will destroy itself once all render process hosts referring 56 // The instance will destroy itself once all render process hosts referring
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 content::RenderProcessHost::AllHostsIterator()); 171 content::RenderProcessHost::AllHostsIterator());
166 !iter.IsAtEnd(); iter.Advance()) { 172 !iter.IsAtEnd(); iter.Advance()) {
167 content::RenderProcessHost* render_process_host = iter.GetCurrentValue(); 173 content::RenderProcessHost* render_process_host = iter.GetCurrentValue();
168 if (render_process_host && Profile::FromBrowserContext( 174 if (render_process_host && Profile::FromBrowserContext(
169 render_process_host->GetBrowserContext()) == profile) { 175 render_process_host->GetBrowserContext()) == profile) {
170 hosts->push_back(render_process_host); 176 hosts->push_back(render_process_host);
171 } 177 }
172 } 178 }
173 return !hosts->empty(); 179 return !hosts->empty();
174 } 180 }
OLDNEW
« no previous file with comments | « no previous file | chrome/test/base/in_process_browser_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698