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

Side by Side Diff: ipc/ipc_sync_channel_unittest.cc

Issue 310293002: Make IPC::Channel polymorphic (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Another attempt to fix build breakage Created 6 years, 6 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
« no previous file with comments | « ipc/ipc_send_fds_test.cc ('k') | ipc/ipc_test_base.cc » ('j') | 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 virtual void OnNestedTestMsg(Message* reply_msg) OVERRIDE { 1721 virtual 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()->peer_pid(), base::GetCurrentProcId()); 1725 ASSERT_EQ(channel()->GetPeerPID(), base::GetCurrentProcId());
1726 Done(); 1726 Done();
1727 } 1727 }
1728 1728
1729 private: 1729 private:
1730 std::string reply_text_; 1730 std::string reply_text_;
1731 }; 1731 };
1732 1732
1733 class VerifiedClient : public Worker { 1733 class VerifiedClient : public Worker {
1734 public: 1734 public:
1735 VerifiedClient(base::Thread* listener_thread, 1735 VerifiedClient(base::Thread* listener_thread,
1736 const std::string& channel_name, 1736 const std::string& channel_name,
1737 const std::string& expected_text) 1737 const std::string& expected_text)
1738 : Worker(channel_name, Channel::MODE_CLIENT), 1738 : Worker(channel_name, Channel::MODE_CLIENT),
1739 expected_text_(expected_text) { 1739 expected_text_(expected_text) {
1740 Worker::OverrideThread(listener_thread); 1740 Worker::OverrideThread(listener_thread);
1741 } 1741 }
1742 1742
1743 virtual void Run() OVERRIDE { 1743 virtual void Run() OVERRIDE {
1744 std::string response; 1744 std::string response;
1745 SyncMessage* msg = new SyncChannelNestedTestMsg_String(&response); 1745 SyncMessage* msg = new SyncChannelNestedTestMsg_String(&response);
1746 bool result = Send(msg); 1746 bool result = Send(msg);
1747 DCHECK(result); 1747 DCHECK(result);
1748 DCHECK_EQ(response, expected_text_); 1748 DCHECK_EQ(response, expected_text_);
1749 // expected_text_ is only used in the above DCHECK. This line suppresses the 1749 // expected_text_ is only used in the above DCHECK. This line suppresses the
1750 // "unused private field" warning in release builds. 1750 // "unused private field" warning in release builds.
1751 (void)expected_text_; 1751 (void)expected_text_;
1752 1752
1753 VLOG(1) << __FUNCTION__ << " Received reply: " << response; 1753 VLOG(1) << __FUNCTION__ << " Received reply: " << response;
1754 ASSERT_EQ(channel()->peer_pid(), base::GetCurrentProcId()); 1754 ASSERT_EQ(channel()->GetPeerPID(), base::GetCurrentProcId());
1755 Done(); 1755 Done();
1756 } 1756 }
1757 1757
1758 private: 1758 private:
1759 std::string expected_text_; 1759 std::string expected_text_;
1760 }; 1760 };
1761 1761
1762 void Verified() { 1762 void Verified() {
1763 std::vector<Worker*> workers; 1763 std::vector<Worker*> workers;
1764 1764
(...skipping 21 matching lines...) Expand all
1786 } 1786 }
1787 1787
1788 // Windows needs to send an out-of-band secret to verify the client end of the 1788 // 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. 1789 // channel. Test that we still connect correctly in that case.
1790 TEST_F(IPCSyncChannelTest, Verified) { 1790 TEST_F(IPCSyncChannelTest, Verified) {
1791 Verified(); 1791 Verified();
1792 } 1792 }
1793 1793
1794 } // namespace 1794 } // namespace
1795 } // namespace IPC 1795 } // namespace IPC
OLDNEW
« no previous file with comments | « ipc/ipc_send_fds_test.cc ('k') | ipc/ipc_test_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698