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

Side by Side Diff: sync/util/nigori.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 | « ppapi/shared_impl/private/net_address_private_impl.cc ('k') | no next file » | 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 #include "sync/util/nigori.h" 5 #include "sync/util/nigori.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
(...skipping 12 matching lines...) Expand all
23 using crypto::SymmetricKey; 23 using crypto::SymmetricKey;
24 24
25 namespace browser_sync { 25 namespace browser_sync {
26 26
27 // NigoriStream simplifies the concatenation operation of the Nigori protocol. 27 // NigoriStream simplifies the concatenation operation of the Nigori protocol.
28 class NigoriStream { 28 class NigoriStream {
29 public: 29 public:
30 // Append the big-endian representation of the length of |value| with 32 bits, 30 // Append the big-endian representation of the length of |value| with 32 bits,
31 // followed by |value| itself to the stream. 31 // followed by |value| itself to the stream.
32 NigoriStream& operator<<(const std::string& value) { 32 NigoriStream& operator<<(const std::string& value) {
33 uint32 size = htonl(value.size()); 33 uint32 size = base::HostToNet32(value.size());
34 stream_.write((char *) &size, sizeof(uint32)); 34 stream_.write((char *) &size, sizeof(uint32));
35 stream_ << value; 35 stream_ << value;
36 return *this; 36 return *this;
37 } 37 }
38 38
39 // Append the big-endian representation of the length of |type| with 32 bits, 39 // Append the big-endian representation of the length of |type| with 32 bits,
40 // followed by the big-endian representation of the value of |type|, with 32 40 // followed by the big-endian representation of the value of |type|, with 32
41 // bits, to the stream. 41 // bits, to the stream.
42 NigoriStream& operator<<(const Nigori::Type type) { 42 NigoriStream& operator<<(const Nigori::Type type) {
43 uint32 size = htonl(sizeof(uint32)); 43 uint32 size = base::HostToNet32(sizeof(uint32));
44 stream_.write((char *) &size, sizeof(uint32)); 44 stream_.write((char *) &size, sizeof(uint32));
45 uint32 value = htonl(type); 45 uint32 value = base::HostToNet32(type);
46 stream_.write((char *) &value, sizeof(uint32)); 46 stream_.write((char *) &value, sizeof(uint32));
47 return *this; 47 return *this;
48 } 48 }
49 49
50 std::string str() { 50 std::string str() {
51 return stream_.str(); 51 return stream_.str();
52 } 52 }
53 53
54 private: 54 private:
55 std::ostringstream stream_; 55 std::ostringstream stream_;
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 DCHECK(user_key); 247 DCHECK(user_key);
248 DCHECK(encryption_key); 248 DCHECK(encryption_key);
249 DCHECK(mac_key); 249 DCHECK(mac_key);
250 250
251 return user_key_->GetRawKey(user_key) && 251 return user_key_->GetRawKey(user_key) &&
252 encryption_key_->GetRawKey(encryption_key) && 252 encryption_key_->GetRawKey(encryption_key) &&
253 mac_key_->GetRawKey(mac_key); 253 mac_key_->GetRawKey(mac_key);
254 } 254 }
255 255
256 } // namespace browser_sync 256 } // namespace browser_sync
OLDNEW
« no previous file with comments | « ppapi/shared_impl/private/net_address_private_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698