Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(530)

Side by Side Diff: chrome/browser/lifetime/application_lifetime.cc

Issue 651253002: Enforce handle ownership in base::Process (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add empty line Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/lifetime/application_lifetime.h" 5 #include "chrome/browser/lifetime/application_lifetime.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "base/metrics/field_trial.h" 14 #include "base/metrics/field_trial.h"
15 #include "base/prefs/pref_service.h" 15 #include "base/prefs/pref_service.h"
16 #include "base/process/kill.h" 16 #include "base/process/kill.h"
17 #include "base/process/process.h" 17 #include "base/process/process_handle.h"
18 #include "build/build_config.h" 18 #include "build/build_config.h"
19 #include "chrome/browser/browser_process.h" 19 #include "chrome/browser/browser_process.h"
20 #include "chrome/browser/browser_process_platform_part.h" 20 #include "chrome/browser/browser_process_platform_part.h"
21 #include "chrome/browser/browser_shutdown.h" 21 #include "chrome/browser/browser_shutdown.h"
22 #include "chrome/browser/chrome_notification_types.h" 22 #include "chrome/browser/chrome_notification_types.h"
23 #include "chrome/browser/download/download_service.h" 23 #include "chrome/browser/download/download_service.h"
24 #include "chrome/browser/lifetime/browser_close_manager.h" 24 #include "chrome/browser/lifetime/browser_close_manager.h"
25 #include "chrome/browser/metrics/thread_watcher.h" 25 #include "chrome/browser/metrics/thread_watcher.h"
26 #include "chrome/browser/profiles/profile.h" 26 #include "chrome/browser/profiles/profile.h"
27 #include "chrome/browser/profiles/profile_manager.h" 27 #include "chrome/browser/profiles/profile_manager.h"
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 content::NotificationService::AllSources(), 304 content::NotificationService::AllSources(),
305 content::NotificationService::NoDetails()); 305 content::NotificationService::NoDetails());
306 306
307 // This will end by terminating the process. 307 // This will end by terminating the process.
308 content::ImmediateShutdownAndExitProcess(); 308 content::ImmediateShutdownAndExitProcess();
309 } else { 309 } else {
310 // On Windows 7 and later, the system will consider the process ripe for 310 // On Windows 7 and later, the system will consider the process ripe for
311 // termination as soon as it hides or destroys its windows. Since any 311 // termination as soon as it hides or destroys its windows. Since any
312 // execution past that point will be non-deterministically cut short, we 312 // execution past that point will be non-deterministically cut short, we
313 // might as well put ourselves out of that misery deterministically. 313 // might as well put ourselves out of that misery deterministically.
314 base::KillProcess(base::Process::Current().handle(), 0, false); 314 base::KillProcess(base::GetCurrentProcessHandle(), 0, false);
315 } 315 }
316 } 316 }
317 317
318 void IncrementKeepAliveCount() { 318 void IncrementKeepAliveCount() {
319 // Increment the browser process refcount as long as we're keeping the 319 // Increment the browser process refcount as long as we're keeping the
320 // application alive. 320 // application alive.
321 if (!WillKeepAlive()) 321 if (!WillKeepAlive())
322 g_browser_process->AddRefModule(); 322 g_browser_process->AddRefModule();
323 ++g_keep_alive_count; 323 ++g_keep_alive_count;
324 } 324 }
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 // environment is still active. 420 // environment is still active.
421 if (browser->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_NATIVE) 421 if (browser->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_NATIVE)
422 return !ash::Shell::HasInstance(); 422 return !ash::Shell::HasInstance();
423 else if (browser->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH) 423 else if (browser->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH)
424 return BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE)->empty(); 424 return BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE)->empty();
425 #endif 425 #endif
426 return true; 426 return true;
427 } 427 }
428 428
429 } // namespace chrome 429 } // namespace chrome
OLDNEW
« no previous file with comments | « base/win/event_trace_controller_unittest.cc ('k') | chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698