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

Side by Side Diff: ipc/ipc_message_utils.h

Issue 6602049: Pure pedantry: Replace all ".size() == 0" with ".empty()". (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 9 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #ifndef IPC_IPC_MESSAGE_UTILS_H_ 5 #ifndef IPC_IPC_MESSAGE_UTILS_H_
6 #define IPC_IPC_MESSAGE_UTILS_H_ 6 #define IPC_IPC_MESSAGE_UTILS_H_
7 #pragma once 7 #pragma once
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <string> 10 #include <string>
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 StringPrintf(" and %u more bytes", 406 StringPrintf(" and %u more bytes",
407 static_cast<unsigned>(data.size() - kMaxBytesToLog))); 407 static_cast<unsigned>(data.size() - kMaxBytesToLog)));
408 } 408 }
409 #endif 409 #endif
410 } 410 }
411 411
412 template <> 412 template <>
413 struct ParamTraits<std::vector<unsigned char> > { 413 struct ParamTraits<std::vector<unsigned char> > {
414 typedef std::vector<unsigned char> param_type; 414 typedef std::vector<unsigned char> param_type;
415 static void Write(Message* m, const param_type& p) { 415 static void Write(Message* m, const param_type& p) {
416 if (p.size() == 0) { 416 if (p.empty()) {
417 m->WriteData(NULL, 0); 417 m->WriteData(NULL, 0);
418 } else { 418 } else {
419 m->WriteData(reinterpret_cast<const char*>(&p.front()), 419 m->WriteData(reinterpret_cast<const char*>(&p.front()),
420 static_cast<int>(p.size())); 420 static_cast<int>(p.size()));
421 } 421 }
422 } 422 }
423 static bool Read(const Message* m, void** iter, param_type* r) { 423 static bool Read(const Message* m, void** iter, param_type* r) {
424 const char *data; 424 const char *data;
425 int data_size = 0; 425 int data_size = 0;
426 if (!m->ReadData(iter, &data, &data_size) || data_size < 0) 426 if (!m->ReadData(iter, &data, &data_size) || data_size < 0)
427 return false; 427 return false;
428 r->resize(data_size); 428 r->resize(data_size);
429 if (data_size) 429 if (data_size)
430 memcpy(&r->front(), data, data_size); 430 memcpy(&r->front(), data, data_size);
431 return true; 431 return true;
432 } 432 }
433 static void Log(const param_type& p, std::string* l) { 433 static void Log(const param_type& p, std::string* l) {
434 LogBytes(p, l); 434 LogBytes(p, l);
435 } 435 }
436 }; 436 };
437 437
438 template <> 438 template <>
439 struct ParamTraits<std::vector<char> > { 439 struct ParamTraits<std::vector<char> > {
440 typedef std::vector<char> param_type; 440 typedef std::vector<char> param_type;
441 static void Write(Message* m, const param_type& p) { 441 static void Write(Message* m, const param_type& p) {
442 if (p.size() == 0) { 442 if (p.empty()) {
443 m->WriteData(NULL, 0); 443 m->WriteData(NULL, 0);
444 } else { 444 } else {
445 m->WriteData(&p.front(), static_cast<int>(p.size())); 445 m->WriteData(&p.front(), static_cast<int>(p.size()));
446 } 446 }
447 } 447 }
448 static bool Read(const Message* m, void** iter, param_type* r) { 448 static bool Read(const Message* m, void** iter, param_type* r) {
449 const char *data; 449 const char *data;
450 int data_size = 0; 450 int data_size = 0;
451 if (!m->ReadData(iter, &data, &data_size) || data_size < 0) 451 if (!m->ReadData(iter, &data, &data_size) || data_size < 0)
452 return false; 452 return false;
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after
1195 ReplyParam p(a, b, c, d, e); 1195 ReplyParam p(a, b, c, d, e);
1196 WriteParam(reply, p); 1196 WriteParam(reply, p);
1197 } 1197 }
1198 }; 1198 };
1199 1199
1200 //----------------------------------------------------------------------------- 1200 //-----------------------------------------------------------------------------
1201 1201
1202 } // namespace IPC 1202 } // namespace IPC
1203 1203
1204 #endif // IPC_IPC_MESSAGE_UTILS_H_ 1204 #endif // IPC_IPC_MESSAGE_UTILS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698