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/debug/trace_event.h" |
8 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
10 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
11 #include "content/public/browser/notification_source.h" | 12 #include "content/public/browser/notification_source.h" |
12 #include "content/public/browser/notification_types.h" | 13 #include "content/public/browser/notification_types.h" |
13 #include "content/public/browser/render_process_host.h" | 14 #include "content/public/browser/render_process_host.h" |
14 | 15 |
15 | 16 |
16 namespace { | 17 namespace { |
17 | 18 |
18 const int64 kTimerDelaySeconds = 1; | 19 const int64 kTimerDelaySeconds = 1; |
19 | 20 |
20 } // namespace | 21 } // namespace |
21 | 22 |
22 std::vector<ProfileDestroyer*>* ProfileDestroyer::pending_destroyers_ = NULL; | 23 std::vector<ProfileDestroyer*>* ProfileDestroyer::pending_destroyers_ = NULL; |
23 | 24 |
24 // static | 25 // static |
25 void ProfileDestroyer::DestroyProfileWhenAppropriate(Profile* const profile) { | 26 void ProfileDestroyer::DestroyProfileWhenAppropriate(Profile* const profile) { |
| 27 TRACE_EVENT0("shutdown", "ProfileDestroyer::DestroyProfileWhenAppropriate"); |
| 28 |
26 DCHECK(profile); | 29 DCHECK(profile); |
27 profile->MaybeSendDestroyedNotification(); | 30 profile->MaybeSendDestroyedNotification(); |
28 | 31 |
29 std::vector<content::RenderProcessHost*> hosts; | 32 std::vector<content::RenderProcessHost*> hosts; |
30 // Testing profiles can simply be deleted directly. Some tests don't setup | 33 // Testing profiles can simply be deleted directly. Some tests don't setup |
31 // RenderProcessHost correctly and don't necessary run on the UI thread | 34 // RenderProcessHost correctly and don't necessary run on the UI thread |
32 // anyway, so we can't use the AllHostIterator. | 35 // anyway, so we can't use the AllHostIterator. |
33 if (profile->AsTestingProfile() == NULL) { | 36 if (profile->AsTestingProfile() == NULL) { |
34 GetHostsForProfile(profile, &hosts); | 37 GetHostsForProfile(profile, &hosts); |
35 if (!profile->IsOffTheRecord() && profile->HasOffTheRecordProfile()) | 38 if (!profile->IsOffTheRecord() && profile->HasOffTheRecordProfile()) |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 content::RenderProcessHost::AllHostsIterator()); | 180 content::RenderProcessHost::AllHostsIterator()); |
178 !iter.IsAtEnd(); iter.Advance()) { | 181 !iter.IsAtEnd(); iter.Advance()) { |
179 content::RenderProcessHost* render_process_host = iter.GetCurrentValue(); | 182 content::RenderProcessHost* render_process_host = iter.GetCurrentValue(); |
180 if (render_process_host && Profile::FromBrowserContext( | 183 if (render_process_host && Profile::FromBrowserContext( |
181 render_process_host->GetBrowserContext()) == profile) { | 184 render_process_host->GetBrowserContext()) == profile) { |
182 hosts->push_back(render_process_host); | 185 hosts->push_back(render_process_host); |
183 } | 186 } |
184 } | 187 } |
185 return !hosts->empty(); | 188 return !hosts->empty(); |
186 } | 189 } |
OLD | NEW |