OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/utility/image_writer/disk_unmounter_mac.h" | 5 #include "chrome/utility/image_writer/disk_unmounter_mac.h" |
6 | 6 |
7 #include <IOKit/storage/IOStorageProtocolCharacteristics.h> | 7 #include <IOKit/storage/IOStorageProtocolCharacteristics.h> |
8 #include <sys/socket.h> | 8 #include <sys/socket.h> |
9 | 9 |
10 #include "base/message_loop/message_pump_mac.h" | 10 #include "base/message_loop/message_pump_mac.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 disk_unmounter->original_thread_->PostTask( | 86 disk_unmounter->original_thread_->PostTask( |
87 FROM_HERE, disk_unmounter->success_continuation_); | 87 FROM_HERE, disk_unmounter->success_continuation_); |
88 } | 88 } |
89 | 89 |
90 // static | 90 // static |
91 std::unique_ptr<base::MessagePump> DiskUnmounterMac::CreateMessagePump() { | 91 std::unique_ptr<base::MessagePump> DiskUnmounterMac::CreateMessagePump() { |
92 return std::unique_ptr<base::MessagePump>(new base::MessagePumpCFRunLoop); | 92 return std::unique_ptr<base::MessagePump>(new base::MessagePumpCFRunLoop); |
93 } | 93 } |
94 | 94 |
95 void DiskUnmounterMac::UnmountOnWorker(const std::string& device_path) { | 95 void DiskUnmounterMac::UnmountOnWorker(const std::string& device_path) { |
96 DCHECK(cf_thread_.message_loop() == base::MessageLoop::current()); | 96 DCHECK(cf_thread_.task_runner()->BelongsToCurrentThread()); |
97 | 97 |
98 session_.reset(DASessionCreate(NULL)); | 98 session_.reset(DASessionCreate(NULL)); |
99 | 99 |
100 DASessionScheduleWithRunLoop( | 100 DASessionScheduleWithRunLoop( |
101 session_, CFRunLoopGetCurrent(), kCFRunLoopCommonModes); | 101 session_, CFRunLoopGetCurrent(), kCFRunLoopCommonModes); |
102 | 102 |
103 disk_.reset(DADiskCreateFromBSDName( | 103 disk_.reset(DADiskCreateFromBSDName( |
104 kCFAllocatorDefault, session_, device_path.c_str())); | 104 kCFAllocatorDefault, session_, device_path.c_str())); |
105 | 105 |
106 if (!disk_) { | 106 if (!disk_) { |
107 LOG(ERROR) << "Unable to get disk reference."; | 107 LOG(ERROR) << "Unable to get disk reference."; |
108 Error(); | 108 Error(); |
109 return; | 109 return; |
110 } | 110 } |
111 | 111 |
112 DADiskClaim(disk_, | 112 DADiskClaim(disk_, |
113 kDADiskClaimOptionDefault, | 113 kDADiskClaimOptionDefault, |
114 DiskClaimRevoked, | 114 DiskClaimRevoked, |
115 this, | 115 this, |
116 DiskClaimed, | 116 DiskClaimed, |
117 this); | 117 this); |
118 } | 118 } |
119 | 119 |
120 void DiskUnmounterMac::Error() { | 120 void DiskUnmounterMac::Error() { |
121 original_thread_->PostTask(FROM_HERE, failure_continuation_); | 121 original_thread_->PostTask(FROM_HERE, failure_continuation_); |
122 } | 122 } |
123 | 123 |
124 } // namespace image_writer | 124 } // namespace image_writer |
OLD | NEW |