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

Side by Side Diff: src/platform/update_engine/delta_performer.cc

Issue 1800009: AU: SplitWriter class for parsing our full update files. (Closed) Base URL: ssh://git@chromiumos-git/chromeos
Patch Set: fixes for review Created 10 years, 7 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 | « src/platform/update_engine/delta_performer.h ('k') | src/platform/update_engine/file_writer.h » ('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 (c) 2010 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium OS 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 "update_engine/delta_performer.h" 5 #include "update_engine/delta_performer.h"
6 #include <endian.h> 6 #include <endian.h>
7 #include <errno.h> 7 #include <errno.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <cstring> 9 #include <cstring>
10 #include <string> 10 #include <string>
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 return -errno; 103 return -errno;
104 fd_ = -2; // Set so that isn't not valid AND calls to Open() will fail. 104 fd_ = -2; // Set so that isn't not valid AND calls to Open() will fail.
105 path_ = ""; 105 path_ = "";
106 return 0; 106 return 0;
107 } 107 }
108 108
109 // Wrapper around write. Returns bytes written on success or 109 // Wrapper around write. Returns bytes written on success or
110 // -errno on error. 110 // -errno on error.
111 // This function performs as many actions as it can, given the amount of 111 // This function performs as many actions as it can, given the amount of
112 // data received thus far. 112 // data received thus far.
113 int DeltaPerformer::Write(const void* bytes, size_t count) { 113 ssize_t DeltaPerformer::Write(const void* bytes, size_t count) {
114 const char* c_bytes = reinterpret_cast<const char*>(bytes); 114 const char* c_bytes = reinterpret_cast<const char*>(bytes);
115 buffer_.insert(buffer_.end(), c_bytes, c_bytes + count); 115 buffer_.insert(buffer_.end(), c_bytes, c_bytes + count);
116 116
117 if (!manifest_valid_) { 117 if (!manifest_valid_) {
118 // See if we have enough bytes for the manifest yet 118 // See if we have enough bytes for the manifest yet
119 if (buffer_.size() < strlen(kDeltaMagic) + 119 if (buffer_.size() < strlen(kDeltaMagic) +
120 kDeltaVersionLength + kDeltaProtobufLengthLength) { 120 kDeltaVersionLength + kDeltaProtobufLengthLength) {
121 // Don't have enough bytes to even know the protobuf length 121 // Don't have enough bytes to even know the protobuf length
122 return count; 122 return count;
123 } 123 }
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 utils::PWriteAll(fd_, &zeros[0], end_byte - begin_byte, begin_byte)); 367 utils::PWriteAll(fd_, &zeros[0], end_byte - begin_byte, begin_byte));
368 } 368 }
369 369
370 // Update buffer. 370 // Update buffer.
371 buffer_offset_ += operation.data_length(); 371 buffer_offset_ += operation.data_length();
372 RemoveBufferHeadBytes(&buffer_, operation.data_length()); 372 RemoveBufferHeadBytes(&buffer_, operation.data_length());
373 return true; 373 return true;
374 } 374 }
375 375
376 } // namespace chromeos_update_engine 376 } // namespace chromeos_update_engine
OLDNEW
« no previous file with comments | « src/platform/update_engine/delta_performer.h ('k') | src/platform/update_engine/file_writer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698