| 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_linux.h" | 5 #include "chrome/browser/chrome_browser_main_linux.h" |
| 6 | 6 |
| 7 #include "base/message_loop_proxy.h" | |
| 8 #include "chrome/browser/storage_monitor/media_transfer_protocol_device_observer
_linux.h" | |
| 9 #include "chrome/common/chrome_switches.h" | |
| 10 #include "device/media_transfer_protocol/media_transfer_protocol_manager.h" | |
| 11 | |
| 12 #if !defined(OS_CHROMEOS) | 7 #if !defined(OS_CHROMEOS) |
| 13 #include "chrome/browser/storage_monitor/storage_monitor_linux.h" | 8 #include "chrome/browser/storage_monitor/storage_monitor_linux.h" |
| 14 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
| 15 #endif | 10 #endif |
| 16 | 11 |
| 17 #if defined(USE_LINUX_BREAKPAD) | 12 #if defined(USE_LINUX_BREAKPAD) |
| 18 #include <stdlib.h> | 13 #include <stdlib.h> |
| 19 | 14 |
| 20 #include "base/command_line.h" | 15 #include "base/command_line.h" |
| 21 #include "base/linux_util.h" | 16 #include "base/linux_util.h" |
| 22 #include "base/prefs/pref_service.h" | 17 #include "base/prefs/pref_service.h" |
| 23 #include "chrome/app/breakpad_linux.h" | 18 #include "chrome/app/breakpad_linux.h" |
| 19 #include "chrome/common/chrome_switches.h" |
| 24 #include "chrome/common/env_vars.h" | 20 #include "chrome/common/env_vars.h" |
| 25 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
| 26 | 22 |
| 27 #if defined(OS_CHROMEOS) | 23 #if defined(OS_CHROMEOS) |
| 28 #include "chrome/browser/chromeos/settings/cros_settings.h" | 24 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 29 #include "chrome/browser/chromeos/settings/cros_settings_names.h" | 25 #include "chrome/browser/chromeos/settings/cros_settings_names.h" |
| 30 #include "chrome/common/chrome_version_info.h" | 26 #include "chrome/common/chrome_version_info.h" |
| 31 #endif | 27 #endif |
| 32 | 28 |
| 33 #endif // defined(USE_LINUX_BREAKPAD) | 29 #endif // defined(USE_LINUX_BREAKPAD) |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 } | 97 } |
| 102 | 98 |
| 103 return breakpad_enabled; | 99 return breakpad_enabled; |
| 104 } | 100 } |
| 105 #endif // defined(USE_LINUX_BREAKPAD) | 101 #endif // defined(USE_LINUX_BREAKPAD) |
| 106 | 102 |
| 107 } // namespace | 103 } // namespace |
| 108 | 104 |
| 109 ChromeBrowserMainPartsLinux::ChromeBrowserMainPartsLinux( | 105 ChromeBrowserMainPartsLinux::ChromeBrowserMainPartsLinux( |
| 110 const content::MainFunctionParams& parameters) | 106 const content::MainFunctionParams& parameters) |
| 111 : ChromeBrowserMainPartsPosix(parameters), | 107 : ChromeBrowserMainPartsPosix(parameters) { |
| 112 initialized_media_transfer_protocol_manager_(false) { | |
| 113 } | 108 } |
| 114 | 109 |
| 115 ChromeBrowserMainPartsLinux::~ChromeBrowserMainPartsLinux() { | 110 ChromeBrowserMainPartsLinux::~ChromeBrowserMainPartsLinux() { |
| 116 if (initialized_media_transfer_protocol_manager_) | |
| 117 device::MediaTransferProtocolManager::Shutdown(); | |
| 118 } | 111 } |
| 119 | 112 |
| 120 void ChromeBrowserMainPartsLinux::PreProfileInit() { | 113 void ChromeBrowserMainPartsLinux::PreProfileInit() { |
| 121 #if defined(USE_LINUX_BREAKPAD) | 114 #if defined(USE_LINUX_BREAKPAD) |
| 122 #if !defined(OS_CHROMEOS) | 115 #if !defined(OS_CHROMEOS) |
| 123 // Needs to be called after we have chrome::DIR_USER_DATA and | 116 // Needs to be called after we have chrome::DIR_USER_DATA and |
| 124 // g_browser_process. This happens in PreCreateThreads. | 117 // g_browser_process. This happens in PreCreateThreads. |
| 125 content::BrowserThread::PostTask(content::BrowserThread::FILE, | 118 content::BrowserThread::PostTask(content::BrowserThread::FILE, |
| 126 FROM_HERE, | 119 FROM_HERE, |
| 127 base::Bind(&GetLinuxDistroCallback)); | 120 base::Bind(&GetLinuxDistroCallback)); |
| 128 #endif | 121 #endif |
| 129 | 122 |
| 130 if (IsCrashReportingEnabled(local_state())) | 123 if (IsCrashReportingEnabled(local_state())) |
| 131 InitCrashReporter(); | 124 InitCrashReporter(); |
| 132 #endif | 125 #endif |
| 133 | 126 |
| 134 #if !defined(OS_CHROMEOS) | 127 #if !defined(OS_CHROMEOS) |
| 135 const base::FilePath kDefaultMtabPath("/etc/mtab"); | 128 const base::FilePath kDefaultMtabPath("/etc/mtab"); |
| 136 storage_monitor_ = new chrome::StorageMonitorLinux(kDefaultMtabPath); | 129 storage_monitor_ = new chrome::StorageMonitorLinux(kDefaultMtabPath); |
| 137 storage_monitor_->Init(); | |
| 138 #endif | 130 #endif |
| 139 | 131 |
| 140 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType)) { | |
| 141 scoped_refptr<base::MessageLoopProxy> loop_proxy; | |
| 142 #if !defined(OS_CHROMEOS) | |
| 143 loop_proxy = content::BrowserThread::GetMessageLoopProxyForThread( | |
| 144 content::BrowserThread::FILE); | |
| 145 #endif | |
| 146 device::MediaTransferProtocolManager::Initialize(loop_proxy); | |
| 147 initialized_media_transfer_protocol_manager_ = true; | |
| 148 } | |
| 149 | |
| 150 ChromeBrowserMainPartsPosix::PreProfileInit(); | 132 ChromeBrowserMainPartsPosix::PreProfileInit(); |
| 151 } | 133 } |
| 152 | 134 |
| 153 void ChromeBrowserMainPartsLinux::PostProfileInit() { | 135 void ChromeBrowserMainPartsLinux::PostProfileInit() { |
| 154 // TODO(gbillock): Make this owned by StorageMonitorLinux. | 136 #if !defined(OS_CHROMEOS) |
| 155 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType)) { | 137 storage_monitor_->Init(); |
| 156 media_transfer_protocol_device_observer_.reset( | 138 #endif |
| 157 new chrome::MediaTransferProtocolDeviceObserverLinux()); | |
| 158 media_transfer_protocol_device_observer_->SetNotifications( | |
| 159 chrome::StorageMonitor::GetInstance()->receiver()); | |
| 160 } | |
| 161 | 139 |
| 162 ChromeBrowserMainPartsPosix::PostProfileInit(); | 140 ChromeBrowserMainPartsPosix::PostProfileInit(); |
| 163 } | 141 } |
| 164 | 142 |
| 165 void ChromeBrowserMainPartsLinux::PostMainMessageLoopRun() { | 143 void ChromeBrowserMainPartsLinux::PostMainMessageLoopRun() { |
| 166 #if !defined(OS_CHROMEOS) | 144 #if !defined(OS_CHROMEOS) |
| 167 // Release it now. Otherwise the FILE thread would be gone when we try to | 145 // Release it now. Otherwise the FILE thread would be gone when we try to |
| 168 // release it in the dtor and Valgrind would report a leak on almost ever | 146 // release it in the dtor and Valgrind would report a leak on almost ever |
| 169 // single browser_test. | 147 // single browser_test. |
| 170 storage_monitor_ = NULL; | 148 storage_monitor_ = NULL; |
| 171 #endif | 149 #endif |
| 172 | 150 |
| 173 media_transfer_protocol_device_observer_.reset(); | |
| 174 | |
| 175 ChromeBrowserMainPartsPosix::PostMainMessageLoopRun(); | 151 ChromeBrowserMainPartsPosix::PostMainMessageLoopRun(); |
| 176 } | 152 } |
| OLD | NEW |