Chromium Code Reviews| 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 "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/mac/foundation_util.h" | 13 #include "base/mac/foundation_util.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/single_thread_task_runner.h" | |
| 16 #include "base/thread_task_runner_handle.h" | |
|
Lei Zhang
2015/04/28 05:24:56
not needed in the .h file?
Pranay
2015/05/04 03:32:24
Done.
| |
| 15 #include "base/threading/thread.h" | 17 #include "base/threading/thread.h" |
| 16 | 18 |
| 17 namespace image_writer { | 19 namespace image_writer { |
| 18 | 20 |
| 19 class ImageWriter; | 21 class ImageWriter; |
| 20 | 22 |
| 21 // Manages the unmounting of disks through Disk Arbitration. Disk Arbitration | 23 // Manages the unmounting of disks through Disk Arbitration. Disk Arbitration |
| 22 // has to be run on a thread with a CFRunLoop. In the utility process neither | 24 // has to be run on a thread with a CFRunLoop. In the utility process neither |
| 23 // the main or IO thread have one by default, so we need to manage a new thread | 25 // the main or IO thread have one by default, so we need to manage a new thread |
| 24 // which will explicitly have a CFRunLoop-based message pump. Note that this | 26 // which will explicitly have a CFRunLoop-based message pump. Note that this |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 50 | 52 |
| 51 // A |MessagePumpFactory| for creating the thread. | 53 // A |MessagePumpFactory| for creating the thread. |
| 52 static scoped_ptr<base::MessagePump> CreateMessagePump(); | 54 static scoped_ptr<base::MessagePump> CreateMessagePump(); |
| 53 | 55 |
| 54 // Starts the unmount process. Should be posted to the |cf_thread_|. | 56 // Starts the unmount process. Should be posted to the |cf_thread_|. |
| 55 void UnmountOnWorker(const std::string& device_path); | 57 void UnmountOnWorker(const std::string& device_path); |
| 56 | 58 |
| 57 // A convenience method that triggers the failure continuation. | 59 // A convenience method that triggers the failure continuation. |
| 58 void Error(); | 60 void Error(); |
| 59 | 61 |
| 60 scoped_refptr<base::MessageLoopProxy> original_thread_; | 62 scoped_refptr<base::SingleThreadTaskRunner> original_thread_; |
| 61 base::Closure success_continuation_; | 63 base::Closure success_continuation_; |
| 62 base::Closure failure_continuation_; | 64 base::Closure failure_continuation_; |
| 63 | 65 |
| 64 base::ScopedCFTypeRef<DADiskRef> disk_; | 66 base::ScopedCFTypeRef<DADiskRef> disk_; |
| 65 base::ScopedCFTypeRef<DASessionRef> session_; | 67 base::ScopedCFTypeRef<DASessionRef> session_; |
| 66 | 68 |
| 67 // Thread is last to ensure it is stopped before the data members are | 69 // Thread is last to ensure it is stopped before the data members are |
| 68 // destroyed. | 70 // destroyed. |
| 69 base::Thread cf_thread_; | 71 base::Thread cf_thread_; |
| 70 }; | 72 }; |
| 71 | 73 |
| 72 } // namespace image_writer | 74 } // namespace image_writer |
| 73 | 75 |
| 74 #endif // CHROME_UTILITY_IMAGE_WRITER_DISK_UNMOUNTER_MAC_H_ | 76 #endif // CHROME_UTILITY_IMAGE_WRITER_DISK_UNMOUNTER_MAC_H_ |
| OLD | NEW |