| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 12 #include "base/synchronization/waitable_event.h" | 12 #include "base/synchronization/waitable_event.h" |
| 13 #include "base/task.h" | 13 #include "base/task.h" |
| 14 #include "base/threading/thread.h" | 14 #include "base/threading/thread.h" |
| 15 #include "base/threading/thread_restrictions.h" | 15 #include "base/threading/thread_restrictions.h" |
| 16 #include "chrome/browser/automation/automation_provider_list.h" | 16 #include "chrome/browser/automation/automation_provider_list.h" |
| 17 #include "chrome/browser/browser_main.h" | 17 #include "chrome/browser/browser_main.h" |
| 18 #include "chrome/browser/browser_process_sub_thread.h" | 18 #include "chrome/browser/browser_process_sub_thread.h" |
| 19 #include "chrome/browser/browser_trial.h" | 19 #include "chrome/browser/browser_trial.h" |
| 20 #include "chrome/browser/debugger/browser_list_tabcontents_provider.h" | 20 #include "chrome/browser/debugger/browser_list_tabcontents_provider.h" |
| 21 #include "chrome/browser/debugger/devtools_http_protocol_handler.h" | 21 #include "chrome/browser/debugger/devtools_http_protocol_handler.h" |
| 22 #include "chrome/browser/debugger/devtools_manager.h" | 22 #include "chrome/browser/debugger/devtools_manager.h" |
| 23 #include "chrome/browser/debugger/devtools_protocol_handler.h" | 23 #include "chrome/browser/debugger/devtools_protocol_handler.h" |
| 24 #include "chrome/browser/download/download_file_manager.h" | 24 #include "chrome/browser/download/download_file_manager.h" |
| 25 #include "chrome/browser/download/save_file_manager.h" | 25 #include "chrome/browser/download/save_file_manager.h" |
| 26 #include "chrome/browser/extensions/extension_event_router_forwarder.h" | 26 #include "chrome/browser/extensions/extension_event_router_forwarder.h" |
| 27 #include "chrome/browser/extensions/extension_tab_id_map.h" | 27 #include "chrome/browser/extensions/extension_tab_id_map.h" |
| 28 #include "chrome/browser/extensions/user_script_listener.h" | 28 #include "chrome/browser/extensions/user_script_listener.h" |
| 29 #include "chrome/browser/first_run/upgrade.h" | 29 #include "chrome/browser/first_run/upgrade_util.h" |
| 30 #include "chrome/browser/google/google_url_tracker.h" | 30 #include "chrome/browser/google/google_url_tracker.h" |
| 31 #include "chrome/browser/gpu_process_host_ui_shim.h" | 31 #include "chrome/browser/gpu_process_host_ui_shim.h" |
| 32 #include "chrome/browser/icon_manager.h" | 32 #include "chrome/browser/icon_manager.h" |
| 33 #include "chrome/browser/intranet_redirect_detector.h" | 33 #include "chrome/browser/intranet_redirect_detector.h" |
| 34 #include "chrome/browser/io_thread.h" | 34 #include "chrome/browser/io_thread.h" |
| 35 #include "chrome/browser/metrics/metrics_service.h" | 35 #include "chrome/browser/metrics/metrics_service.h" |
| 36 #include "chrome/browser/metrics/thread_watcher.h" | 36 #include "chrome/browser/metrics/thread_watcher.h" |
| 37 #include "chrome/browser/net/chrome_net_log.h" | 37 #include "chrome/browser/net/chrome_net_log.h" |
| 38 #include "chrome/browser/net/predictor_api.h" | 38 #include "chrome/browser/net/predictor_api.h" |
| 39 #include "chrome/browser/net/sdch_dictionary_fetcher.h" | 39 #include "chrome/browser/net/sdch_dictionary_fetcher.h" |
| (...skipping 953 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 993 | 993 |
| 994 #endif // IPC_MESSAGE_LOG_ENABLED | 994 #endif // IPC_MESSAGE_LOG_ENABLED |
| 995 | 995 |
| 996 // Mac is currently not supported. | 996 // Mac is currently not supported. |
| 997 #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 997 #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
| 998 | 998 |
| 999 bool BrowserProcessImpl::CanAutorestartForUpdate() const { | 999 bool BrowserProcessImpl::CanAutorestartForUpdate() const { |
| 1000 // Check if browser is in the background and if it needs to be restarted to | 1000 // Check if browser is in the background and if it needs to be restarted to |
| 1001 // apply a pending update. | 1001 // apply a pending update. |
| 1002 return BrowserList::size() == 0 && BrowserList::WillKeepAlive() && | 1002 return BrowserList::size() == 0 && BrowserList::WillKeepAlive() && |
| 1003 Upgrade::IsUpdatePendingRestart(); | 1003 upgrade_util::IsUpdatePendingRestart(); |
| 1004 } | 1004 } |
| 1005 | 1005 |
| 1006 // Switches to add when auto-restarting Chrome. | 1006 // Switches to add when auto-restarting Chrome. |
| 1007 const char* const kSwitchesToAddOnAutorestart[] = { | 1007 const char* const kSwitchesToAddOnAutorestart[] = { |
| 1008 switches::kNoStartupWindow | 1008 switches::kNoStartupWindow |
| 1009 }; | 1009 }; |
| 1010 | 1010 |
| 1011 void BrowserProcessImpl::RestartPersistentInstance() { | 1011 void BrowserProcessImpl::RestartPersistentInstance() { |
| 1012 CommandLine* old_cl = CommandLine::ForCurrentProcess(); | 1012 CommandLine* old_cl = CommandLine::ForCurrentProcess(); |
| 1013 scoped_ptr<CommandLine> new_cl(new CommandLine(old_cl->GetProgram())); | 1013 scoped_ptr<CommandLine> new_cl(new CommandLine(old_cl->GetProgram())); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1032 // Ensure that our desired switches are set on the new process. | 1032 // Ensure that our desired switches are set on the new process. |
| 1033 for (size_t i = 0; i < arraysize(kSwitchesToAddOnAutorestart); ++i) { | 1033 for (size_t i = 0; i < arraysize(kSwitchesToAddOnAutorestart); ++i) { |
| 1034 if (!new_cl->HasSwitch(kSwitchesToAddOnAutorestart[i])) | 1034 if (!new_cl->HasSwitch(kSwitchesToAddOnAutorestart[i])) |
| 1035 new_cl->AppendSwitch(kSwitchesToAddOnAutorestart[i]); | 1035 new_cl->AppendSwitch(kSwitchesToAddOnAutorestart[i]); |
| 1036 } | 1036 } |
| 1037 | 1037 |
| 1038 DLOG(WARNING) << "Shutting down current instance of the browser."; | 1038 DLOG(WARNING) << "Shutting down current instance of the browser."; |
| 1039 BrowserList::CloseAllBrowsersAndExit(); | 1039 BrowserList::CloseAllBrowsersAndExit(); |
| 1040 | 1040 |
| 1041 // Transfer ownership to Upgrade. | 1041 // Transfer ownership to Upgrade. |
| 1042 Upgrade::SetNewCommandLine(new_cl.release()); | 1042 upgrade_util::SetNewCommandLine(new_cl.release()); |
| 1043 } | 1043 } |
| 1044 | 1044 |
| 1045 void BrowserProcessImpl::OnAutoupdateTimer() { | 1045 void BrowserProcessImpl::OnAutoupdateTimer() { |
| 1046 if (CanAutorestartForUpdate()) { | 1046 if (CanAutorestartForUpdate()) { |
| 1047 DLOG(WARNING) << "Detected update. Restarting browser."; | 1047 DLOG(WARNING) << "Detected update. Restarting browser."; |
| 1048 RestartPersistentInstance(); | 1048 RestartPersistentInstance(); |
| 1049 } | 1049 } |
| 1050 } | 1050 } |
| 1051 | 1051 |
| 1052 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 1052 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
| OLD | NEW |