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

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

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

Powered by Google App Engine
This is Rietveld 408576698