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

Side by Side Diff: chrome/browser/storage_monitor/storage_monitor_linux.cc

Issue 13533009: Storage Monitor: Remove MediaTransferProtocolDeviceObserverLinux::GetInstance() and access it only … (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: rebase Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/storage_monitor/storage_monitor_chromeos.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // StorageMonitorLinux implementation. 5 // StorageMonitorLinux implementation.
6 6
7 #include "chrome/browser/storage_monitor/storage_monitor_linux.h" 7 #include "chrome/browser/storage_monitor/storage_monitor_linux.h"
8 8
9 #include <mntent.h> 9 #include <mntent.h>
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 base::Bind(&StorageMonitorLinux::OnMtabWatcherCreated, 251 base::Bind(&StorageMonitorLinux::OnMtabWatcherCreated,
252 weak_ptr_factory_.GetWeakPtr())); 252 weak_ptr_factory_.GetWeakPtr()));
253 253
254 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType)) { 254 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType)) {
255 scoped_refptr<base::MessageLoopProxy> loop_proxy; 255 scoped_refptr<base::MessageLoopProxy> loop_proxy;
256 loop_proxy = content::BrowserThread::GetMessageLoopProxyForThread( 256 loop_proxy = content::BrowserThread::GetMessageLoopProxyForThread(
257 content::BrowserThread::FILE); 257 content::BrowserThread::FILE);
258 device::MediaTransferProtocolManager::Initialize(loop_proxy); 258 device::MediaTransferProtocolManager::Initialize(loop_proxy);
259 259
260 media_transfer_protocol_device_observer_.reset( 260 media_transfer_protocol_device_observer_.reset(
261 new MediaTransferProtocolDeviceObserverLinux()); 261 new MediaTransferProtocolDeviceObserverLinux(receiver()));
262 media_transfer_protocol_device_observer_->SetNotifications(receiver());
263 } 262 }
264 } 263 }
265 264
266 bool StorageMonitorLinux::GetStorageInfoForPath( 265 bool StorageMonitorLinux::GetStorageInfoForPath(
267 const base::FilePath& path, 266 const base::FilePath& path,
268 StorageInfo* device_info) const { 267 StorageInfo* device_info) const {
269 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 268 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
270 269
270 // TODO(thestig) |media_transfer_protocol_device_observer_| should always be
271 // valid.
272 if (media_transfer_protocol_device_observer_ &&
273 media_transfer_protocol_device_observer_->GetStorageInfoForPath(
274 path, device_info)) {
275 return true;
276 }
277
271 if (!path.IsAbsolute()) 278 if (!path.IsAbsolute())
272 return false; 279 return false;
273 280
274 base::FilePath current = path; 281 base::FilePath current = path;
275 while (!ContainsKey(mount_info_map_, current) && current != current.DirName()) 282 while (!ContainsKey(mount_info_map_, current) && current != current.DirName())
276 current = current.DirName(); 283 current = current.DirName();
277 284
278 MountMap::const_iterator mount_info = mount_info_map_.find(current); 285 MountMap::const_iterator mount_info = mount_info_map_.find(current);
279 if (mount_info == mount_info_map_.end()) 286 if (mount_info == mount_info_map_.end())
280 return false; 287 return false;
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 437
431 if (removable) { 438 if (removable) {
432 // TODO(gbillock) Do this in a higher level instead of here. 439 // TODO(gbillock) Do this in a higher level instead of here.
433 storage_info->name = MediaStorageUtil::GetDisplayNameForDevice( 440 storage_info->name = MediaStorageUtil::GetDisplayNameForDevice(
434 storage_info->total_size_in_bytes, storage_info->name); 441 storage_info->total_size_in_bytes, storage_info->name);
435 receiver()->ProcessAttach(*storage_info); 442 receiver()->ProcessAttach(*storage_info);
436 } 443 }
437 } 444 }
438 445
439 } // namespace chrome 446 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/storage_monitor/storage_monitor_chromeos.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698