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

Side by Side Diff: content/test/render_thread_impl_browser_test_ipc_helper.cc

Issue 1883323002: Reland of Use a token to initialise ChannelMojo and MojoApplication everywhere. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « content/test/render_thread_impl_browser_test_ipc_helper.h ('k') | ipc/ipc_message_start.h » ('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 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 "content/test/render_thread_impl_browser_test_ipc_helper.h" 5 #include "content/test/render_thread_impl_browser_test_ipc_helper.h"
6 6
7 #include "content/common/mojo/channel_init.h"
8 #include "content/public/common/mojo_channel_switches.h" 7 #include "content/public/common/mojo_channel_switches.h"
8 #include "mojo/edk/embedder/embedder.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
11 namespace content { 11 namespace content {
12 12
13 class RenderThreadImplBrowserIPCTestHelper::DummyListener 13 class RenderThreadImplBrowserIPCTestHelper::DummyListener
14 : public IPC::Listener { 14 : public IPC::Listener {
15 public: 15 public:
16 bool OnMessageReceived(const IPC::Message& message) override { return true; } 16 bool OnMessageReceived(const IPC::Message& message) override { return true; }
17 }; 17 };
18 18
(...skipping 22 matching lines...) Expand all
41 base::Thread::Options options; 41 base::Thread::Options options;
42 options.message_loop_type = base::MessageLoop::TYPE_IO; 42 options.message_loop_type = base::MessageLoop::TYPE_IO;
43 ASSERT_TRUE(ipc_thread_->StartWithOptions(options)); 43 ASSERT_TRUE(ipc_thread_->StartWithOptions(options));
44 } 44 }
45 45
46 void RenderThreadImplBrowserIPCTestHelper::SetupMojo() { 46 void RenderThreadImplBrowserIPCTestHelper::SetupMojo() {
47 InitializeMojo(); 47 InitializeMojo();
48 48
49 ipc_support_.reset(new IPC::ScopedIPCSupport(ipc_thread_->task_runner())); 49 ipc_support_.reset(new IPC::ScopedIPCSupport(ipc_thread_->task_runner()));
50 mojo_application_host_.reset(new MojoApplicationHost()); 50 mojo_application_host_.reset(new MojoApplicationHost());
51 mojo_application_host_->OverrideIOTaskRunnerForTest( 51 mojo_application_token_ = mojo_application_host_->GetToken();
52 ipc_thread_->task_runner()); 52
53 mojo_ipc_token_ = mojo::edk::GenerateRandomToken();
53 54
54 mojo::MessagePipe pipe; 55 mojo::MessagePipe pipe;
55 channel_ = IPC::ChannelProxy::Create( 56 channel_ = IPC::ChannelProxy::Create(
56 IPC::ChannelMojo::CreateServerFactory(std::move(pipe.handle0)), 57 IPC::ChannelMojo::CreateServerFactory(
58 mojo::edk::CreateParentMessagePipe(mojo_ipc_token_)),
57 dummy_listener_.get(), ipc_thread_->task_runner()); 59 dummy_listener_.get(), ipc_thread_->task_runner());
58 message_pipe_handle_ = std::move(pipe.handle1);
59
60 mojo_application_host_->Init();
61 mojo_application_host_->Activate(channel_.get(),
62 base::GetCurrentProcessHandle());
63 } 60 }
64 61
65 scoped_refptr<base::SingleThreadTaskRunner> 62 scoped_refptr<base::SingleThreadTaskRunner>
66 RenderThreadImplBrowserIPCTestHelper::GetIOTaskRunner() const { 63 RenderThreadImplBrowserIPCTestHelper::GetIOTaskRunner() const {
67 return ipc_thread_->task_runner(); 64 return ipc_thread_->task_runner();
68 } 65 }
69 66
70 } // namespace content 67 } // namespace content
OLDNEW
« no previous file with comments | « content/test/render_thread_impl_browser_test_ipc_helper.h ('k') | ipc/ipc_message_start.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698