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

Side by Side Diff: mojo/edk/system/message_pipe_test_utils.cc

Issue 728043002: Revert of Update mojo sdk to rev afb4440fd5a10cba980878c326180b7ad7960480 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 | « mojo/edk/system/message_pipe_perftest.cc ('k') | mojo/edk/system/message_pipe_unittest.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 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 "mojo/edk/system/message_pipe_test_utils.h" 5 #include "mojo/edk/system/message_pipe_test_utils.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/threading/platform_thread.h" // For |Sleep()|. 8 #include "base/threading/platform_thread.h" // For |Sleep()|.
9 #include "mojo/edk/system/channel.h" 9 #include "mojo/edk/system/channel.h"
10 #include "mojo/edk/system/channel_endpoint.h" 10 #include "mojo/edk/system/channel_endpoint.h"
(...skipping 28 matching lines...) Expand all
39 39
40 ChannelThread::~ChannelThread() { 40 ChannelThread::~ChannelThread() {
41 Stop(); 41 Stop();
42 } 42 }
43 43
44 void ChannelThread::Start(embedder::ScopedPlatformHandle platform_handle, 44 void ChannelThread::Start(embedder::ScopedPlatformHandle platform_handle,
45 scoped_refptr<ChannelEndpoint> channel_endpoint) { 45 scoped_refptr<ChannelEndpoint> channel_endpoint) {
46 test_io_thread_.Start(); 46 test_io_thread_.Start();
47 test_io_thread_.PostTaskAndWait( 47 test_io_thread_.PostTaskAndWait(
48 FROM_HERE, 48 FROM_HERE,
49 base::Bind(&ChannelThread::InitChannelOnIOThread, base::Unretained(this), 49 base::Bind(&ChannelThread::InitChannelOnIOThread,
50 base::Passed(&platform_handle), channel_endpoint)); 50 base::Unretained(this),
51 base::Passed(&platform_handle),
52 channel_endpoint));
51 } 53 }
52 54
53 void ChannelThread::Stop() { 55 void ChannelThread::Stop() {
54 if (channel_.get()) { 56 if (channel_.get()) {
55 // Hack to flush write buffers before quitting. 57 // Hack to flush write buffers before quitting.
56 // TODO(vtl): Remove this once |Channel| has a 58 // TODO(vtl): Remove this once |Channel| has a
57 // |FlushWriteBufferAndShutdown()| (or whatever). 59 // |FlushWriteBufferAndShutdown()| (or whatever).
58 while (!channel_->IsWriteBufferEmpty()) 60 while (!channel_->IsWriteBufferEmpty())
59 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(20)); 61 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(20));
60 62
61 test_io_thread_.PostTaskAndWait( 63 test_io_thread_.PostTaskAndWait(
62 FROM_HERE, base::Bind(&ChannelThread::ShutdownChannelOnIOThread, 64 FROM_HERE,
63 base::Unretained(this))); 65 base::Bind(&ChannelThread::ShutdownChannelOnIOThread,
66 base::Unretained(this)));
64 } 67 }
65 test_io_thread_.Stop(); 68 test_io_thread_.Stop();
66 } 69 }
67 70
68 void ChannelThread::InitChannelOnIOThread( 71 void ChannelThread::InitChannelOnIOThread(
69 embedder::ScopedPlatformHandle platform_handle, 72 embedder::ScopedPlatformHandle platform_handle,
70 scoped_refptr<ChannelEndpoint> channel_endpoint) { 73 scoped_refptr<ChannelEndpoint> channel_endpoint) {
71 CHECK_EQ(base::MessageLoop::current(), test_io_thread_.message_loop()); 74 CHECK_EQ(base::MessageLoop::current(), test_io_thread_.message_loop());
72 CHECK(platform_handle.is_valid()); 75 CHECK(platform_handle.is_valid());
73 76
(...skipping 25 matching lines...) Expand all
99 } 102 }
100 103
101 void MultiprocessMessagePipeTestBase::Init(scoped_refptr<ChannelEndpoint> ep) { 104 void MultiprocessMessagePipeTestBase::Init(scoped_refptr<ChannelEndpoint> ep) {
102 channel_thread_.Start(helper_.server_platform_handle.Pass(), ep); 105 channel_thread_.Start(helper_.server_platform_handle.Pass(), ep);
103 } 106 }
104 #endif 107 #endif
105 108
106 } // namespace test 109 } // namespace test
107 } // namespace system 110 } // namespace system
108 } // namespace mojo 111 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/message_pipe_perftest.cc ('k') | mojo/edk/system/message_pipe_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698