OLD | NEW |
---|---|
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 Loading... | |
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()); | |
Mark Seaborn
2014/12/08 21:40:36
Should this check stay for non-Linux platforms?
S
hidehiko
2014/12/09 08:08:20
Done.
| |
1726 Done(); | 1725 Done(); |
1727 } | 1726 } |
1728 | 1727 |
1729 private: | 1728 private: |
1730 std::string reply_text_; | 1729 std::string reply_text_; |
1731 }; | 1730 }; |
1732 | 1731 |
1733 class VerifiedClient : public Worker { | 1732 class VerifiedClient : public Worker { |
1734 public: | 1733 public: |
1735 VerifiedClient(base::Thread* listener_thread, | 1734 VerifiedClient(base::Thread* listener_thread, |
1736 const std::string& channel_name, | 1735 const std::string& channel_name, |
1737 const std::string& expected_text) | 1736 const std::string& expected_text) |
1738 : Worker(channel_name, Channel::MODE_CLIENT), | 1737 : Worker(channel_name, Channel::MODE_CLIENT), |
1739 expected_text_(expected_text) { | 1738 expected_text_(expected_text) { |
1740 Worker::OverrideThread(listener_thread); | 1739 Worker::OverrideThread(listener_thread); |
1741 } | 1740 } |
1742 | 1741 |
1743 void Run() override { | 1742 void Run() override { |
1744 std::string response; | 1743 std::string response; |
1745 SyncMessage* msg = new SyncChannelNestedTestMsg_String(&response); | 1744 SyncMessage* msg = new SyncChannelNestedTestMsg_String(&response); |
1746 bool result = Send(msg); | 1745 bool result = Send(msg); |
1747 DCHECK(result); | 1746 DCHECK(result); |
1748 DCHECK_EQ(response, expected_text_); | 1747 DCHECK_EQ(response, expected_text_); |
1749 // expected_text_ is only used in the above DCHECK. This line suppresses the | 1748 // expected_text_ is only used in the above DCHECK. This line suppresses the |
1750 // "unused private field" warning in release builds. | 1749 // "unused private field" warning in release builds. |
1751 (void)expected_text_; | 1750 (void)expected_text_; |
1752 | 1751 |
1753 VLOG(1) << __FUNCTION__ << " Received reply: " << response; | 1752 VLOG(1) << __FUNCTION__ << " Received reply: " << response; |
1754 ASSERT_EQ(channel()->GetPeerPID(), base::GetCurrentProcId()); | |
Mark Seaborn
2014/12/08 21:40:36
Same for this one.
hidehiko
2014/12/09 08:08:20
Done.
| |
1755 Done(); | 1753 Done(); |
1756 } | 1754 } |
1757 | 1755 |
1758 private: | 1756 private: |
1759 std::string expected_text_; | 1757 std::string expected_text_; |
1760 }; | 1758 }; |
1761 | 1759 |
1762 void Verified() { | 1760 void Verified() { |
1763 std::vector<Worker*> workers; | 1761 std::vector<Worker*> workers; |
1764 | 1762 |
(...skipping 21 matching lines...) Expand all Loading... | |
1786 } | 1784 } |
1787 | 1785 |
1788 // Windows needs to send an out-of-band secret to verify the client end of the | 1786 // 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. | 1787 // channel. Test that we still connect correctly in that case. |
1790 TEST_F(IPCSyncChannelTest, Verified) { | 1788 TEST_F(IPCSyncChannelTest, Verified) { |
1791 Verified(); | 1789 Verified(); |
1792 } | 1790 } |
1793 | 1791 |
1794 } // namespace | 1792 } // namespace |
1795 } // namespace IPC | 1793 } // namespace IPC |
OLD | NEW |