| OLD | NEW | 
|    1 // Copyright 2014 The Chromium Authors. All rights reserved. |    1 // Copyright 2014 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/mojo/ipc_channel_mojo.h" |    5 #include "ipc/mojo/ipc_channel_mojo.h" | 
|    6  |    6  | 
 |    7 #include <stdint.h> | 
 |    8  | 
|    7 #include "base/base_paths.h" |    9 #include "base/base_paths.h" | 
|    8 #include "base/files/file.h" |   10 #include "base/files/file.h" | 
|    9 #include "base/location.h" |   11 #include "base/location.h" | 
|   10 #include "base/path_service.h" |   12 #include "base/path_service.h" | 
|   11 #include "base/pickle.h" |   13 #include "base/pickle.h" | 
|   12 #include "base/run_loop.h" |   14 #include "base/run_loop.h" | 
|   13 #include "base/single_thread_task_runner.h" |   15 #include "base/single_thread_task_runner.h" | 
|   14 #include "base/test/test_timeouts.h" |   16 #include "base/test/test_timeouts.h" | 
|   15 #include "base/thread_task_runner_handle.h" |   17 #include "base/thread_task_runner_handle.h" | 
|   16 #include "base/threading/thread.h" |   18 #include "base/threading/thread.h" | 
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  126 }; |  128 }; | 
|  127  |  129  | 
|  128  |  130  | 
|  129 class TestChannelListenerWithExtraExpectations |  131 class TestChannelListenerWithExtraExpectations | 
|  130     : public IPC::TestChannelListener { |  132     : public IPC::TestChannelListener { | 
|  131  public: |  133  public: | 
|  132   TestChannelListenerWithExtraExpectations() |  134   TestChannelListenerWithExtraExpectations() | 
|  133       : is_connected_called_(false) { |  135       : is_connected_called_(false) { | 
|  134   } |  136   } | 
|  135  |  137  | 
|  136   void OnChannelConnected(int32 peer_pid) override { |  138   void OnChannelConnected(int32_t peer_pid) override { | 
|  137     IPC::TestChannelListener::OnChannelConnected(peer_pid); |  139     IPC::TestChannelListener::OnChannelConnected(peer_pid); | 
|  138     EXPECT_TRUE(base::kNullProcessId != peer_pid); |  140     EXPECT_TRUE(base::kNullProcessId != peer_pid); | 
|  139     is_connected_called_ = true; |  141     is_connected_called_ = true; | 
|  140   } |  142   } | 
|  141  |  143  | 
|  142   bool is_connected_called() const { return is_connected_called_; } |  144   bool is_connected_called() const { return is_connected_called_; } | 
|  143  |  145  | 
|  144  private: |  146  private: | 
|  145   bool is_connected_called_; |  147   bool is_connected_called_; | 
|  146 }; |  148 }; | 
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  193  |  195  | 
|  194   return 0; |  196   return 0; | 
|  195 } |  197 } | 
|  196  |  198  | 
|  197 class ListenerExpectingErrors : public IPC::Listener { |  199 class ListenerExpectingErrors : public IPC::Listener { | 
|  198  public: |  200  public: | 
|  199   ListenerExpectingErrors() |  201   ListenerExpectingErrors() | 
|  200       : has_error_(false) { |  202       : has_error_(false) { | 
|  201   } |  203   } | 
|  202  |  204  | 
|  203   void OnChannelConnected(int32 peer_pid) override { |  205   void OnChannelConnected(int32_t peer_pid) override { | 
|  204     base::MessageLoop::current()->Quit(); |  206     base::MessageLoop::current()->Quit(); | 
|  205   } |  207   } | 
|  206  |  208  | 
|  207   bool OnMessageReceived(const IPC::Message& message) override { return true; } |  209   bool OnMessageReceived(const IPC::Message& message) override { return true; } | 
|  208  |  210  | 
|  209   void OnChannelError() override { |  211   void OnChannelError() override { | 
|  210     has_error_ = true; |  212     has_error_ = true; | 
|  211     base::MessageLoop::current()->Quit(); |  213     base::MessageLoop::current()->Quit(); | 
|  212   } |  214   } | 
|  213  |  215  | 
| (...skipping 22 matching lines...) Expand all  Loading... | 
|  236  |  238  | 
|  237 class ListenerThatQuits : public IPC::Listener { |  239 class ListenerThatQuits : public IPC::Listener { | 
|  238  public: |  240  public: | 
|  239   ListenerThatQuits() { |  241   ListenerThatQuits() { | 
|  240   } |  242   } | 
|  241  |  243  | 
|  242   bool OnMessageReceived(const IPC::Message& message) override { |  244   bool OnMessageReceived(const IPC::Message& message) override { | 
|  243     return true; |  245     return true; | 
|  244   } |  246   } | 
|  245  |  247  | 
|  246   void OnChannelConnected(int32 peer_pid) override { |  248   void OnChannelConnected(int32_t peer_pid) override { | 
|  247     base::MessageLoop::current()->Quit(); |  249     base::MessageLoop::current()->Quit(); | 
|  248   } |  250   } | 
|  249 }; |  251 }; | 
|  250  |  252  | 
|  251 // A long running process that connects to us. |  253 // A long running process that connects to us. | 
|  252 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(IPCChannelMojoErraticTestClient) { |  254 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(IPCChannelMojoErraticTestClient) { | 
|  253   ListenerThatQuits listener; |  255   ListenerThatQuits listener; | 
|  254   ChannelClient client(&listener, "IPCChannelMojoErraticTestClient"); |  256   ChannelClient client(&listener, "IPCChannelMojoErraticTestClient"); | 
|  255   client.Connect(); |  257   client.Connect(); | 
|  256  |  258  | 
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  588  |  590  | 
|  589 class ListenerSendingOneOk : public IPC::Listener { |  591 class ListenerSendingOneOk : public IPC::Listener { | 
|  590  public: |  592  public: | 
|  591   ListenerSendingOneOk() { |  593   ListenerSendingOneOk() { | 
|  592   } |  594   } | 
|  593  |  595  | 
|  594   bool OnMessageReceived(const IPC::Message& message) override { |  596   bool OnMessageReceived(const IPC::Message& message) override { | 
|  595     return true; |  597     return true; | 
|  596   } |  598   } | 
|  597  |  599  | 
|  598   void OnChannelConnected(int32 peer_pid) override { |  600   void OnChannelConnected(int32_t peer_pid) override { | 
|  599     ListenerThatExpectsOK::SendOK(sender_); |  601     ListenerThatExpectsOK::SendOK(sender_); | 
|  600     base::MessageLoop::current()->Quit(); |  602     base::MessageLoop::current()->Quit(); | 
|  601   } |  603   } | 
|  602  |  604  | 
|  603   void set_sender(IPC::Sender* sender) { sender_ = sender; } |  605   void set_sender(IPC::Sender* sender) { sender_ = sender; } | 
|  604  |  606  | 
|  605  private: |  607  private: | 
|  606   IPC::Sender* sender_; |  608   IPC::Sender* sender_; | 
|  607 }; |  609 }; | 
|  608  |  610  | 
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  808 } |  810 } | 
|  809  |  811  | 
|  810 #endif |  812 #endif | 
|  811  |  813  | 
|  812 #if defined(OS_LINUX) |  814 #if defined(OS_LINUX) | 
|  813  |  815  | 
|  814 const base::ProcessId kMagicChildId = 54321; |  816 const base::ProcessId kMagicChildId = 54321; | 
|  815  |  817  | 
|  816 class ListenerThatVerifiesPeerPid : public IPC::Listener { |  818 class ListenerThatVerifiesPeerPid : public IPC::Listener { | 
|  817  public: |  819  public: | 
|  818   void OnChannelConnected(int32 peer_pid) override { |  820   void OnChannelConnected(int32_t peer_pid) override { | 
|  819     EXPECT_EQ(peer_pid, kMagicChildId); |  821     EXPECT_EQ(peer_pid, kMagicChildId); | 
|  820     base::MessageLoop::current()->Quit(); |  822     base::MessageLoop::current()->Quit(); | 
|  821   } |  823   } | 
|  822  |  824  | 
|  823   bool OnMessageReceived(const IPC::Message& message) override { |  825   bool OnMessageReceived(const IPC::Message& message) override { | 
|  824     NOTREACHED(); |  826     NOTREACHED(); | 
|  825     return true; |  827     return true; | 
|  826   } |  828   } | 
|  827 }; |  829 }; | 
|  828  |  830  | 
| (...skipping 22 matching lines...) Expand all  Loading... | 
|  851   base::MessageLoop::current()->Run(); |  853   base::MessageLoop::current()->Run(); | 
|  852  |  854  | 
|  853   client.Close(); |  855   client.Close(); | 
|  854  |  856  | 
|  855   return 0; |  857   return 0; | 
|  856 } |  858 } | 
|  857  |  859  | 
|  858 #endif // OS_LINUX |  860 #endif // OS_LINUX | 
|  859  |  861  | 
|  860 }  // namespace |  862 }  // namespace | 
| OLD | NEW |