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/location.h" | 8 #include "base/location.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 weak_ptr_factory_.GetWeakPtr())); | 115 weak_ptr_factory_.GetWeakPtr())); |
116 } | 116 } |
117 } | 117 } |
118 | 118 |
119 ProfileDestroyer::~ProfileDestroyer() { | 119 ProfileDestroyer::~ProfileDestroyer() { |
120 // Check again, in case other render hosts were added while we were | 120 // Check again, in case other render hosts were added while we were |
121 // waiting for the previous ones to go away... | 121 // waiting for the previous ones to go away... |
122 if (profile_) | 122 if (profile_) |
123 DestroyProfileWhenAppropriate(profile_); | 123 DestroyProfileWhenAppropriate(profile_); |
124 | 124 |
| 125 #ifdef NDEBUG |
125 // Don't wait for pending registrations, if any, these hosts are buggy. | 126 // Don't wait for pending registrations, if any, these hosts are buggy. |
126 // Note: this can happen, but if so, it's better to crash here than wait | 127 // Note: this can happen, but if so, it's better to crash here than wait |
127 // for the host to dereference a deleted Profile. http://crbug.com/248625 | 128 // for the host to dereference a deleted Profile. http://crbug.com/248625 |
128 CHECK_EQ(0U, num_hosts_) << "Some render process hosts were not " | 129 CHECK_EQ(0U, num_hosts_) << "Some render process hosts were not " |
129 << "destroyed early enough!"; | 130 << "destroyed early enough!"; |
130 | 131 #endif // NDEBUG |
131 DCHECK(pending_destroyers_ != NULL); | 132 DCHECK(pending_destroyers_ != NULL); |
132 DestroyerSet::iterator iter = pending_destroyers_->find(this); | 133 DestroyerSet::iterator iter = pending_destroyers_->find(this); |
133 DCHECK(iter != pending_destroyers_->end()); | 134 DCHECK(iter != pending_destroyers_->end()); |
134 pending_destroyers_->erase(iter); | 135 pending_destroyers_->erase(iter); |
135 if (pending_destroyers_->empty()) { | 136 if (pending_destroyers_->empty()) { |
136 delete pending_destroyers_; | 137 delete pending_destroyers_; |
137 pending_destroyers_ = NULL; | 138 pending_destroyers_ = NULL; |
138 } | 139 } |
139 } | 140 } |
140 | 141 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 content::RenderProcessHost::AllHostsIterator()); | 177 content::RenderProcessHost::AllHostsIterator()); |
177 !iter.IsAtEnd(); iter.Advance()) { | 178 !iter.IsAtEnd(); iter.Advance()) { |
178 content::RenderProcessHost* render_process_host = iter.GetCurrentValue(); | 179 content::RenderProcessHost* render_process_host = iter.GetCurrentValue(); |
179 if (render_process_host && | 180 if (render_process_host && |
180 render_process_host->GetBrowserContext() == profile) { | 181 render_process_host->GetBrowserContext() == profile) { |
181 hosts->insert(render_process_host); | 182 hosts->insert(render_process_host); |
182 } | 183 } |
183 } | 184 } |
184 return !hosts->empty(); | 185 return !hosts->empty(); |
185 } | 186 } |
OLD | NEW |