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/chrome_browser_main.h" | 5 #include "chrome/browser/chrome_browser_main.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
230 #endif // defined(ENABLE_RLZ) | 230 #endif // defined(ENABLE_RLZ) |
231 | 231 |
232 #if defined(ENABLE_WEBRTC) | 232 #if defined(ENABLE_WEBRTC) |
233 #include "chrome/browser/media/webrtc_log_util.h" | 233 #include "chrome/browser/media/webrtc_log_util.h" |
234 #endif // defined(ENABLE_WEBRTC) | 234 #endif // defined(ENABLE_WEBRTC) |
235 | 235 |
236 #if defined(USE_AURA) | 236 #if defined(USE_AURA) |
237 #include "ui/aura/env.h" | 237 #include "ui/aura/env.h" |
238 #endif // defined(USE_AURA) | 238 #endif // defined(USE_AURA) |
239 | 239 |
240 #if !defined(OS_ANDROID) && !defined(OS_IOS) | |
241 #include "chrome/browser/chrome_webusb_browser_client.h" | |
242 #include "components/webusb/webusb_detector.h" | |
243 #endif | |
244 | |
240 using content::BrowserThread; | 245 using content::BrowserThread; |
241 | 246 |
242 namespace { | 247 namespace { |
243 | 248 |
244 // This function provides some ways to test crash and assertion handling | 249 // This function provides some ways to test crash and assertion handling |
245 // behavior of the program. | 250 // behavior of the program. |
246 void HandleTestParameters(const base::CommandLine& command_line) { | 251 void HandleTestParameters(const base::CommandLine& command_line) { |
247 // This parameter causes a null pointer crash (crash reporter trigger). | 252 // This parameter causes a null pointer crash (crash reporter trigger). |
248 if (command_line.HasSwitch(switches::kBrowserCrashTest)) { | 253 if (command_line.HasSwitch(switches::kBrowserCrashTest)) { |
249 int* bad_pointer = NULL; | 254 int* bad_pointer = NULL; |
(...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1172 #if defined(ENABLE_WEBRTC) | 1177 #if defined(ENABLE_WEBRTC) |
1173 // Set up a task to delete old WebRTC log files for all profiles. Use a delay | 1178 // Set up a task to delete old WebRTC log files for all profiles. Use a delay |
1174 // to reduce the impact on startup time. | 1179 // to reduce the impact on startup time. |
1175 BrowserThread::PostDelayedTask( | 1180 BrowserThread::PostDelayedTask( |
1176 BrowserThread::UI, | 1181 BrowserThread::UI, |
1177 FROM_HERE, | 1182 FROM_HERE, |
1178 base::Bind(&WebRtcLogUtil::DeleteOldWebRtcLogFilesForAllProfiles), | 1183 base::Bind(&WebRtcLogUtil::DeleteOldWebRtcLogFilesForAllProfiles), |
1179 base::TimeDelta::FromMinutes(1)); | 1184 base::TimeDelta::FromMinutes(1)); |
1180 #endif // defined(ENABLE_WEBRTC) | 1185 #endif // defined(ENABLE_WEBRTC) |
1181 | 1186 |
1187 #if !defined(OS_ANDROID) && !defined(OS_IOS) | |
1188 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | |
1189 switches::kEnableWebUsbNotifications)) { | |
1190 webusb_browser_client_.reset(new ChromeWebUsbBrowserClient()); | |
1191 webusb_detector_.reset( | |
1192 new webusb::WebUsbDetector(webusb_browser_client_.get())); | |
1193 } | |
1194 #endif | |
1195 | |
1182 // At this point, StartupBrowserCreator::Start has run creating initial | 1196 // At this point, StartupBrowserCreator::Start has run creating initial |
1183 // browser windows and tabs, but no progress has been made in loading | 1197 // browser windows and tabs, but no progress has been made in loading |
1184 // content as the main message loop hasn't started processing tasks yet. | 1198 // content as the main message loop hasn't started processing tasks yet. |
1185 // We setup to observe to the initial page load here to defer running | 1199 // We setup to observe to the initial page load here to defer running |
1186 // task posted via PostAfterStartupTask until its complete. | 1200 // task posted via PostAfterStartupTask until its complete. |
1187 AfterStartupTaskUtils::StartMonitoringStartup(); | 1201 AfterStartupTaskUtils::StartMonitoringStartup(); |
1188 } | 1202 } |
1189 | 1203 |
1190 int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { | 1204 int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { |
1191 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreMainMessageLoopRunImpl"); | 1205 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreMainMessageLoopRunImpl"); |
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1768 g_browser_process->local_state()); | 1782 g_browser_process->local_state()); |
1769 shutdown_watcher_->Arm(base::TimeDelta::FromSeconds(300)); | 1783 shutdown_watcher_->Arm(base::TimeDelta::FromSeconds(300)); |
1770 | 1784 |
1771 // Disarm the startup hang detector time bomb if it is still Arm'ed. | 1785 // Disarm the startup hang detector time bomb if it is still Arm'ed. |
1772 startup_watcher_->Disarm(); | 1786 startup_watcher_->Disarm(); |
1773 | 1787 |
1774 // Remove observers attached to D-Bus clients before DbusThreadManager is | 1788 // Remove observers attached to D-Bus clients before DbusThreadManager is |
1775 // shut down. | 1789 // shut down. |
1776 process_power_collector_.reset(); | 1790 process_power_collector_.reset(); |
1777 | 1791 |
1792 #if !defined(OS_IOS) | |
1793 webusb_browser_client_.reset(); | |
1794 webusb_detector_.reset(); | |
stevenjb
2015/09/09 19:35:26
Note: We should really reset the detector before t
juncai
2015/09/09 20:30:29
Done in a new patch.
| |
1795 #endif | |
1796 | |
1778 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) | 1797 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) |
1779 chrome_extra_parts_[i]->PostMainMessageLoopRun(); | 1798 chrome_extra_parts_[i]->PostMainMessageLoopRun(); |
1780 | 1799 |
1781 // Some tests don't set parameters.ui_task, so they started translate | 1800 // Some tests don't set parameters.ui_task, so they started translate |
1782 // language fetch that was never completed so we need to cleanup here | 1801 // language fetch that was never completed so we need to cleanup here |
1783 // otherwise it will be done by the destructor in a wrong thread. | 1802 // otherwise it will be done by the destructor in a wrong thread. |
1784 TranslateService::Shutdown(parameters().ui_task == NULL); | 1803 TranslateService::Shutdown(parameters().ui_task == NULL); |
1785 | 1804 |
1786 if (notify_result_ == ProcessSingleton::PROCESS_NONE) | 1805 if (notify_result_ == ProcessSingleton::PROCESS_NONE) |
1787 process_singleton_->Cleanup(); | 1806 process_singleton_->Cleanup(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1822 chromeos::CrosSettings::Shutdown(); | 1841 chromeos::CrosSettings::Shutdown(); |
1823 #endif // defined(OS_CHROMEOS) | 1842 #endif // defined(OS_CHROMEOS) |
1824 #endif // defined(OS_ANDROID) | 1843 #endif // defined(OS_ANDROID) |
1825 } | 1844 } |
1826 | 1845 |
1827 // Public members: | 1846 // Public members: |
1828 | 1847 |
1829 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { | 1848 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { |
1830 chrome_extra_parts_.push_back(parts); | 1849 chrome_extra_parts_.push_back(parts); |
1831 } | 1850 } |
OLD | NEW |