| 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 "base/lazy_instance.h" |   5 #include "base/lazy_instance.h" | 
|   6 #include "ipc/ipc_perftest_support.h" |   6 #include "ipc/ipc_perftest_support.h" | 
|   7 #include "ipc/mojo/ipc_channel_mojo.h" |   7 #include "ipc/mojo/ipc_channel_mojo.h" | 
|   8 #include "ipc/mojo/ipc_channel_mojo_host.h" |   8 #include "ipc/mojo/ipc_channel_mojo_host.h" | 
|   9 #include "mojo/edk/embedder/test_embedder.h" |   9 #include "mojo/edk/embedder/test_embedder.h" | 
|  10  |  10  | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
|  22  |  22  | 
|  23 base::LazyInstance<MojoInitialier> g_mojo_initializer |  23 base::LazyInstance<MojoInitialier> g_mojo_initializer | 
|  24     = LAZY_INSTANCE_INITIALIZER; |  24     = LAZY_INSTANCE_INITIALIZER; | 
|  25  |  25  | 
|  26 class MojoChannelPerfTest : public IPC::test::IPCChannelPerfTestBase { |  26 class MojoChannelPerfTest : public IPC::test::IPCChannelPerfTestBase { | 
|  27 public: |  27 public: | 
|  28   typedef IPC::test::IPCChannelPerfTestBase Super; |  28   typedef IPC::test::IPCChannelPerfTestBase Super; | 
|  29  |  29  | 
|  30   MojoChannelPerfTest(); |  30   MojoChannelPerfTest(); | 
|  31  |  31  | 
|  32   virtual scoped_ptr<IPC::ChannelFactory> CreateChannelFactory( |  32   scoped_ptr<IPC::ChannelFactory> CreateChannelFactory( | 
|  33       const IPC::ChannelHandle& handle, |  33       const IPC::ChannelHandle& handle, | 
|  34       base::TaskRunner* runner) override { |  34       base::TaskRunner* runner) override { | 
|  35     host_.reset(new IPC::ChannelMojoHost(task_runner())); |  35     host_.reset(new IPC::ChannelMojoHost(task_runner())); | 
|  36     return IPC::ChannelMojo::CreateServerFactory(host_->channel_delegate(), |  36     return IPC::ChannelMojo::CreateServerFactory(host_->channel_delegate(), | 
|  37                                                  handle); |  37                                                  handle); | 
|  38   } |  38   } | 
|  39  |  39  | 
|  40   virtual bool DidStartClient() override { |  40   bool DidStartClient() override { | 
|  41     bool ok = IPCTestBase::DidStartClient(); |  41     bool ok = IPCTestBase::DidStartClient(); | 
|  42     DCHECK(ok); |  42     DCHECK(ok); | 
|  43     host_->OnClientLaunched(client_process()); |  43     host_->OnClientLaunched(client_process()); | 
|  44     return ok; |  44     return ok; | 
|  45   } |  45   } | 
|  46  |  46  | 
|  47   void set_io_thread_task_runner(base::TaskRunner* runner) { |  47   void set_io_thread_task_runner(base::TaskRunner* runner) { | 
|  48     io_thread_task_runner_ = runner; |  48     io_thread_task_runner_ = runner; | 
|  49   } |  49   } | 
|  50  |  50  | 
| (...skipping 15 matching lines...) Expand all  Loading... | 
|  66 TEST_F(MojoChannelPerfTest, ChannelProxyPingPong) { |  66 TEST_F(MojoChannelPerfTest, ChannelProxyPingPong) { | 
|  67   RunTestChannelProxyPingPong(GetDefaultTestParams()); |  67   RunTestChannelProxyPingPong(GetDefaultTestParams()); | 
|  68 } |  68 } | 
|  69  |  69  | 
|  70 class MojoTestClient : public IPC::test::PingPongTestClient { |  70 class MojoTestClient : public IPC::test::PingPongTestClient { | 
|  71  public: |  71  public: | 
|  72   typedef IPC::test::PingPongTestClient SuperType; |  72   typedef IPC::test::PingPongTestClient SuperType; | 
|  73  |  73  | 
|  74   MojoTestClient(); |  74   MojoTestClient(); | 
|  75  |  75  | 
|  76   virtual scoped_ptr<IPC::Channel> CreateChannel( |  76   scoped_ptr<IPC::Channel> CreateChannel(IPC::Listener* listener) override; | 
|  77       IPC::Listener* listener) override; |  | 
|  78 }; |  77 }; | 
|  79  |  78  | 
|  80 MojoTestClient::MojoTestClient() { |  79 MojoTestClient::MojoTestClient() { | 
|  81   g_mojo_initializer.Get(); |  80   g_mojo_initializer.Get(); | 
|  82 } |  81 } | 
|  83  |  82  | 
|  84 scoped_ptr<IPC::Channel> MojoTestClient::CreateChannel( |  83 scoped_ptr<IPC::Channel> MojoTestClient::CreateChannel( | 
|  85     IPC::Listener* listener) { |  84     IPC::Listener* listener) { | 
|  86   return scoped_ptr<IPC::Channel>( |  85   return scoped_ptr<IPC::Channel>( | 
|  87       IPC::ChannelMojo::Create(NULL, |  86       IPC::ChannelMojo::Create(NULL, | 
|  88                                IPCTestBase::GetChannelName("PerformanceClient"), |  87                                IPCTestBase::GetChannelName("PerformanceClient"), | 
|  89                                IPC::Channel::MODE_CLIENT, |  88                                IPC::Channel::MODE_CLIENT, | 
|  90                                listener)); |  89                                listener)); | 
|  91 } |  90 } | 
|  92  |  91  | 
|  93 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(PerformanceClient) { |  92 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(PerformanceClient) { | 
|  94   MojoTestClient client; |  93   MojoTestClient client; | 
|  95   return client.RunMain(); |  94   return client.RunMain(); | 
|  96 } |  95 } | 
|  97  |  96  | 
|  98 }  // namespace |  97 }  // namespace | 
| OLD | NEW |