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

Side by Side Diff: components/proximity_auth/wire_message.cc

Issue 794683005: replace COMPILE_ASSERT with static_assert in components/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: formatting fixup Created 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/proximity_auth/wire_message.h" 5 #include "components/proximity_auth/wire_message.h"
6 6
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 23 matching lines...) Expand all
34 // parse the header, or if the message length encoded in the message header 34 // parse the header, or if the message length encoded in the message header
35 // exceeds the size of the |serialized_message|. 35 // exceeds the size of the |serialized_message|.
36 bool ParseHeader(const std::string& serialized_message, 36 bool ParseHeader(const std::string& serialized_message,
37 bool* is_incomplete_message) { 37 bool* is_incomplete_message) {
38 *is_incomplete_message = false; 38 *is_incomplete_message = false;
39 if (serialized_message.size() < kHeaderLength) { 39 if (serialized_message.size() < kHeaderLength) {
40 *is_incomplete_message = true; 40 *is_incomplete_message = true;
41 return false; 41 return false;
42 } 42 }
43 43
44 COMPILE_ASSERT(kHeaderLength > 2, header_length_too_small); 44 static_assert(kHeaderLength > 2, "kHeaderLength too small");
45 size_t version = serialized_message[0]; 45 size_t version = serialized_message[0];
46 if (version != kExpectedMessageFormatVersion) { 46 if (version != kExpectedMessageFormatVersion) {
47 VLOG(1) << "Error: Invalid message version. Got " << version 47 VLOG(1) << "Error: Invalid message version. Got " << version
48 << ", expected " << kExpectedMessageFormatVersion; 48 << ", expected " << kExpectedMessageFormatVersion;
49 return false; 49 return false;
50 } 50 }
51 51
52 size_t expected_body_length = 52 size_t expected_body_length =
53 (static_cast<size_t>(serialized_message[1]) << 8) | 53 (static_cast<size_t>(serialized_message[1]) << 8) |
54 (static_cast<size_t>(serialized_message[2]) << 0); 54 (static_cast<size_t>(serialized_message[2]) << 0);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 // TODO(isherman): Implement. 115 // TODO(isherman): Implement.
116 return "This method is not yet implemented."; 116 return "This method is not yet implemented.";
117 } 117 }
118 118
119 WireMessage::WireMessage(const std::string& permit_id, 119 WireMessage::WireMessage(const std::string& permit_id,
120 const std::string& payload) 120 const std::string& payload)
121 : permit_id_(permit_id), payload_(payload) { 121 : permit_id_(permit_id), payload_(payload) {
122 } 122 }
123 123
124 } // namespace proximity_auth 124 } // namespace proximity_auth
OLDNEW
« no previous file with comments | « components/policy/core/common/cloud/cloud_policy_validator.cc ('k') | components/sessions/serialized_navigation_entry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698