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

Side by Side Diff: mojo/public/cpp/bindings/tests/connector_unittest.cc

Issue 2725133002: Mojo: Armed Watchers (Closed)
Patch Set: . Created 3 years, 9 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/public/cpp/bindings/connector.h" 5 #include "mojo/public/cpp/bindings/connector.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdlib.h> 8 #include <stdlib.h>
9 #include <string.h> 9 #include <string.h>
10 #include <utility> 10 #include <utility>
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 connector0.Accept(&message); 561 connector0.Accept(&message);
562 562
563 base::RunLoop run_loop; 563 base::RunLoop run_loop;
564 MessageAccumulator accumulator; 564 MessageAccumulator accumulator;
565 // When the accumulator gets the first message it spins a nested message 565 // When the accumulator gets the first message it spins a nested message
566 // loop. The loop is quit when another message is received. 566 // loop. The loop is quit when another message is received.
567 accumulator.set_closure(base::Bind(&AccumulateWithNestedLoop, &accumulator, 567 accumulator.set_closure(base::Bind(&AccumulateWithNestedLoop, &accumulator,
568 run_loop.QuitClosure())); 568 run_loop.QuitClosure()));
569 connector1.set_incoming_receiver(&accumulator); 569 connector1.set_incoming_receiver(&accumulator);
570 570
571 connector1.EnableNestedDispatch(true);
571 run_loop.Run(); 572 run_loop.Run();
572 573
573 ASSERT_EQ(2u, accumulator.size()); 574 ASSERT_EQ(2u, accumulator.size());
574 } 575 }
575 576
576 TEST_F(ConnectorTest, DestroyOnDifferentThreadAfterClose) { 577 TEST_F(ConnectorTest, DestroyOnDifferentThreadAfterClose) {
577 std::unique_ptr<Connector> connector( 578 std::unique_ptr<Connector> connector(
578 new Connector(std::move(handle0_), Connector::SINGLE_THREADED_SEND, 579 new Connector(std::move(handle0_), Connector::SINGLE_THREADED_SEND,
579 base::ThreadTaskRunnerHandle::Get())); 580 base::ThreadTaskRunnerHandle::Get()));
580 581
581 connector->CloseMessagePipe(); 582 connector->CloseMessagePipe();
582 583
583 base::Thread another_thread("ThreadForDestroyingConnector"); 584 base::Thread another_thread("ThreadForDestroyingConnector");
584 another_thread.Start(); 585 another_thread.Start();
585 586
586 base::RunLoop run_loop; 587 base::RunLoop run_loop;
587 another_thread.task_runner()->PostTaskAndReply( 588 another_thread.task_runner()->PostTaskAndReply(
588 FROM_HERE, 589 FROM_HERE,
589 base::Bind( 590 base::Bind(
590 [](std::unique_ptr<Connector> connector) { connector.reset(); }, 591 [](std::unique_ptr<Connector> connector) { connector.reset(); },
591 base::Passed(std::move(connector))), 592 base::Passed(std::move(connector))),
592 run_loop.QuitClosure()); 593 run_loop.QuitClosure());
593 594
594 run_loop.Run(); 595 run_loop.Run();
595 } 596 }
596 597
597 } // namespace 598 } // namespace
598 } // namespace test 599 } // namespace test
599 } // namespace mojo 600 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698