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

Side by Side Diff: base/pickle.cc

Issue 57783006: Revert https://src.chromium.org/viewvc/chrome?view=rev&revision=231330 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile (cc perftest). Created 7 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/pickle.h" 5 #include "base/pickle.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 8
9 #include <algorithm> // for max() 9 #include <algorithm> // for max()
10 10
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 : header_(NULL), 163 : header_(NULL),
164 header_size_(AlignInt(header_size, sizeof(uint32))), 164 header_size_(AlignInt(header_size, sizeof(uint32))),
165 capacity_after_header_(0), 165 capacity_after_header_(0),
166 write_offset_(0) { 166 write_offset_(0) {
167 DCHECK_GE(static_cast<size_t>(header_size), sizeof(Header)); 167 DCHECK_GE(static_cast<size_t>(header_size), sizeof(Header));
168 DCHECK_LE(header_size, kPayloadUnit); 168 DCHECK_LE(header_size, kPayloadUnit);
169 Resize(kPayloadUnit); 169 Resize(kPayloadUnit);
170 header_->payload_size = 0; 170 header_->payload_size = 0;
171 } 171 }
172 172
173 Pickle::Pickle(const char* data, size_t data_len) 173 Pickle::Pickle(const char* data, int data_len)
174 : header_(reinterpret_cast<Header*>(const_cast<char*>(data))), 174 : header_(reinterpret_cast<Header*>(const_cast<char*>(data))),
175 header_size_(0), 175 header_size_(0),
176 capacity_after_header_(kCapacityReadOnly), 176 capacity_after_header_(kCapacityReadOnly),
177 write_offset_(0) { 177 write_offset_(0) {
178 if (data_len >= sizeof(Header)) 178 if (data_len >= static_cast<int>(sizeof(Header)))
179 header_size_ = data_len - header_->payload_size; 179 header_size_ = data_len - header_->payload_size;
180 180
181 if (header_size_ > data_len) 181 if (header_size_ > static_cast<unsigned int>(data_len))
182 header_size_ = 0; 182 header_size_ = 0;
183 183
184 if (header_size_ != AlignInt(header_size_, sizeof(uint32))) 184 if (header_size_ != AlignInt(header_size_, sizeof(uint32)))
185 header_size_ = 0; 185 header_size_ = 0;
186 186
187 // If there is anything wrong with the data, we're not going to use it. 187 // If there is anything wrong with the data, we're not going to use it.
188 if (!header_size_) 188 if (!header_size_)
189 header_ = NULL; 189 header_ = NULL;
190 } 190 }
191 191
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 if (new_size > capacity_after_header_) { 317 if (new_size > capacity_after_header_) {
318 Resize(std::max(capacity_after_header_ * 2, new_size)); 318 Resize(std::max(capacity_after_header_ * 2, new_size));
319 } 319 }
320 320
321 char* write = mutable_payload() + write_offset_; 321 char* write = mutable_payload() + write_offset_;
322 memcpy(write, data, length); 322 memcpy(write, data, length);
323 memset(write + length, 0, data_len - length); 323 memset(write + length, 0, data_len - length);
324 header_->payload_size = static_cast<uint32>(write_offset_ + length); 324 header_->payload_size = static_cast<uint32>(write_offset_ + length);
325 write_offset_ = new_size; 325 write_offset_ = new_size;
326 } 326 }
OLDNEW
« no previous file with comments | « base/pickle.h ('k') | chrome/browser/automation/chrome_frame_automation_provider_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698