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

Side by Side Diff: chrome/browser/chrome_browser_main_linux.cc

Issue 12334096: Regularize ownerships and lifecycle for storage monitor platform classes. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Document lifecycle in storage_monitor.h Created 7 years, 9 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/chrome_browser_main_linux.h" 5 #include "chrome/browser/chrome_browser_main_linux.h"
6 6
7 #include "base/message_loop_proxy.h" 7 #include "base/message_loop_proxy.h"
Lei Zhang 2013/03/01 04:40:15 message_loop_proxy.h is no longer needed. chrome_s
Greg Billock 2013/03/01 18:00:50 Done.
8 #include "chrome/browser/storage_monitor/media_transfer_protocol_device_observer _linux.h"
9 #include "chrome/common/chrome_switches.h" 8 #include "chrome/common/chrome_switches.h"
10 #include "device/media_transfer_protocol/media_transfer_protocol_manager.h"
11 9
12 #if !defined(OS_CHROMEOS) 10 #if !defined(OS_CHROMEOS)
13 #include "chrome/browser/storage_monitor/removable_device_notifications_linux.h" 11 #include "chrome/browser/storage_monitor/removable_device_notifications_linux.h"
14 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
15 #endif 13 #endif
16 14
17 #if defined(USE_LINUX_BREAKPAD) 15 #if defined(USE_LINUX_BREAKPAD)
18 #include <stdlib.h> 16 #include <stdlib.h>
19 17
20 #include "base/command_line.h" 18 #include "base/command_line.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 } 99 }
102 100
103 return breakpad_enabled; 101 return breakpad_enabled;
104 } 102 }
105 #endif // defined(USE_LINUX_BREAKPAD) 103 #endif // defined(USE_LINUX_BREAKPAD)
106 104
107 } // namespace 105 } // namespace
108 106
109 ChromeBrowserMainPartsLinux::ChromeBrowserMainPartsLinux( 107 ChromeBrowserMainPartsLinux::ChromeBrowserMainPartsLinux(
110 const content::MainFunctionParams& parameters) 108 const content::MainFunctionParams& parameters)
111 : ChromeBrowserMainPartsPosix(parameters), 109 : ChromeBrowserMainPartsPosix(parameters) {
112 initialized_media_transfer_protocol_manager_(false) {
113 } 110 }
114 111
115 ChromeBrowserMainPartsLinux::~ChromeBrowserMainPartsLinux() { 112 ChromeBrowserMainPartsLinux::~ChromeBrowserMainPartsLinux() {
116 if (initialized_media_transfer_protocol_manager_)
117 device::MediaTransferProtocolManager::Shutdown();
118 } 113 }
119 114
120 void ChromeBrowserMainPartsLinux::PreProfileInit() { 115 void ChromeBrowserMainPartsLinux::PreProfileInit() {
121 #if defined(USE_LINUX_BREAKPAD) 116 #if defined(USE_LINUX_BREAKPAD)
122 #if !defined(OS_CHROMEOS) 117 #if !defined(OS_CHROMEOS)
123 // Needs to be called after we have chrome::DIR_USER_DATA and 118 // Needs to be called after we have chrome::DIR_USER_DATA and
124 // g_browser_process. This happens in PreCreateThreads. 119 // g_browser_process. This happens in PreCreateThreads.
125 content::BrowserThread::PostTask(content::BrowserThread::FILE, 120 content::BrowserThread::PostTask(content::BrowserThread::FILE,
126 FROM_HERE, 121 FROM_HERE,
127 base::Bind(&GetLinuxDistroCallback)); 122 base::Bind(&GetLinuxDistroCallback));
128 #endif 123 #endif
129 124
130 if (IsCrashReportingEnabled(local_state())) 125 if (IsCrashReportingEnabled(local_state()))
131 InitCrashReporter(); 126 InitCrashReporter();
132 #endif 127 #endif
133 128
134 #if !defined(OS_CHROMEOS) 129 #if !defined(OS_CHROMEOS)
135 const base::FilePath kDefaultMtabPath("/etc/mtab"); 130 const base::FilePath kDefaultMtabPath("/etc/mtab");
136 removable_device_notifications_linux_ = 131 removable_device_notifications_linux_ =
137 new chrome::RemovableDeviceNotificationsLinux(kDefaultMtabPath); 132 new chrome::RemovableDeviceNotificationsLinux(kDefaultMtabPath);
138 removable_device_notifications_linux_->Init();
139 #endif 133 #endif
140 134
141 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType)) {
142 scoped_refptr<base::MessageLoopProxy> loop_proxy;
143 #if !defined(OS_CHROMEOS)
144 loop_proxy = content::BrowserThread::GetMessageLoopProxyForThread(
145 content::BrowserThread::FILE);
146 #endif
147 device::MediaTransferProtocolManager::Initialize(loop_proxy);
148 initialized_media_transfer_protocol_manager_ = true;
149 }
150
151 ChromeBrowserMainPartsPosix::PreProfileInit(); 135 ChromeBrowserMainPartsPosix::PreProfileInit();
152 } 136 }
153 137
154 void ChromeBrowserMainPartsLinux::PostProfileInit() { 138 void ChromeBrowserMainPartsLinux::PostProfileInit() {
155 // TODO(gbillock): Make this owned by RemovableDeviceNotificationsLinux. 139 #if !defined(OS_CHROMEOS)
156 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType)) { 140 removable_device_notifications_linux_->Init();
157 media_transfer_protocol_device_observer_.reset( 141 #endif
158 new chrome::MediaTransferProtocolDeviceObserverLinux());
159 media_transfer_protocol_device_observer_->SetNotifications(
160 chrome::StorageMonitor::GetInstance()->receiver());
161 }
162 142
163 ChromeBrowserMainPartsPosix::PostProfileInit(); 143 ChromeBrowserMainPartsPosix::PostProfileInit();
164 } 144 }
165 145
166 void ChromeBrowserMainPartsLinux::PostMainMessageLoopRun() { 146 void ChromeBrowserMainPartsLinux::PostMainMessageLoopRun() {
167 #if !defined(OS_CHROMEOS) 147 #if !defined(OS_CHROMEOS)
168 // Release it now. Otherwise the FILE thread would be gone when we try to 148 // Release it now. Otherwise the FILE thread would be gone when we try to
169 // release it in the dtor and Valgrind would report a leak on almost ever 149 // release it in the dtor and Valgrind would report a leak on almost ever
170 // single browser_test. 150 // single browser_test.
171 removable_device_notifications_linux_ = NULL; 151 removable_device_notifications_linux_ = NULL;
172 #endif 152 #endif
173 153
174 media_transfer_protocol_device_observer_.reset();
175
176 ChromeBrowserMainPartsPosix::PostMainMessageLoopRun(); 154 ChromeBrowserMainPartsPosix::PostMainMessageLoopRun();
177 } 155 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698