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 #ifndef CHROME_UTILITY_IMAGE_WRITER_DISK_UNMOUNTER_MAC_H_ | 5 #ifndef CHROME_UTILITY_IMAGE_WRITER_DISK_UNMOUNTER_MAC_H_ |
6 #define CHROME_UTILITY_IMAGE_WRITER_DISK_UNMOUNTER_MAC_H_ | 6 #define CHROME_UTILITY_IMAGE_WRITER_DISK_UNMOUNTER_MAC_H_ |
7 | 7 |
8 #include <CoreFoundation/CoreFoundation.h> | 8 #include <CoreFoundation/CoreFoundation.h> |
9 #include <DiskArbitration/DiskArbitration.h> | 9 #include <DiskArbitration/DiskArbitration.h> |
10 | 10 |
11 #include <memory> | 11 #include <memory> |
12 | 12 |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/callback.h" | 14 #include "base/callback.h" |
15 #include "base/mac/foundation_util.h" | 15 #include "base/mac/foundation_util.h" |
16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
17 #include "base/single_thread_task_runner.h" | 17 #include "base/single_thread_task_runner.h" |
18 #include "base/threading/thread.h" | 18 #include "base/threading/thread.h" |
19 | 19 |
20 namespace image_writer { | 20 namespace image_writer { |
21 | 21 |
22 class ImageWriter; | |
23 | |
24 // Manages the unmounting of disks through Disk Arbitration. Disk Arbitration | 22 // Manages the unmounting of disks through Disk Arbitration. Disk Arbitration |
25 // has to be run on a thread with a CFRunLoop. In the utility process neither | 23 // has to be run on a thread with a CFRunLoop. In the utility process neither |
26 // the main or IO thread have one by default, so we need to manage a new thread | 24 // the main or IO thread have one by default, so we need to manage a new thread |
27 // which will explicitly have a CFRunLoop-based message pump. Note that this | 25 // which will explicitly have a CFRunLoop-based message pump. Note that this |
28 // class can only handle one unmount operation at a time and calling Unmount | 26 // class can only handle one unmount operation at a time and calling Unmount |
29 // again before the continuation returns will cause undefined behavior. | 27 // again before the continuation returns will cause undefined behavior. |
30 class DiskUnmounterMac { | 28 class DiskUnmounterMac { |
31 public: | 29 public: |
32 DiskUnmounterMac(); | 30 DiskUnmounterMac(); |
33 ~DiskUnmounterMac(); | 31 ~DiskUnmounterMac(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 base::ScopedCFTypeRef<DASessionRef> session_; | 66 base::ScopedCFTypeRef<DASessionRef> session_; |
69 | 67 |
70 // Thread is last to ensure it is stopped before the data members are | 68 // Thread is last to ensure it is stopped before the data members are |
71 // destroyed. | 69 // destroyed. |
72 base::Thread cf_thread_; | 70 base::Thread cf_thread_; |
73 }; | 71 }; |
74 | 72 |
75 } // namespace image_writer | 73 } // namespace image_writer |
76 | 74 |
77 #endif // CHROME_UTILITY_IMAGE_WRITER_DISK_UNMOUNTER_MAC_H_ | 75 #endif // CHROME_UTILITY_IMAGE_WRITER_DISK_UNMOUNTER_MAC_H_ |
OLD | NEW |