OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chromeos/dbus/fake_cros_disks_client.h" | 5 #include "chromeos/dbus/fake_cros_disks_client.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 | 75 |
76 void FakeCrosDisksClient::Init(dbus::Bus* bus) { | 76 void FakeCrosDisksClient::Init(dbus::Bus* bus) { |
77 } | 77 } |
78 | 78 |
79 void FakeCrosDisksClient::Mount(const std::string& source_path, | 79 void FakeCrosDisksClient::Mount(const std::string& source_path, |
80 const std::string& source_format, | 80 const std::string& source_format, |
81 const std::string& mount_label, | 81 const std::string& mount_label, |
82 MountAccessMode access_mode, | 82 MountAccessMode access_mode, |
83 const base::Closure& callback, | 83 const base::Closure& callback, |
84 const base::Closure& error_callback) { | 84 const base::Closure& error_callback) { |
85 // This fake implementation only accepts archive mount requests. | 85 // This fake implementation assumes mounted path is device when source_format |
86 const MountType type = MOUNT_TYPE_ARCHIVE; | 86 // is empty, or an archive otherwise. |
| 87 MountType type = |
| 88 (source_format == "") ? MOUNT_TYPE_DEVICE : MOUNT_TYPE_ARCHIVE; |
87 | 89 |
88 const base::FilePath mounted_path = GetArchiveMountPoint().Append( | 90 base::FilePath mounted_path; |
89 base::FilePath::FromUTF8Unsafe(mount_label)); | 91 switch (type) { |
| 92 case MOUNT_TYPE_ARCHIVE: |
| 93 mounted_path = GetArchiveMountPoint().Append( |
| 94 base::FilePath::FromUTF8Unsafe(mount_label)); |
| 95 break; |
| 96 case MOUNT_TYPE_DEVICE: |
| 97 mounted_path = GetRemovableDiskMountPoint().Append( |
| 98 base::FilePath::FromUTF8Unsafe(mount_label)); |
| 99 break; |
| 100 case MOUNT_TYPE_INVALID: |
| 101 // Unreachable |
| 102 return; |
| 103 } |
90 mounted_paths_.insert(mounted_path); | 104 mounted_paths_.insert(mounted_path); |
91 | 105 |
92 base::PostTaskAndReplyWithResult( | 106 base::PostTaskAndReplyWithResult( |
93 base::WorkerPool::GetTaskRunner(true /* task_is_slow */).get(), | 107 base::WorkerPool::GetTaskRunner(true /* task_is_slow */).get(), |
94 FROM_HERE, | 108 FROM_HERE, |
95 base::Bind(&PerformFakeMount, source_path, mounted_path), | 109 base::Bind(&PerformFakeMount, source_path, mounted_path), |
96 base::Bind(&DidMount, | 110 base::Bind(&DidMount, |
97 mount_completed_handler_, | 111 mount_completed_handler_, |
98 source_path, | 112 source_path, |
99 type, | 113 type, |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 bool FakeCrosDisksClient::SendFormatCompletedEvent( | 214 bool FakeCrosDisksClient::SendFormatCompletedEvent( |
201 FormatError error_code, | 215 FormatError error_code, |
202 const std::string& device_path) { | 216 const std::string& device_path) { |
203 if (format_completed_handler_.is_null()) | 217 if (format_completed_handler_.is_null()) |
204 return false; | 218 return false; |
205 format_completed_handler_.Run(error_code, device_path); | 219 format_completed_handler_.Run(error_code, device_path); |
206 return true; | 220 return true; |
207 } | 221 } |
208 | 222 |
209 } // namespace chromeos | 223 } // namespace chromeos |
OLD | NEW |