OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/threading/worker_pool.h" | 10 #include "base/threading/worker_pool.h" |
11 #include "net/base/completion_callback.h" | 11 #include "net/base/completion_callback.h" |
12 #include "net/base/test_completion_callback.h" | 12 #include "net/base/test_completion_callback.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 #include "testing/platform_test.h" | 14 #include "testing/platform_test.h" |
15 | 15 |
16 typedef PlatformTest TestCompletionCallbackTest; | 16 typedef PlatformTest TestCompletionCallbackTest; |
17 | 17 |
18 const int kMagicResult = 8888; | 18 const int kMagicResult = 8888; |
19 | 19 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 TEST_F(TestCompletionCallbackTest, Simple) { | 114 TEST_F(TestCompletionCallbackTest, Simple) { |
115 ExampleEmployer boss; | 115 ExampleEmployer boss; |
116 net::TestCompletionCallback callback; | 116 net::TestCompletionCallback callback; |
117 bool queued = boss.DoSomething(callback.callback()); | 117 bool queued = boss.DoSomething(callback.callback()); |
118 EXPECT_EQ(queued, true); | 118 EXPECT_EQ(queued, true); |
119 int result = callback.WaitForResult(); | 119 int result = callback.WaitForResult(); |
120 EXPECT_EQ(result, kMagicResult); | 120 EXPECT_EQ(result, kMagicResult); |
121 } | 121 } |
122 | 122 |
123 // TODO: test deleting ExampleEmployer while work outstanding | 123 // TODO: test deleting ExampleEmployer while work outstanding |
OLD | NEW |