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

Side by Side Diff: chrome/browser/safe_browsing/protocol_parser.cc

Issue 9716020: Add base::HostToNetXX() & NetToHostXX(), and use them to replace htonX() & ntohX() in Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 8 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/chromeos/web_socket_proxy.cc ('k') | chrome/common/metrics/metrics_log_base.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 (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 // Parse the data returned from the SafeBrowsing v2.1 protocol response. 5 // Parse the data returned from the SafeBrowsing v2.1 protocol response.
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 8
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 bool SafeBrowsingProtocolParser::ReadChunkId( 445 bool SafeBrowsingProtocolParser::ReadChunkId(
446 const char** data, int* remaining, int* chunk_id) { 446 const char** data, int* remaining, int* chunk_id) {
447 // Protocol says four bytes, not sizeof(int). Make sure those 447 // Protocol says four bytes, not sizeof(int). Make sure those
448 // values are the same. 448 // values are the same.
449 DCHECK_EQ(sizeof(*chunk_id), 4u); 449 DCHECK_EQ(sizeof(*chunk_id), 4u);
450 if (static_cast<size_t>(*remaining) < sizeof(*chunk_id)) 450 if (static_cast<size_t>(*remaining) < sizeof(*chunk_id))
451 return false; 451 return false;
452 memcpy(chunk_id, *data, sizeof(*chunk_id)); 452 memcpy(chunk_id, *data, sizeof(*chunk_id));
453 *data += sizeof(*chunk_id); 453 *data += sizeof(*chunk_id);
454 *remaining -= sizeof(*chunk_id); 454 *remaining -= sizeof(*chunk_id);
455 *chunk_id = htonl(*chunk_id); 455 *chunk_id = base::HostToNet32(*chunk_id);
456 DCHECK_GE(*remaining, 0); 456 DCHECK_GE(*remaining, 0);
457 return true; 457 return true;
458 } 458 }
459 459
460 bool SafeBrowsingProtocolParser::ReadPrefixes( 460 bool SafeBrowsingProtocolParser::ReadPrefixes(
461 const char** data, int* remaining, SBEntry* entry, int count) { 461 const char** data, int* remaining, SBEntry* entry, int count) {
462 int hash_len = entry->HashLen(); 462 int hash_len = entry->HashLen();
463 for (int i = 0; i < count; ++i) { 463 for (int i = 0; i < count; ++i) {
464 if (entry->IsSub()) { 464 if (entry->IsSub()) {
465 int chunk_id; 465 int chunk_id;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 520
521 data += line.size() + 1; 521 data += line.size() + 1;
522 remaining -= static_cast<int>(line.size()) + 1; 522 remaining -= static_cast<int>(line.size()) + 1;
523 } 523 }
524 524
525 if (client_key->empty() || wrapped_key->empty()) 525 if (client_key->empty() || wrapped_key->empty())
526 return false; 526 return false;
527 527
528 return true; 528 return true;
529 } 529 }
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/web_socket_proxy.cc ('k') | chrome/common/metrics/metrics_log_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698