OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // Illustrates how to use worker threads that issue completion callbacks | 5 // Illustrates how to use worker threads that issue completion callbacks |
6 | 6 |
| 7 #include "base/logging.h" |
| 8 #include "base/message_loop.h" |
| 9 #include "base/task.h" |
7 #include "base/threading/worker_pool.h" | 10 #include "base/threading/worker_pool.h" |
8 #include "net/base/completion_callback.h" | 11 #include "net/base/completion_callback.h" |
9 #include "net/base/test_completion_callback.h" | 12 #include "net/base/test_completion_callback.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
11 #include "testing/platform_test.h" | 14 #include "testing/platform_test.h" |
12 | 15 |
13 typedef PlatformTest TestCompletionCallbackTest; | 16 typedef PlatformTest TestCompletionCallbackTest; |
14 | 17 |
15 using net::CompletionCallback; | 18 using net::CompletionCallback; |
16 | 19 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 TEST_F(TestCompletionCallbackTest, Simple) { | 118 TEST_F(TestCompletionCallbackTest, Simple) { |
116 ExampleEmployer boss; | 119 ExampleEmployer boss; |
117 TestCompletionCallback callback; | 120 TestCompletionCallback callback; |
118 bool queued = boss.DoSomething(&callback); | 121 bool queued = boss.DoSomething(&callback); |
119 EXPECT_EQ(queued, true); | 122 EXPECT_EQ(queued, true); |
120 int result = callback.WaitForResult(); | 123 int result = callback.WaitForResult(); |
121 EXPECT_EQ(result, kMagicResult); | 124 EXPECT_EQ(result, kMagicResult); |
122 } | 125 } |
123 | 126 |
124 // TODO: test deleting ExampleEmployer while work outstanding | 127 // TODO: test deleting ExampleEmployer while work outstanding |
OLD | NEW |