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

Side by Side Diff: ipc/ipc_sync_channel_unittest.cc

Issue 695353005: Non-SFI mode: Use dummy PID for NaCl's IPC channel on Linux platform. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « ipc/ipc_channel_posix.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 "ipc/ipc_sync_channel.h" 5 #include "ipc/ipc_sync_channel.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 1704 matching lines...) Expand 10 before | Expand all | Expand 10 after
1715 const std::string& reply_text) 1715 const std::string& reply_text)
1716 : Worker(channel_name, Channel::MODE_SERVER), 1716 : Worker(channel_name, Channel::MODE_SERVER),
1717 reply_text_(reply_text) { 1717 reply_text_(reply_text) {
1718 Worker::OverrideThread(listener_thread); 1718 Worker::OverrideThread(listener_thread);
1719 } 1719 }
1720 1720
1721 void OnNestedTestMsg(Message* reply_msg) override { 1721 void OnNestedTestMsg(Message* reply_msg) override {
1722 VLOG(1) << __FUNCTION__ << " Sending reply: " << reply_text_; 1722 VLOG(1) << __FUNCTION__ << " Sending reply: " << reply_text_;
1723 SyncChannelNestedTestMsg_String::WriteReplyParams(reply_msg, reply_text_); 1723 SyncChannelNestedTestMsg_String::WriteReplyParams(reply_msg, reply_text_);
1724 Send(reply_msg); 1724 Send(reply_msg);
1725 ASSERT_EQ(channel()->GetPeerPID(), base::GetCurrentProcId()); 1725 #if defined(OS_LINUX) || defined(OS_NACL_NONSFI)
1726 ASSERT_EQ(-1, channel()->GetPeerPID());
1727 #else
1728 ASSERT_EQ(base::GetCurrentProcId(), channel()->GetPeerPID());
1729 #endif
1726 Done(); 1730 Done();
1727 } 1731 }
1728 1732
1729 private: 1733 private:
1730 std::string reply_text_; 1734 std::string reply_text_;
1731 }; 1735 };
1732 1736
1733 class VerifiedClient : public Worker { 1737 class VerifiedClient : public Worker {
1734 public: 1738 public:
1735 VerifiedClient(base::Thread* listener_thread, 1739 VerifiedClient(base::Thread* listener_thread,
1736 const std::string& channel_name, 1740 const std::string& channel_name,
1737 const std::string& expected_text) 1741 const std::string& expected_text)
1738 : Worker(channel_name, Channel::MODE_CLIENT), 1742 : Worker(channel_name, Channel::MODE_CLIENT),
1739 expected_text_(expected_text) { 1743 expected_text_(expected_text) {
1740 Worker::OverrideThread(listener_thread); 1744 Worker::OverrideThread(listener_thread);
1741 } 1745 }
1742 1746
1743 void Run() override { 1747 void Run() override {
1744 std::string response; 1748 std::string response;
1745 SyncMessage* msg = new SyncChannelNestedTestMsg_String(&response); 1749 SyncMessage* msg = new SyncChannelNestedTestMsg_String(&response);
1746 bool result = Send(msg); 1750 bool result = Send(msg);
1747 DCHECK(result); 1751 DCHECK(result);
1748 DCHECK_EQ(response, expected_text_); 1752 DCHECK_EQ(response, expected_text_);
1749 // expected_text_ is only used in the above DCHECK. This line suppresses the 1753 // expected_text_ is only used in the above DCHECK. This line suppresses the
1750 // "unused private field" warning in release builds. 1754 // "unused private field" warning in release builds.
1751 (void)expected_text_; 1755 (void)expected_text_;
1752 1756
1753 VLOG(1) << __FUNCTION__ << " Received reply: " << response; 1757 VLOG(1) << __FUNCTION__ << " Received reply: " << response;
1754 ASSERT_EQ(channel()->GetPeerPID(), base::GetCurrentProcId()); 1758 #if defined(OS_LINUX) || defined(OS_NACL_NONSFI)
1759 ASSERT_EQ(-1, channel()->GetPeerPID());
1760 #else
1761 ASSERT_EQ(base::GetCurrentProcId(), channel()->GetPeerPID());
1762 #endif
1755 Done(); 1763 Done();
1756 } 1764 }
1757 1765
1758 private: 1766 private:
1759 std::string expected_text_; 1767 std::string expected_text_;
1760 }; 1768 };
1761 1769
1762 void Verified() { 1770 void Verified() {
1763 std::vector<Worker*> workers; 1771 std::vector<Worker*> workers;
1764 1772
(...skipping 21 matching lines...) Expand all
1786 } 1794 }
1787 1795
1788 // Windows needs to send an out-of-band secret to verify the client end of the 1796 // Windows needs to send an out-of-band secret to verify the client end of the
1789 // channel. Test that we still connect correctly in that case. 1797 // channel. Test that we still connect correctly in that case.
1790 TEST_F(IPCSyncChannelTest, Verified) { 1798 TEST_F(IPCSyncChannelTest, Verified) {
1791 Verified(); 1799 Verified();
1792 } 1800 }
1793 1801
1794 } // namespace 1802 } // namespace
1795 } // namespace IPC 1803 } // namespace IPC
OLDNEW
« no previous file with comments | « ipc/ipc_channel_posix.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698