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

Side by Side 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: Minor updates. 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 unified diff | Download patch
OLDNEW
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 <windows.h> 5 #include <windows.h>
6 #include <setupapi.h> 6 #include <setupapi.h>
7 #include <winioctl.h> 7 #include <winioctl.h>
8 8
9 #include "chrome/utility/image_writer/error_messages.h" 9 #include "chrome/utility/image_writer/error_messages.h"
10 #include "chrome/utility/image_writer/image_writer.h" 10 #include "chrome/utility/image_writer/image_writer.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 PLOG(ERROR) << "Storage property query failed"; 48 PLOG(ERROR) << "Storage property query failed";
49 return false; 49 return false;
50 } 50 }
51 51
52 STORAGE_DEVICE_DESCRIPTOR* device_descriptor = 52 STORAGE_DEVICE_DESCRIPTOR* device_descriptor =
53 reinterpret_cast<STORAGE_DEVICE_DESCRIPTOR*>(output_buf.get()); 53 reinterpret_cast<STORAGE_DEVICE_DESCRIPTOR*>(output_buf.get());
54 54
55 return device_descriptor->RemovableMedia == TRUE; 55 return device_descriptor->RemovableMedia == TRUE;
56 } 56 }
57 57
58 bool ImageWriter::UnmountVolumes() { 58 bool ImageWriter::OpenDevice() {
59 // Windows requires that device files be opened with FILE_FLAG_NO_BUFFERING
60 // and FILE_FLAG_WRITE_THROUGH. These two flags are not part of base::File.
61 device_file_ =
62 base::File(CreateFile(device_path_.value().c_str(),
63 GENERIC_READ | GENERIC_WRITE,
64 FILE_SHARE_READ | FILE_SHARE_WRITE,
65 NULL,
66 OPEN_EXISTING,
67 FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH,
68 NULL));
69 return device_file_.IsValid();
70 }
71
72 void ImageWriter::UnmountVolumes(const base::Closure& continuation) {
59 if (!InitializeFiles()) { 73 if (!InitializeFiles()) {
60 return false; 74 return false;
61 } 75 }
62 76
63 STORAGE_DEVICE_NUMBER sdn = {0}; 77 STORAGE_DEVICE_NUMBER sdn = {0};
64 DWORD bytes_returned; 78 DWORD bytes_returned;
65 79
66 BOOL status = DeviceIoControl( 80 BOOL status = DeviceIoControl(
67 device_file_.GetPlatformFile(), 81 device_file_.GetPlatformFile(),
68 IOCTL_STORAGE_GET_DEVICE_NUMBER, 82 IOCTL_STORAGE_GET_DEVICE_NUMBER,
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 success = false; 184 success = false;
171 break; 185 break;
172 } 186 }
173 } 187 }
174 } 188 }
175 189
176 if (volume_finder != INVALID_HANDLE_VALUE) { 190 if (volume_finder != INVALID_HANDLE_VALUE) {
177 FindVolumeClose(volume_finder); 191 FindVolumeClose(volume_finder);
178 } 192 }
179 193
180 return success; 194 if (success)
195 callback.Run();
181 } 196 }
182 197
183 } // namespace image_writer 198 } // namespace image_writer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698