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

Side by Side Diff: ipc/ipc_send_fds_test.cc

Issue 824243004: Adding "static_assert" in lieu of "COMPILE_ASSERT" in ipc module (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #if defined(OS_POSIX) 7 #if defined(OS_POSIX)
8 #if defined(OS_MACOSX) 8 #if defined(OS_MACOSX)
9 extern "C" { 9 extern "C" {
10 #include <sandbox.h> 10 #include <sandbox.h>
(...skipping 20 matching lines...) Expand all
31 #include "base/macros.h" 31 #include "base/macros.h"
32 #endif 32 #endif
33 33
34 namespace { 34 namespace {
35 35
36 const unsigned kNumFDsToSend = 7; // per message 36 const unsigned kNumFDsToSend = 7; // per message
37 const unsigned kNumMessages = 20; 37 const unsigned kNumMessages = 20;
38 const char* kDevZeroPath = "/dev/zero"; 38 const char* kDevZeroPath = "/dev/zero";
39 39
40 #if defined(OS_POSIX) 40 #if defined(OS_POSIX)
41 COMPILE_ASSERT(kNumFDsToSend == 41 static_assert(kNumFDsToSend ==
42 IPC::MessageAttachmentSet::kMaxDescriptorsPerMessage, 42 IPC::MessageAttachmentSet::kMaxDescriptorsPerMessage,
43 num_fds_to_send_must_be_the_same_as_the_max_desc_per_message); 43 "num fds to send must be the same as the max desc per message");
dmichael (off chromium) 2015/01/20 16:44:10 How about: "The number of FDs to send must be kMax
anujsharma 2015/01/21 03:11:51 Done.
44 #endif 44 #endif
45 45
46 class MyChannelDescriptorListenerBase : public IPC::Listener { 46 class MyChannelDescriptorListenerBase : public IPC::Listener {
47 public: 47 public:
48 bool OnMessageReceived(const IPC::Message& message) override { 48 bool OnMessageReceived(const IPC::Message& message) override {
49 PickleIterator iter(message); 49 PickleIterator iter(message);
50 base::FileDescriptor descriptor; 50 base::FileDescriptor descriptor;
51 while (IPC::ParamTraits<base::FileDescriptor>::Read( 51 while (IPC::ParamTraits<base::FileDescriptor>::Read(
52 &message, &iter, &descriptor)) { 52 &message, &iter, &descriptor)) {
53 HandleFD(descriptor.fd); 53 HandleFD(descriptor.fd);
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 base::WaitableEvent received_; 378 base::WaitableEvent received_;
379 }; 379 };
380 380
381 TEST_F(IPCMultiSendingFdsTest, StressTest) { 381 TEST_F(IPCMultiSendingFdsTest, StressTest) {
382 Run(); 382 Run();
383 } 383 }
384 384
385 } // namespace 385 } // namespace
386 386
387 #endif // defined(OS_POSIX) 387 #endif // defined(OS_POSIX)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698