| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 1914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1925 { | 1925 { |
| 1926 base::RunLoop run_loop; | 1926 base::RunLoop run_loop; |
| 1927 int count = 0; | 1927 int count = 0; |
| 1928 auto callback = base::Bind( | 1928 auto callback = base::Bind( |
| 1929 [] (base::RunLoop* loop, int* count, MojoResult result) { | 1929 [] (base::RunLoop* loop, int* count, MojoResult result) { |
| 1930 EXPECT_EQ(MOJO_RESULT_OK, result); | 1930 EXPECT_EQ(MOJO_RESULT_OK, result); |
| 1931 if (++*count == 2) | 1931 if (++*count == 2) |
| 1932 loop->Quit(); | 1932 loop->Quit(); |
| 1933 }, | 1933 }, |
| 1934 &run_loop, &count); | 1934 &run_loop, &count); |
| 1935 Watcher producer_watcher(FROM_HERE), consumer_watcher(FROM_HERE); | 1935 Watcher producer_watcher(FROM_HERE, Watcher::ArmingPolicy::AUTOMATIC); |
| 1936 Watcher consumer_watcher(FROM_HERE, Watcher::ArmingPolicy::AUTOMATIC); |
| 1936 producer_watcher.Start( | 1937 producer_watcher.Start( |
| 1937 Handle(producers[1]), MOJO_HANDLE_SIGNAL_PEER_CLOSED, callback); | 1938 Handle(producers[1]), MOJO_HANDLE_SIGNAL_PEER_CLOSED, callback); |
| 1938 consumer_watcher.Start( | 1939 consumer_watcher.Start( |
| 1939 Handle(consumers[1]), MOJO_HANDLE_SIGNAL_PEER_CLOSED, callback); | 1940 Handle(consumers[1]), MOJO_HANDLE_SIGNAL_PEER_CLOSED, callback); |
| 1940 run_loop.Run(); | 1941 run_loop.Run(); |
| 1942 EXPECT_EQ(2, count); |
| 1941 } | 1943 } |
| 1942 | 1944 |
| 1943 // Wait on producer 2 by polling with MojoWriteData. | 1945 // Wait on producer 2 by polling with MojoWriteData. |
| 1944 MojoResult result; | 1946 MojoResult result; |
| 1945 do { | 1947 do { |
| 1946 uint32_t num_bytes = 0; | 1948 uint32_t num_bytes = 0; |
| 1947 result = MojoWriteData( | 1949 result = MojoWriteData( |
| 1948 producers[2], nullptr, &num_bytes, MOJO_WRITE_DATA_FLAG_NONE); | 1950 producers[2], nullptr, &num_bytes, MOJO_WRITE_DATA_FLAG_NONE); |
| 1949 } while (result == MOJO_RESULT_OK); | 1951 } while (result == MOJO_RESULT_OK); |
| 1950 EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, result); | 1952 EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, result); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1981 for (size_t i = 3; i < 6; ++i) | 1983 for (size_t i = 3; i < 6; ++i) |
| 1982 CloseHandle(producers[i]); | 1984 CloseHandle(producers[i]); |
| 1983 END_CHILD() | 1985 END_CHILD() |
| 1984 } | 1986 } |
| 1985 | 1987 |
| 1986 #endif // !defined(OS_IOS) | 1988 #endif // !defined(OS_IOS) |
| 1987 | 1989 |
| 1988 } // namespace | 1990 } // namespace |
| 1989 } // namespace edk | 1991 } // namespace edk |
| 1990 } // namespace mojo | 1992 } // namespace mojo |
| OLD | NEW |