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

Side by Side Diff: chrome/utility/image_writer/image_writer.cc

Issue 599853002: [Mac] Use raw disks (/dev/rdisk#) in image_writer_mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a DCHECK in WriteChunk. Created 6 years, 2 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
« no previous file with comments | « no previous file | chrome/utility/image_writer/image_writer_mac.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/utility/image_writer/image_writer.h" 5 #include "chrome/utility/image_writer/image_writer.h"
6 6
7 #include "base/memory/aligned_memory.h" 7 #include "base/memory/aligned_memory.h"
8 #include "chrome/utility/image_writer/error_messages.h" 8 #include "chrome/utility/image_writer/error_messages.h"
9 #include "chrome/utility/image_writer/image_writer_handler.h" 9 #include "chrome/utility/image_writer/image_writer_handler.h"
10 #include "content/public/utility/utility_thread.h" 10 #include "content/public/utility/utility_thread.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 memset(buffer.get(), 0, kBurningBlockSize); 118 memset(buffer.get(), 0, kBurningBlockSize);
119 119
120 int bytes_read = image_file_.Read(bytes_processed_, buffer.get(), 120 int bytes_read = image_file_.Read(bytes_processed_, buffer.get(),
121 kBurningBlockSize); 121 kBurningBlockSize);
122 122
123 if (bytes_read > 0) { 123 if (bytes_read > 0) {
124 // Always attempt to write a whole block, as writing DASD requires sector- 124 // Always attempt to write a whole block, as writing DASD requires sector-
125 // aligned writes to devices. 125 // aligned writes to devices.
126 int bytes_to_write = bytes_read + (kMemoryAlignment - 1) - 126 int bytes_to_write = bytes_read + (kMemoryAlignment - 1) -
127 (bytes_read - 1) % kMemoryAlignment; 127 (bytes_read - 1) % kMemoryAlignment;
128 DCHECK_EQ(0, bytes_to_write % kMemoryAlignment);
128 int bytes_written = 129 int bytes_written =
129 device_file_.Write(bytes_processed_, buffer.get(), bytes_to_write); 130 device_file_.Write(bytes_processed_, buffer.get(), bytes_to_write);
130 131
131 if (bytes_written < bytes_read) { 132 if (bytes_written < bytes_read) {
132 Error(error::kWriteImage); 133 Error(error::kWriteImage);
133 return; 134 return;
134 } 135 }
135 136
136 bytes_processed_ += bytes_read; 137 bytes_processed_ += bytes_read;
137 PostProgress(bytes_processed_); 138 PostProgress(bytes_processed_);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 running_ = false; 189 running_ = false;
189 } else { 190 } else {
190 // Unable to read entire file. 191 // Unable to read entire file.
191 LOG(ERROR) << "Failed to read " << kBurningBlockSize << " bytes of image " 192 LOG(ERROR) << "Failed to read " << kBurningBlockSize << " bytes of image "
192 << "at offset " << bytes_processed_; 193 << "at offset " << bytes_processed_;
193 Error(error::kReadImage); 194 Error(error::kReadImage);
194 } 195 }
195 } 196 }
196 197
197 } // namespace image_writer 198 } // namespace image_writer
OLDNEW
« no previous file with comments | « no previous file | chrome/utility/image_writer/image_writer_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698