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

Unified Diff: chrome/utility/image_writer/image_writer_win.cc

Issue 294163008: Adds USB writing for OS X. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@list-devices
Patch Set: Fixes windows compilation. Created 6 years, 6 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/utility/image_writer/image_writer_stub.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/utility/image_writer/image_writer_win.cc
diff --git a/chrome/utility/image_writer/image_writer_win.cc b/chrome/utility/image_writer/image_writer_win.cc
index b3cec9507445bc47ec1e83f2869e6abb38dd3b04..f8a369f54d2939ff8118e95824c91d90efb6bbbf 100644
--- a/chrome/utility/image_writer/image_writer_win.cc
+++ b/chrome/utility/image_writer/image_writer_win.cc
@@ -55,9 +55,23 @@ bool ImageWriter::IsValidDevice() {
return device_descriptor->RemovableMedia == TRUE;
}
-bool ImageWriter::UnmountVolumes() {
+bool ImageWriter::OpenDevice() {
+ // Windows requires that device files be opened with FILE_FLAG_NO_BUFFERING
+ // and FILE_FLAG_WRITE_THROUGH. These two flags are not part of base::File.
+ device_file_ =
+ base::File(CreateFile(device_path_.value().c_str(),
+ GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL,
+ OPEN_EXISTING,
+ FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH,
+ NULL));
+ return device_file_.IsValid();
+}
+
+void ImageWriter::UnmountVolumes(const base::Closure& continuation) {
if (!InitializeFiles()) {
- return false;
+ return;
}
STORAGE_DEVICE_NUMBER sdn = {0};
@@ -74,7 +88,7 @@ bool ImageWriter::UnmountVolumes() {
NULL); // Unused overlap.
if (!status) {
PLOG(ERROR) << "Unable to get device number.";
- return false;
+ return;
}
ULONG device_number = sdn.DeviceNumber;
@@ -82,7 +96,7 @@ bool ImageWriter::UnmountVolumes() {
TCHAR volume_path[MAX_PATH + 1];
HANDLE volume_finder = FindFirstVolume(volume_path, MAX_PATH + 1);
if (volume_finder == INVALID_HANDLE_VALUE) {
- return false;
+ return;
}
HANDLE volume_handle;
@@ -177,7 +191,8 @@ bool ImageWriter::UnmountVolumes() {
FindVolumeClose(volume_finder);
}
- return success;
+ if (success)
+ continuation.Run();
}
} // namespace image_writer
« no previous file with comments | « chrome/utility/image_writer/image_writer_stub.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698