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_shutdown.h" | 5 #include "chrome/browser/browser_shutdown.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
62 using base::Time; | 62 using base::Time; |
63 using base::TimeDelta; | 63 using base::TimeDelta; |
64 using content::BrowserThread; | 64 using content::BrowserThread; |
65 | 65 |
66 namespace browser_shutdown { | 66 namespace browser_shutdown { |
67 namespace { | 67 namespace { |
68 | 68 |
69 // Whether the browser is trying to quit (e.g., Quit chosen from menu). | 69 // Whether the browser is trying to quit (e.g., Quit chosen from menu). |
70 bool g_trying_to_quit = false; | 70 bool g_trying_to_quit = false; |
71 | 71 |
72 // If restarting and this is true then add the kNoStartupWindow switch to the | |
73 // command line. | |
74 bool g_should_restart_in_background = false; | |
75 | |
72 Time* g_shutdown_started = nullptr; | 76 Time* g_shutdown_started = nullptr; |
73 ShutdownType g_shutdown_type = NOT_VALID; | 77 ShutdownType g_shutdown_type = NOT_VALID; |
74 int g_shutdown_num_processes; | 78 int g_shutdown_num_processes; |
75 int g_shutdown_num_processes_slow; | 79 int g_shutdown_num_processes_slow; |
76 | 80 |
77 const char kShutdownMsFile[] = "chrome_shutdown_ms.txt"; | 81 const char kShutdownMsFile[] = "chrome_shutdown_ms.txt"; |
78 | 82 |
79 const char* ToShutdownTypeString(ShutdownType type) { | 83 const char* ToShutdownTypeString(ShutdownType type) { |
80 switch (type) { | 84 switch (type) { |
81 case NOT_VALID: | 85 case NOT_VALID: |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
232 about_flags::RemoveFlagsSwitches(&switches); | 236 about_flags::RemoveFlagsSwitches(&switches); |
233 switches::RemoveSwitchesForAutostart(&switches); | 237 switches::RemoveSwitchesForAutostart(&switches); |
234 // Append the old switches to the new command line. | 238 // Append the old switches to the new command line. |
235 for (const auto& it : switches) { | 239 for (const auto& it : switches) { |
236 const base::CommandLine::StringType& switch_value = it.second; | 240 const base::CommandLine::StringType& switch_value = it.second; |
237 if (!switch_value.empty()) | 241 if (!switch_value.empty()) |
238 new_cl->AppendSwitchNative(it.first, it.second); | 242 new_cl->AppendSwitchNative(it.first, it.second); |
239 else | 243 else |
240 new_cl->AppendSwitch(it.first); | 244 new_cl->AppendSwitch(it.first); |
241 } | 245 } |
246 if (g_should_restart_in_background) | |
sky
2016/05/18 19:23:06
Having a global is error prone. Can you make this
dgn
2016/06/20 17:45:19
Done. It made it a static class member in Backgrou
| |
247 new_cl->AppendSwitch(switches::kNoStartupWindow); | |
242 | 248 |
243 #if defined(OS_POSIX) || defined(OS_WIN) | 249 #if defined(OS_POSIX) || defined(OS_WIN) |
244 upgrade_util::RelaunchChromeBrowser(*new_cl.get()); | 250 upgrade_util::RelaunchChromeBrowser(*new_cl.get()); |
245 #endif // defined(OS_WIN) | 251 #endif // defined(OS_WIN) |
246 | 252 |
247 #else | 253 #else |
248 NOTIMPLEMENTED(); | 254 NOTIMPLEMENTED(); |
249 #endif // !defined(OS_CHROMEOS) | 255 #endif // !defined(OS_CHROMEOS) |
250 } | 256 } |
251 | 257 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
328 } | 334 } |
329 | 335 |
330 void SetTryingToQuit(bool quitting) { | 336 void SetTryingToQuit(bool quitting) { |
331 g_trying_to_quit = quitting; | 337 g_trying_to_quit = quitting; |
332 } | 338 } |
333 | 339 |
334 bool IsTryingToQuit() { | 340 bool IsTryingToQuit() { |
335 return g_trying_to_quit; | 341 return g_trying_to_quit; |
336 } | 342 } |
337 | 343 |
344 void SetShouldRestartInBackground(bool should_restart_in_background) { | |
345 g_should_restart_in_background = should_restart_in_background; | |
346 } | |
347 | |
338 void StartShutdownTracing() { | 348 void StartShutdownTracing() { |
339 const base::CommandLine& command_line = | 349 const base::CommandLine& command_line = |
340 *base::CommandLine::ForCurrentProcess(); | 350 *base::CommandLine::ForCurrentProcess(); |
341 if (command_line.HasSwitch(switches::kTraceShutdown)) { | 351 if (command_line.HasSwitch(switches::kTraceShutdown)) { |
342 base::trace_event::TraceConfig trace_config( | 352 base::trace_event::TraceConfig trace_config( |
343 command_line.GetSwitchValueASCII(switches::kTraceShutdown), ""); | 353 command_line.GetSwitchValueASCII(switches::kTraceShutdown), ""); |
344 content::TracingController::GetInstance()->StartTracing( | 354 content::TracingController::GetInstance()->StartTracing( |
345 trace_config, | 355 trace_config, |
346 content::TracingController::StartTracingDoneCallback()); | 356 content::TracingController::StartTracingDoneCallback()); |
347 } | 357 } |
348 TRACE_EVENT0("shutdown", "StartShutdownTracing"); | 358 TRACE_EVENT0("shutdown", "StartShutdownTracing"); |
349 } | 359 } |
350 | 360 |
351 } // namespace browser_shutdown | 361 } // namespace browser_shutdown |
OLD | NEW |