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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <map> | 10 #include <map> |
11 #include <utility> | 11 #include <utility> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/atomic_ref_count.h" | 14 #include "base/atomic_ref_count.h" |
15 #include "base/bind.h" | 15 #include "base/bind.h" |
16 #include "base/bind_helpers.h" | 16 #include "base/bind_helpers.h" |
17 #include "base/command_line.h" | 17 #include "base/command_line.h" |
18 #include "base/debug/crash_logging.h" | 18 #include "base/debug/crash_logging.h" |
19 #include "base/debug/leak_annotations.h" | 19 #include "base/debug/leak_annotations.h" |
20 #include "base/files/file_path.h" | 20 #include "base/files/file_path.h" |
21 #include "base/location.h" | 21 #include "base/location.h" |
22 #include "base/macros.h" | 22 #include "base/macros.h" |
23 #include "base/memory/ptr_util.h" | 23 #include "base/memory/ptr_util.h" |
24 #include "base/metrics/field_trial.h" | 24 #include "base/metrics/field_trial.h" |
25 #include "base/metrics/histogram_macros.h" | 25 #include "base/metrics/histogram_macros.h" |
26 #include "base/path_service.h" | 26 #include "base/path_service.h" |
| 27 #include "base/run_loop.h" |
27 #include "base/single_thread_task_runner.h" | 28 #include "base/single_thread_task_runner.h" |
28 #include "base/synchronization/waitable_event.h" | 29 #include "base/synchronization/waitable_event.h" |
29 #include "base/threading/sequenced_worker_pool.h" | 30 #include "base/threading/sequenced_worker_pool.h" |
30 #include "base/threading/thread.h" | 31 #include "base/threading/thread.h" |
31 #include "base/threading/thread_restrictions.h" | 32 #include "base/threading/thread_restrictions.h" |
32 #include "base/threading/thread_task_runner_handle.h" | 33 #include "base/threading/thread_task_runner_handle.h" |
33 #include "base/time/default_clock.h" | 34 #include "base/time/default_clock.h" |
34 #include "base/time/default_tick_clock.h" | 35 #include "base/time/default_tick_clock.h" |
35 #include "base/trace_event/trace_event.h" | 36 #include "base/trace_event/trace_event.h" |
36 #include "build/build_config.h" | 37 #include "build/build_config.h" |
(...skipping 1321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1358 #endif | 1359 #endif |
1359 | 1360 |
1360 #if defined(LEAK_SANITIZER) | 1361 #if defined(LEAK_SANITIZER) |
1361 // Check for memory leaks now, before we start shutting down threads. Doing | 1362 // Check for memory leaks now, before we start shutting down threads. Doing |
1362 // this early means we won't report any shutdown-only leaks (as they have | 1363 // this early means we won't report any shutdown-only leaks (as they have |
1363 // not yet happened at this point). | 1364 // not yet happened at this point). |
1364 // If leaks are found, this will make the process exit immediately. | 1365 // If leaks are found, this will make the process exit immediately. |
1365 __lsan_do_leak_check(); | 1366 __lsan_do_leak_check(); |
1366 #endif | 1367 #endif |
1367 | 1368 |
1368 CHECK(base::MessageLoop::current()->is_running()); | 1369 CHECK(base::RunLoop::IsRunningOnCurrentThread()); |
1369 | 1370 |
1370 #if defined(OS_MACOSX) | 1371 #if defined(OS_MACOSX) |
1371 base::ThreadTaskRunnerHandle::Get()->PostTask( | 1372 base::ThreadTaskRunnerHandle::Get()->PostTask( |
1372 FROM_HERE, base::Bind(ChromeBrowserMainPartsMac::DidEndMainMessageLoop)); | 1373 FROM_HERE, base::Bind(ChromeBrowserMainPartsMac::DidEndMainMessageLoop)); |
1373 #endif | 1374 #endif |
1374 base::MessageLoop::current()->QuitWhenIdle(); | 1375 base::MessageLoop::current()->QuitWhenIdle(); |
1375 | 1376 |
1376 #if !defined(OS_ANDROID) | 1377 #if !defined(OS_ANDROID) |
1377 chrome::ShutdownIfNeeded(); | 1378 chrome::ShutdownIfNeeded(); |
1378 #endif // !defined(OS_ANDROID) | 1379 #endif // !defined(OS_ANDROID) |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1435 } | 1436 } |
1436 | 1437 |
1437 void BrowserProcessImpl::OnAutoupdateTimer() { | 1438 void BrowserProcessImpl::OnAutoupdateTimer() { |
1438 if (CanAutorestartForUpdate()) { | 1439 if (CanAutorestartForUpdate()) { |
1439 DLOG(WARNING) << "Detected update. Restarting browser."; | 1440 DLOG(WARNING) << "Detected update. Restarting browser."; |
1440 RestartBackgroundInstance(); | 1441 RestartBackgroundInstance(); |
1441 } | 1442 } |
1442 } | 1443 } |
1443 | 1444 |
1444 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 1445 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
OLD | NEW |