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

Side by Side Diff: chrome/browser/chromeos/disks/disk_mount_manager.cc

Issue 8499007: Add CrosDisksClient (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added comment, fix to compare strings in case sensitive way Created 9 years, 1 month 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/chromeos/disks/disk_mount_manager.h"
6
7 #include <map>
8 #include <set>
9
10 #include <sys/statvfs.h>
11
12 #include "base/bind.h"
13 #include "base/string_util.h"
14 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h"
15 #include "content/public/browser/browser_thread.h"
16
17 using content::BrowserThread;
18
19 namespace chromeos {
20 namespace disks {
21
22 namespace {
23
24 const char kDeviceNotFound[] = "Device could not be found";
25
26 DiskMountManager* g_disk_mount_manager = NULL;
27
28 // The DiskMountManager implementation.
29 class DiskMountManagerImpl : public DiskMountManager {
30 public:
31 DiskMountManagerImpl() : weak_ptr_factory_(this) {
32 DBusThreadManager* dbus_thread_manager = DBusThreadManager::Get();
33 DCHECK(dbus_thread_manager);
34 cros_disks_client_ = dbus_thread_manager->GetCrosDisksClient();
35 DCHECK(cros_disks_client_);
36
37 cros_disks_client_->SetUpConnections(
38 base::Bind(&DiskMountManagerImpl::OnMountEvent,
39 weak_ptr_factory_.GetWeakPtr()),
40 base::Bind(&DiskMountManagerImpl::OnMountCompleted,
41 weak_ptr_factory_.GetWeakPtr()));
42 }
43
44 virtual ~DiskMountManagerImpl() {
45 }
46
47 // DiskMountManager override.
48 virtual void AddObserver(Observer* observer) OVERRIDE {
49 observers_.AddObserver(observer);
50 }
51
52 // DiskMountManager override.
53 virtual void RemoveObserver(Observer* observer) OVERRIDE {
54 observers_.RemoveObserver(observer);
55 }
56
57 // DiskMountManager override.
58 virtual void MountPath(const std::string& source_path,
59 MountType type) OVERRIDE {
60 // Hidden and non-existent devices should not be mounted.
61 if (type == MOUNT_TYPE_DEVICE) {
62 DiskMap::const_iterator it = disks_.find(source_path);
63 if (it == disks_.end() || it->second->is_hidden()) {
64 OnMountCompleted(MOUNT_ERROR_INTERNAL, source_path, type, "");
65 return;
66 }
67 }
68 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
69 cros_disks_client_->Mount(
70 source_path,
71 type,
72 // When succeeds, OnMountCompleted will be called by
73 // "MountCompleted" signal instead.
74 base::Bind(&DoNothing),
75 base::Bind(&DiskMountManagerImpl::OnMountCompleted,
76 weak_ptr_factory_.GetWeakPtr(),
77 MOUNT_ERROR_INTERNAL,
78 source_path,
79 type,
80 ""));
81 }
82
83 // DiskMountManager override.
84 virtual void UnmountPath(const std::string& mount_path) OVERRIDE {
85 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
86 cros_disks_client_->Unmount(mount_path,
87 base::Bind(&DiskMountManagerImpl::OnUnmountPath,
88 weak_ptr_factory_.GetWeakPtr()),
89 base::Bind(&DoNothing));
90 }
91
92 // DiskMountManager override.
93 virtual void GetSizeStatsOnFileThread(const std::string& mount_path,
94 size_t* total_size_kb,
95 size_t* remaining_size_kb) OVERRIDE {
96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
97
98 uint64_t total_size_in_bytes = 0;
99 uint64_t remaining_size_in_bytes = 0;
100
101 struct statvfs stat = {}; // Zero-clear
102 if (statvfs(mount_path.c_str(), &stat) == 0) {
103 total_size_in_bytes =
104 static_cast<uint64_t>(stat.f_blocks) * stat.f_frsize;
105 remaining_size_in_bytes =
106 static_cast<uint64_t>(stat.f_bfree) * stat.f_frsize;
107 }
108 *total_size_kb = static_cast<size_t>(total_size_in_bytes / 1024);
109 *remaining_size_kb = static_cast<size_t>(remaining_size_in_bytes / 1024);
110 }
111
112 // DiskMountManager override.
113 virtual void FormatUnmountedDevice(const std::string& file_path) OVERRIDE {
114 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
115 for (DiskMountManager::DiskMap::iterator it = disks_.begin();
116 it != disks_.end(); ++it) {
117 if (it->second->file_path() == file_path &&
118 !it->second->mount_path().empty()) {
119 LOG(ERROR) << "Device is still mounted: " << file_path;
120 OnFormatDevice(file_path, false);
121 return;
122 }
123 }
124 const char kFormatVFAT[] = "vfat";
125 cros_disks_client_->FormatDevice(
126 file_path,
127 kFormatVFAT,
128 base::Bind(&DiskMountManagerImpl::OnFormatDevice,
129 weak_ptr_factory_.GetWeakPtr()),
130 base::Bind(&DiskMountManagerImpl::OnFormatDevice,
131 weak_ptr_factory_.GetWeakPtr(),
132 file_path,
133 false));
134 }
135
136 // DiskMountManager override.
137 virtual void FormatMountedDevice(const std::string& mount_path) OVERRIDE {
138 Disk* disk = NULL;
139 for (DiskMountManager::DiskMap::iterator it = disks_.begin();
140 it != disks_.end(); ++it) {
141 if (it->second->mount_path() == mount_path) {
142 disk = it->second;
143 break;
144 }
145 }
146 if (!disk) {
147 LOG(ERROR) << "Device with this mount path not found: " << mount_path;
148 OnFormatDevice(mount_path, false);
149 return;
150 }
151 if (formatting_pending_.find(disk->device_path()) !=
152 formatting_pending_.end()) {
153 LOG(ERROR) << "Formatting is already pending: " << mount_path;
154 OnFormatDevice(mount_path, false);
155 return;
156 }
157 // Formatting process continues, after unmounting.
158 formatting_pending_[disk->device_path()] = disk->file_path();
159 UnmountPath(disk->mount_path());
160 }
161
162 // DiskMountManager override.
163 virtual void UnmountDeviceRecursive(
164 const std::string& device_path,
165 UnmountDeviceRecursiveCallbackType callback,
166 void* user_data) OVERRIDE {
167 bool success = true;
168 std::string error_message;
169 std::vector<std::string> devices_to_unmount;
170
171 // Get list of all devices to unmount.
172 int device_path_len = device_path.length();
173 for (DiskMap::iterator it = disks_.begin(); it != disks_.end(); ++it) {
174 if (!it->second->mount_path().empty() &&
175 strncmp(device_path.c_str(), it->second->device_path().c_str(),
176 device_path_len) == 0) {
177 devices_to_unmount.push_back(it->second->mount_path());
178 }
179 }
180 // We should detect at least original device.
181 if (devices_to_unmount.empty()) {
182 if (disks_.find(device_path) == disks_.end()) {
183 success = false;
184 error_message = kDeviceNotFound;
185 } else {
186 // Nothing to unmount.
187 callback(user_data, true);
188 return;
189 }
190 }
191 if (success) {
192 // We will send the same callback data object to all Unmount calls and use
193 // it to syncronize callbacks.
194 UnmountDeviceRecursiveCallbackData* cb_data =
195 new UnmountDeviceRecursiveCallbackData(user_data, callback,
196 devices_to_unmount.size());
197 for (size_t i = 0; i < devices_to_unmount.size(); ++i) {
198 cros_disks_client_->Unmount(
199 devices_to_unmount[i],
200 base::Bind(&DiskMountManagerImpl::OnUnmountDeviceRecursive,
201 weak_ptr_factory_.GetWeakPtr(), cb_data, true),
202 base::Bind(&DiskMountManagerImpl::OnUnmountDeviceRecursive,
203 weak_ptr_factory_.GetWeakPtr(),
204 cb_data,
205 false,
206 devices_to_unmount[i]));
207 }
208 } else {
209 LOG(WARNING) << "Unmount recursive request failed for device "
210 << device_path << ", with error: " << error_message;
211 callback(user_data, false);
212 }
213 }
214
215 // DiskMountManager override.
216 virtual void RequestMountInfoRefresh() OVERRIDE {
217 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
218 cros_disks_client_->EnumerateAutoMountableDevices(
219 base::Bind(&DiskMountManagerImpl::OnRequestMountInfo,
220 weak_ptr_factory_.GetWeakPtr()),
221 base::Bind(&DoNothing));
222 }
223
224 // DiskMountManager override.
225 const DiskMap& disks() const OVERRIDE { return disks_; }
226
227
228 // DiskMountManager override.
229 const MountPointMap& mount_points() const OVERRIDE { return mount_points_; }
230
231 private:
232 struct UnmountDeviceRecursiveCallbackData {
233 void* user_data;
234 UnmountDeviceRecursiveCallbackType callback;
235 size_t pending_callbacks_count;
236
237 UnmountDeviceRecursiveCallbackData(void* ud,
238 UnmountDeviceRecursiveCallbackType cb,
239 int count)
240 : user_data(ud),
241 callback(cb),
242 pending_callbacks_count(count) {
243 }
244 };
245
246 // Callback for UnmountDeviceRecursive.
247 void OnUnmountDeviceRecursive(UnmountDeviceRecursiveCallbackData* cb_data,
248 bool success,
249 const std::string& mount_path) {
250 if (success) {
251 // Do standard processing for Unmount event.
252 OnUnmountPath(mount_path);
253 LOG(INFO) << mount_path << " unmounted.";
254 }
255 // This is safe as long as all callbacks are called on the same thread as
256 // UnmountDeviceRecursive.
257 cb_data->pending_callbacks_count--;
258
259 if (cb_data->pending_callbacks_count == 0) {
260 cb_data->callback(cb_data->user_data, success);
261 delete cb_data;
262 }
263 }
264
265 // Callback to handle MountCompleted signal and Mount method call failure.
266 void OnMountCompleted(MountError error_code,
267 const std::string& source_path,
268 MountType mount_type,
269 const std::string& mount_path) {
270 MountCondition mount_condition = MOUNT_CONDITION_NONE;
271 if (mount_type == MOUNT_TYPE_DEVICE) {
272 if (error_code == MOUNT_ERROR_UNKNOWN_FILESYSTEM)
273 mount_condition = MOUNT_CONDITION_UNKNOWN_FILESYSTEM;
274 if (error_code == MOUNT_ERROR_UNSUPORTED_FILESYSTEM)
275 mount_condition = MOUNT_CONDITION_UNSUPPORTED_FILESYSTEM;
276 }
277 const MountPointInfo mount_info(source_path, mount_path, mount_type,
278 mount_condition);
279
280 NotifyMountCompleted(MOUNTING, error_code, mount_info);
281
282 // If the device is corrupted but it's still possible to format it, it will
283 // be fake mounted.
284 if ((error_code == MOUNT_ERROR_NONE || mount_info.mount_condition) &&
285 mount_points_.find(mount_info.mount_path) == mount_points_.end()) {
286 mount_points_.insert(MountPointMap::value_type(mount_info.mount_path,
287 mount_info));
288 }
289 if ((error_code == MOUNT_ERROR_NONE || mount_info.mount_condition) &&
290 mount_info.mount_type == MOUNT_TYPE_DEVICE &&
291 !mount_info.source_path.empty() &&
292 !mount_info.mount_path.empty()) {
293 DiskMap::iterator iter = disks_.find(mount_info.source_path);
294 if (iter == disks_.end()) {
295 // disk might have been removed by now?
296 return;
297 }
298 Disk* disk = iter->second;
299 DCHECK(disk);
300 disk->set_mount_path(mount_info.mount_path);
301 NotifyDiskStatusUpdate(MOUNT_DISK_MOUNTED, disk);
302 }
303 }
304
305 // Callback for UnmountPath.
306 void OnUnmountPath(const std::string& mount_path) {
307 MountPointMap::iterator mount_points_it = mount_points_.find(mount_path);
308 if (mount_points_it == mount_points_.end())
309 return;
310 // TODO(tbarzic): Add separate, PathUnmounted event to Observer.
311 NotifyMountCompleted(UNMOUNTING,
312 MOUNT_ERROR_NONE,
313 MountPointInfo(mount_points_it->second.source_path,
314 mount_points_it->second.mount_path,
315 mount_points_it->second.mount_type,
316 mount_points_it->second.mount_condition)
317 );
318 std::string path(mount_points_it->second.source_path);
319 mount_points_.erase(mount_points_it);
320 DiskMap::iterator iter = disks_.find(path);
321 if (iter == disks_.end()) {
322 // disk might have been removed by now.
323 return;
324 }
325 Disk* disk = iter->second;
326 DCHECK(disk);
327 disk->clear_mount_path();
328 // Check if there is a formatting scheduled.
329 PathMap::iterator it = formatting_pending_.find(disk->device_path());
330 if (it != formatting_pending_.end()) {
331 const std::string& file_path = it->second;
332 formatting_pending_.erase(it);
333 FormatUnmountedDevice(file_path);
334 }
335 }
336
337 // Callback for FormatDevice.
338 void OnFormatDevice(const std::string& device_path, bool success) {
339 if (success) {
340 NotifyDeviceStatusUpdate(MOUNT_FORMATTING_STARTED, device_path);
341 } else {
342 NotifyDeviceStatusUpdate(MOUNT_FORMATTING_STARTED,
343 std::string("!") + device_path);
344 LOG(WARNING) << "Format request failed for device " << device_path;
345 }
346 }
347
348 // Callbcak for GetDeviceProperties.
349 void OnGetDeviceProperties(const DiskInfo& disk_info) {
350 // TODO(zelidrag): Find a better way to filter these out before we
351 // fetch the properties:
352 // Ignore disks coming from the device we booted the system from.
353 if (disk_info.on_boot_device())
354 return;
355
356 LOG(WARNING) << "Found disk " << disk_info.device_path();
357 // Delete previous disk info for this path:
358 bool is_new = true;
359 DiskMap::iterator iter = disks_.find(disk_info.device_path());
360 if (iter != disks_.end()) {
361 delete iter->second;
362 disks_.erase(iter);
363 is_new = false;
364 }
365 Disk* disk = new Disk(disk_info.device_path(),
366 disk_info.mount_path(),
367 disk_info.system_path(),
368 disk_info.file_path(),
369 disk_info.label(),
370 disk_info.drive_label(),
371 FindSystemPathPrefix(disk_info.system_path()),
372 disk_info.device_type(),
373 disk_info.total_size_in_bytes(),
374 disk_info.is_drive(),
375 disk_info.is_read_only(),
376 disk_info.has_media(),
377 disk_info.on_boot_device(),
378 disk_info.is_hidden());
379 disks_.insert(std::make_pair(disk_info.device_path(), disk));
380 NotifyDiskStatusUpdate(is_new ? MOUNT_DISK_ADDED : MOUNT_DISK_CHANGED,
381 disk);
382 }
383
384 // Callbcak for RequestMountInfo.
385 void OnRequestMountInfo(const std::vector<std::string>& devices) {
386 std::set<std::string> current_device_set;
387 if (!devices.empty()) {
388 // Initiate properties fetch for all removable disks,
389 for (size_t i = 0; i < devices.size(); i++) {
390 current_device_set.insert(devices[i]);
391 // Initiate disk property retrieval for each relevant device path.
392 cros_disks_client_->GetDeviceProperties(
393 devices[i],
394 base::Bind(&DiskMountManagerImpl::OnGetDeviceProperties,
395 weak_ptr_factory_.GetWeakPtr()),
396 base::Bind(&DoNothing));
397 }
398 }
399 // Search and remove disks that are no longer present.
400 for (DiskMap::iterator iter = disks_.begin(); iter != disks_.end(); ) {
401 if (current_device_set.find(iter->first) == current_device_set.end()) {
402 Disk* disk = iter->second;
403 NotifyDiskStatusUpdate(MOUNT_DISK_REMOVED, disk);
404 delete iter->second;
405 disks_.erase(iter++);
406 } else {
407 ++iter;
408 }
409 }
410 }
411
412 // Callback to handle mount event signals.
413 void OnMountEvent(MountEventType event, std::string device_path) {
414 DiskMountManagerEventType type = MOUNT_DEVICE_ADDED;
415 switch (event) {
416 case DISK_ADDED: {
417 cros_disks_client_->GetDeviceProperties(
418 device_path,
419 base::Bind(&DiskMountManagerImpl::OnGetDeviceProperties,
420 weak_ptr_factory_.GetWeakPtr()),
421 base::Bind(&DoNothing));
422 return;
423 }
424 case DISK_REMOVED: {
425 // Search and remove disks that are no longer present.
426 DiskMountManager::DiskMap::iterator iter = disks_.find(device_path);
427 if (iter != disks_.end()) {
428 Disk* disk = iter->second;
429 NotifyDiskStatusUpdate(MOUNT_DISK_REMOVED, disk);
430 delete iter->second;
431 disks_.erase(iter);
432 }
433 return;
434 }
435 case DEVICE_ADDED: {
436 type = MOUNT_DEVICE_ADDED;
437 system_path_prefixes_.insert(device_path);
438 break;
439 }
440 case DEVICE_REMOVED: {
441 type = MOUNT_DEVICE_REMOVED;
442 system_path_prefixes_.erase(device_path);
443 break;
444 }
445 case DEVICE_SCANNED: {
446 type = MOUNT_DEVICE_SCANNED;
447 break;
448 }
449 case FORMATTING_FINISHED: {
450 // FORMATTING_FINISHED actually returns file path instead of device
451 // path.
452 device_path = FilePathToDevicePath(device_path);
453 if (device_path.empty()) {
454 LOG(ERROR) << "Error while handling disks metadata. Cannot find "
455 << "device that is being formatted.";
456 return;
457 }
458 type = MOUNT_FORMATTING_FINISHED;
459 break;
460 }
461 default: {
462 LOG(ERROR) << "Unknown event: " << event;
463 return;
464 }
465 }
466 NotifyDeviceStatusUpdate(type, device_path);
467 }
468
469 // Notifies all observers about disk status update.
470 void NotifyDiskStatusUpdate(DiskMountManagerEventType event,
471 const Disk* disk) {
472 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
473 FOR_EACH_OBSERVER(Observer, observers_, DiskChanged(event, disk));
474 }
475
476 // Notifies all observers about device status update.
477 void NotifyDeviceStatusUpdate(DiskMountManagerEventType event,
478 const std::string& device_path) {
479 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
480 FOR_EACH_OBSERVER(Observer, observers_, DeviceChanged(event, device_path));
481 }
482
483 // Notifies all observers about mount completion.
484 void NotifyMountCompleted(MountEvent event_type,
485 MountError error_code,
486 const MountPointInfo& mount_info) {
487 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
488 FOR_EACH_OBSERVER(Observer, observers_,
489 MountCompleted(event_type, error_code, mount_info));
490 }
491
492 // Converts file path to device path.
493 std::string FilePathToDevicePath(const std::string& file_path) {
494 // TODO(hashimoto): Refactor error handling code like here.
495 // Appending "!" is not the best way to indicate error. This kind of trick
496 // also makes it difficult to simplify the code paths. crosbug.com/22972
497 const int failed = StartsWithASCII(file_path, "!", true);
498 for (DiskMountManager::DiskMap::iterator it = disks_.begin();
499 it != disks_.end(); ++it) {
500 // Skip the leading '!' on the failure case.
501 if (it->second->file_path() == file_path.substr(failed)) {
502 if (failed)
503 return std::string("!") + it->second->device_path();
504 else
505 return it->second->device_path();
506 }
507 }
508 return "";
509 }
510
511 // Finds system path prefix from |system_path|.
512 const std::string& FindSystemPathPrefix(const std::string& system_path) {
513 if (system_path.empty())
514 return EmptyString();
515 for (SystemPathPrefixSet::const_iterator it = system_path_prefixes_.begin();
516 it != system_path_prefixes_.end();
517 ++it) {
518 const std::string& prefix = *it;
519 if (StartsWithASCII(system_path, prefix, true))
520 return prefix;
521 }
522 return EmptyString();
523 }
524
525 // A function to be used as an empty callback.
526 static void DoNothing() {
527 }
528
529 // Mount event change observers.
530 ObserverList<Observer> observers_;
531
532 CrosDisksClient* cros_disks_client_;
533
534 // The list of disks found.
535 DiskMountManager::DiskMap disks_;
536
537 DiskMountManager::MountPointMap mount_points_;
538
539 typedef std::set<std::string> SystemPathPrefixSet;
540 SystemPathPrefixSet system_path_prefixes_;
541
542 // A map from device path (e.g. /sys/devices/pci0000:00/.../sdb/sdb1)) to file
543 // path (e.g. /dev/sdb).
544 // Devices in this map are supposed to be formatted, but are currently waiting
545 // to be unmounted. When device is in this map, the formatting process HAVEN'T
546 // started yet.
547 typedef std::map<std::string, std::string> PathMap;
548 PathMap formatting_pending_;
549
550 base::WeakPtrFactory<DiskMountManagerImpl> weak_ptr_factory_;
551
552 DISALLOW_COPY_AND_ASSIGN(DiskMountManagerImpl);
553 };
554
555 } // namespace
556
557 DiskMountManager::Disk::Disk(const std::string& device_path,
558 const std::string& mount_path,
559 const std::string& system_path,
560 const std::string& file_path,
561 const std::string& device_label,
562 const std::string& drive_label,
563 const std::string& system_path_prefix,
564 DeviceType device_type,
565 uint64 total_size_in_bytes,
566 bool is_parent,
567 bool is_read_only,
568 bool has_media,
569 bool on_boot_device,
570 bool is_hidden)
571 : device_path_(device_path),
572 mount_path_(mount_path),
573 system_path_(system_path),
574 file_path_(file_path),
575 device_label_(device_label),
576 drive_label_(drive_label),
577 system_path_prefix_(system_path_prefix),
578 device_type_(device_type),
579 total_size_in_bytes_(total_size_in_bytes),
580 is_parent_(is_parent),
581 is_read_only_(is_read_only),
582 has_media_(has_media),
583 on_boot_device_(on_boot_device),
584 is_hidden_(is_hidden) {
585 }
586
587 DiskMountManager::Disk::~Disk() {}
588
589 // static
590 std::string DiskMountManager::MountTypeToString(MountType type) {
591 switch (type) {
592 case MOUNT_TYPE_DEVICE:
593 return "device";
594 case MOUNT_TYPE_ARCHIVE:
595 return "file";
596 case MOUNT_TYPE_NETWORK_STORAGE:
597 return "network";
598 case MOUNT_TYPE_INVALID:
599 return "invalid";
600 default:
601 NOTREACHED();
602 }
603 return "";
604 }
605
606 // static
607 std::string DiskMountManager::MountConditionToString(MountCondition condition) {
608 switch (condition) {
609 case MOUNT_CONDITION_NONE:
610 return "";
611 case MOUNT_CONDITION_UNKNOWN_FILESYSTEM:
612 return "unknown_filesystem";
613 case MOUNT_CONDITION_UNSUPPORTED_FILESYSTEM:
614 return "unsupported_filesystem";
615 default:
616 NOTREACHED();
617 }
618 return "";
619 }
620
621 // static
622 MountType DiskMountManager::MountTypeFromString(const std::string& type_str) {
623 if (type_str == "device")
624 return MOUNT_TYPE_DEVICE;
625 else if (type_str == "network")
626 return MOUNT_TYPE_NETWORK_STORAGE;
627 else if (type_str == "file")
628 return MOUNT_TYPE_ARCHIVE;
629 else
630 return MOUNT_TYPE_INVALID;
631 }
632
633 // static
634 void DiskMountManager::Initialize() {
635 VLOG(1) << "DiskMountManager::Initialize";
636 DCHECK(!g_disk_mount_manager);
637 g_disk_mount_manager = new DiskMountManagerImpl();
638 DCHECK(g_disk_mount_manager);
639 }
640
641 // static
642 void DiskMountManager::Shutdown() {
643 VLOG(1) << "DiskMountManager::Shutdown";
644 if (g_disk_mount_manager) {
645 delete g_disk_mount_manager;
646 g_disk_mount_manager = NULL;
647 }
648 }
649
650 // static
651 DiskMountManager* DiskMountManager::GetInstance() {
652 return g_disk_mount_manager;
653 }
654
655 } // namespace disks
656 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/disks/disk_mount_manager.h ('k') | chrome/browser/chromeos/disks/mock_disk_mount_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698