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/browser_process_impl.h" | 5 #include "chrome/browser/browser_process_impl.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/debug/alias.h" |
14 #include "base/file_util.h" | 15 #include "base/file_util.h" |
15 #include "base/path_service.h" | 16 #include "base/path_service.h" |
16 #include "base/synchronization/waitable_event.h" | 17 #include "base/synchronization/waitable_event.h" |
17 #include "base/threading/thread.h" | 18 #include "base/threading/thread.h" |
18 #include "base/threading/thread_restrictions.h" | 19 #include "base/threading/thread_restrictions.h" |
19 #include "chrome/browser/automation/automation_provider_list.h" | 20 #include "chrome/browser/automation/automation_provider_list.h" |
20 #include "chrome/browser/background/background_mode_manager.h" | 21 #include "chrome/browser/background/background_mode_manager.h" |
21 #include "chrome/browser/browser_trial.h" | 22 #include "chrome/browser/browser_trial.h" |
22 #include "chrome/browser/chrome_browser_main.h" | 23 #include "chrome/browser/chrome_browser_main.h" |
23 #include "chrome/browser/chrome_plugin_service_filter.h" | 24 #include "chrome/browser/chrome_plugin_service_filter.h" |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 message_loop->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 238 message_loop->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
238 } | 239 } |
239 #elif defined(USE_X11) | 240 #elif defined(USE_X11) |
240 static void Signal(base::WaitableEvent* event) { | 241 static void Signal(base::WaitableEvent* event) { |
241 event->Signal(); | 242 event->Signal(); |
242 } | 243 } |
243 #endif | 244 #endif |
244 | 245 |
245 unsigned int BrowserProcessImpl::AddRefModule() { | 246 unsigned int BrowserProcessImpl::AddRefModule() { |
246 DCHECK(CalledOnValidThread()); | 247 DCHECK(CalledOnValidThread()); |
247 CHECK(!IsShuttingDown()); | 248 |
| 249 // CHECK(!IsShuttingDown()); |
| 250 if (IsShuttingDown()) { |
| 251 // Copy the stacktrace which released the final reference onto our stack so |
| 252 // it will be available in the crash report for inspection. |
| 253 base::debug::StackTrace callstack = release_last_reference_callstack_; |
| 254 base::debug::Alias(&callstack); |
| 255 CHECK(false); |
| 256 } |
| 257 |
248 did_start_ = true; | 258 did_start_ = true; |
249 module_ref_count_++; | 259 module_ref_count_++; |
250 return module_ref_count_; | 260 return module_ref_count_; |
251 } | 261 } |
252 | 262 |
253 unsigned int BrowserProcessImpl::ReleaseModule() { | 263 unsigned int BrowserProcessImpl::ReleaseModule() { |
254 DCHECK(CalledOnValidThread()); | 264 DCHECK(CalledOnValidThread()); |
255 DCHECK_NE(0u, module_ref_count_); | 265 DCHECK_NE(0u, module_ref_count_); |
256 module_ref_count_--; | 266 module_ref_count_--; |
257 if (0 == module_ref_count_) { | 267 if (0 == module_ref_count_) { |
| 268 release_last_reference_callstack_ = base::debug::StackTrace(); |
| 269 |
258 CHECK(MessageLoop::current()->is_running()); | 270 CHECK(MessageLoop::current()->is_running()); |
259 // Allow UI and IO threads to do blocking IO on shutdown, since we do a lot | 271 // Allow UI and IO threads to do blocking IO on shutdown, since we do a lot |
260 // of it on shutdown for valid reasons. | 272 // of it on shutdown for valid reasons. |
261 base::ThreadRestrictions::SetIOAllowed(true); | 273 base::ThreadRestrictions::SetIOAllowed(true); |
262 CHECK(!BrowserList::GetLastActive()); | 274 CHECK(!BrowserList::GetLastActive()); |
263 BrowserThread::PostTask( | 275 BrowserThread::PostTask( |
264 BrowserThread::IO, | 276 BrowserThread::IO, |
265 FROM_HERE, | 277 FROM_HERE, |
266 base::Bind(base::IgnoreResult(&base::ThreadRestrictions::SetIOAllowed), | 278 base::Bind(base::IgnoreResult(&base::ThreadRestrictions::SetIOAllowed), |
267 true)); | 279 true)); |
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
890 } | 902 } |
891 | 903 |
892 void BrowserProcessImpl::OnAutoupdateTimer() { | 904 void BrowserProcessImpl::OnAutoupdateTimer() { |
893 if (CanAutorestartForUpdate()) { | 905 if (CanAutorestartForUpdate()) { |
894 DLOG(WARNING) << "Detected update. Restarting browser."; | 906 DLOG(WARNING) << "Detected update. Restarting browser."; |
895 RestartBackgroundInstance(); | 907 RestartBackgroundInstance(); |
896 } | 908 } |
897 } | 909 } |
898 | 910 |
899 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 911 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
OLD | NEW |