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

Side by Side Diff: content/browser/indexed_db/indexed_db_leveldb_coding.cc

Issue 1471073010: Removed unused include of winsock.h/inet.h from sys_byteorder.h. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: include inet.h for things other than byte-swap Created 5 years 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "content/browser/indexed_db/indexed_db_leveldb_coding.h" 5 #include "content/browser/indexed_db/indexed_db_leveldb_coding.h"
6 6
7 #include <iterator> 7 #include <iterator>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 return; 283 return;
284 // Backing store is UTF-16BE, convert from host endianness. 284 // Backing store is UTF-16BE, convert from host endianness.
285 size_t length = value.length(); 285 size_t length = value.length();
286 size_t current = into->size(); 286 size_t current = into->size();
287 into->resize(into->size() + length * sizeof(base::char16)); 287 into->resize(into->size() + length * sizeof(base::char16));
288 288
289 const base::char16* src = value.c_str(); 289 const base::char16* src = value.c_str();
290 base::char16* dst = 290 base::char16* dst =
291 reinterpret_cast<base::char16*>(&*into->begin() + current); 291 reinterpret_cast<base::char16*>(&*into->begin() + current);
292 for (unsigned i = 0; i < length; ++i) 292 for (unsigned i = 0; i < length; ++i)
293 *dst++ = htons(*src++); 293 *dst++ = base::HostToNet16(*src++);
294 } 294 }
295 295
296 void EncodeBinary(const std::string& value, std::string* into) { 296 void EncodeBinary(const std::string& value, std::string* into) {
297 EncodeVarInt(value.length(), into); 297 EncodeVarInt(value.length(), into);
298 into->append(value.begin(), value.end()); 298 into->append(value.begin(), value.end());
299 DCHECK(into->size() >= value.size()); 299 DCHECK(into->size() >= value.size());
300 } 300 }
301 301
302 void EncodeStringWithLength(const base::string16& value, std::string* into) { 302 void EncodeStringWithLength(const base::string16& value, std::string* into) {
303 EncodeVarInt(value.length(), into); 303 EncodeVarInt(value.length(), into);
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 } 448 }
449 449
450 // Backing store is UTF-16BE, convert to host endianness. 450 // Backing store is UTF-16BE, convert to host endianness.
451 DCHECK(!(slice->size() % sizeof(base::char16))); 451 DCHECK(!(slice->size() % sizeof(base::char16)));
452 size_t length = slice->size() / sizeof(base::char16); 452 size_t length = slice->size() / sizeof(base::char16);
453 base::string16 decoded; 453 base::string16 decoded;
454 decoded.reserve(length); 454 decoded.reserve(length);
455 const base::char16* encoded = 455 const base::char16* encoded =
456 reinterpret_cast<const base::char16*>(slice->begin()); 456 reinterpret_cast<const base::char16*>(slice->begin());
457 for (unsigned i = 0; i < length; ++i) 457 for (unsigned i = 0; i < length; ++i)
458 decoded.push_back(ntohs(*encoded++)); 458 decoded.push_back(base::NetToHost16(*encoded++));
459 459
460 *value = decoded; 460 *value = decoded;
461 slice->remove_prefix(length * sizeof(base::char16)); 461 slice->remove_prefix(length * sizeof(base::char16));
462 return true; 462 return true;
463 } 463 }
464 464
465 bool DecodeStringWithLength(StringPiece* slice, base::string16* value) { 465 bool DecodeStringWithLength(StringPiece* slice, base::string16* value) {
466 if (slice->empty()) 466 if (slice->empty())
467 return false; 467 return false;
468 468
(...skipping 1563 matching lines...) Expand 10 before | Expand all | Expand 10 after
2032 scoped_ptr<IndexedDBKey> IndexDataKey::primary_key() const { 2032 scoped_ptr<IndexedDBKey> IndexDataKey::primary_key() const {
2033 scoped_ptr<IndexedDBKey> key; 2033 scoped_ptr<IndexedDBKey> key;
2034 StringPiece slice(encoded_primary_key_); 2034 StringPiece slice(encoded_primary_key_);
2035 if (!DecodeIDBKey(&slice, &key)) { 2035 if (!DecodeIDBKey(&slice, &key)) {
2036 // TODO(jsbell): Return error. 2036 // TODO(jsbell): Return error.
2037 } 2037 }
2038 return key.Pass(); 2038 return key.Pass();
2039 } 2039 }
2040 2040
2041 } // namespace content 2041 } // namespace content
OLDNEW
« no previous file with comments | « components/nacl/browser/nacl_process_host.cc ('k') | net/dns/dns_config_service_posix_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698