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 "content/browser/browser_main_loop.h" | 5 #include "content/browser/browser_main_loop.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 #include "content/browser/renderer_host/media/media_stream_manager.h" | 42 #include "content/browser/renderer_host/media/media_stream_manager.h" |
43 #include "content/browser/speech/speech_recognition_manager_impl.h" | 43 #include "content/browser/speech/speech_recognition_manager_impl.h" |
44 #include "content/browser/startup_task_runner.h" | 44 #include "content/browser/startup_task_runner.h" |
45 #include "content/browser/time_zone_monitor.h" | 45 #include "content/browser/time_zone_monitor.h" |
46 #include "content/browser/webui/content_web_ui_controller_factory.h" | 46 #include "content/browser/webui/content_web_ui_controller_factory.h" |
47 #include "content/browser/webui/url_data_manager.h" | 47 #include "content/browser/webui/url_data_manager.h" |
48 #include "content/common/content_switches_internal.h" | 48 #include "content/common/content_switches_internal.h" |
49 #include "content/common/host_discardable_shared_memory_manager.h" | 49 #include "content/common/host_discardable_shared_memory_manager.h" |
50 #include "content/common/host_shared_bitmap_manager.h" | 50 #include "content/common/host_shared_bitmap_manager.h" |
51 #include "content/public/browser/browser_main_parts.h" | 51 #include "content/public/browser/browser_main_parts.h" |
52 #include "content/public/browser/browser_shutdown.h" | |
53 #include "content/public/browser/content_browser_client.h" | 52 #include "content/public/browser/content_browser_client.h" |
54 #include "content/public/browser/render_process_host.h" | 53 #include "content/public/browser/render_process_host.h" |
55 #include "content/public/browser/tracing_controller.h" | 54 #include "content/public/browser/tracing_controller.h" |
56 #include "content/public/common/content_switches.h" | 55 #include "content/public/common/content_switches.h" |
57 #include "content/public/common/main_function_params.h" | 56 #include "content/public/common/main_function_params.h" |
58 #include "content/public/common/result_codes.h" | 57 #include "content/public/common/result_codes.h" |
59 #include "crypto/nss_util.h" | 58 #include "crypto/nss_util.h" |
60 #include "device/battery/battery_status_service.h" | 59 #include "device/battery/battery_status_service.h" |
61 #include "media/audio/audio_manager.h" | 60 #include "media/audio/audio_manager.h" |
62 #include "media/base/media.h" | 61 #include "media/base/media.h" |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 // In absence of valid switches use the automatic defaults. | 327 // In absence of valid switches use the automatic defaults. |
329 return new base::win::MemoryPressureMonitor(); | 328 return new base::win::MemoryPressureMonitor(); |
330 } | 329 } |
331 #endif // defined(OS_WIN) | 330 #endif // defined(OS_WIN) |
332 | 331 |
333 } // namespace | 332 } // namespace |
334 | 333 |
335 // The currently-running BrowserMainLoop. There can be one or zero. | 334 // The currently-running BrowserMainLoop. There can be one or zero. |
336 BrowserMainLoop* g_current_browser_main_loop = NULL; | 335 BrowserMainLoop* g_current_browser_main_loop = NULL; |
337 | 336 |
338 // This is just to be able to keep ShutdownThreadsAndCleanUp out of | |
339 // the public interface of BrowserMainLoop. | |
340 class BrowserShutdownImpl { | |
341 public: | |
342 static void ImmediateShutdownAndExitProcess() { | |
343 DCHECK(g_current_browser_main_loop); | |
344 g_current_browser_main_loop->ShutdownThreadsAndCleanUp(); | |
345 | |
346 #if defined(OS_WIN) | |
347 // At this point the message loop is still running yet we've shut everything | |
348 // down. If any messages are processed we'll likely crash. Exit now. | |
349 ExitProcess(RESULT_CODE_NORMAL_EXIT); | |
350 #elif defined(OS_POSIX) && !defined(OS_MACOSX) | |
351 _exit(RESULT_CODE_NORMAL_EXIT); | |
352 #else | |
353 NOTIMPLEMENTED(); | |
354 #endif | |
355 } | |
356 }; | |
357 | |
358 void ImmediateShutdownAndExitProcess() { | |
359 BrowserShutdownImpl::ImmediateShutdownAndExitProcess(); | |
360 } | |
361 | |
362 // For measuring memory usage after each task. Behind a command line flag. | 337 // For measuring memory usage after each task. Behind a command line flag. |
363 class BrowserMainLoop::MemoryObserver : public base::MessageLoop::TaskObserver { | 338 class BrowserMainLoop::MemoryObserver : public base::MessageLoop::TaskObserver { |
364 public: | 339 public: |
365 MemoryObserver() {} | 340 MemoryObserver() {} |
366 ~MemoryObserver() override {} | 341 ~MemoryObserver() override {} |
367 | 342 |
368 void WillProcessTask(const base::PendingTask& pending_task) override {} | 343 void WillProcessTask(const base::PendingTask& pending_task) override {} |
369 | 344 |
370 void DidProcessTask(const base::PendingTask& pending_task) override { | 345 void DidProcessTask(const base::PendingTask& pending_task) override { |
371 #if !defined(OS_IOS) // No ProcessMetrics on IOS. | 346 #if !defined(OS_IOS) // No ProcessMetrics on IOS. |
(...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1351 | 1326 |
1352 void BrowserMainLoop::EndStartupTracing() { | 1327 void BrowserMainLoop::EndStartupTracing() { |
1353 is_tracing_startup_ = false; | 1328 is_tracing_startup_ = false; |
1354 TracingController::GetInstance()->DisableRecording( | 1329 TracingController::GetInstance()->DisableRecording( |
1355 TracingController::CreateFileSink( | 1330 TracingController::CreateFileSink( |
1356 startup_trace_file_, | 1331 startup_trace_file_, |
1357 base::Bind(OnStoppedStartupTracing, startup_trace_file_))); | 1332 base::Bind(OnStoppedStartupTracing, startup_trace_file_))); |
1358 } | 1333 } |
1359 | 1334 |
1360 } // namespace content | 1335 } // namespace content |
OLD | NEW |