| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "net/base/completion_callback.h" | 8 #include "net/base/completion_callback.h" |
| 9 #include "net/base/test_completion_callback.h" | 9 #include "net/base/test_completion_callback.h" |
| 10 #include "base/platform_test.h" | |
| 11 #include "base/worker_pool.h" | 10 #include "base/worker_pool.h" |
| 11 #include "testing/platform_test.h" |
| 12 | 12 |
| 13 typedef PlatformTest TestCompletionCallbackTest; | 13 typedef PlatformTest TestCompletionCallbackTest; |
| 14 | 14 |
| 15 using net::CompletionCallback; | 15 using net::CompletionCallback; |
| 16 | 16 |
| 17 const int kMagicResult = 8888; | 17 const int kMagicResult = 8888; |
| 18 | 18 |
| 19 // ExampleEmployer is a toy version of HostResolver | 19 // ExampleEmployer is a toy version of HostResolver |
| 20 // TODO: restore damage done in extracting example from real code | 20 // TODO: restore damage done in extracting example from real code |
| 21 // (e.g. bring back real destructor, bring back comments) | 21 // (e.g. bring back real destructor, bring back comments) |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 TEST_F(TestCompletionCallbackTest, Simple) { | 111 TEST_F(TestCompletionCallbackTest, Simple) { |
| 112 ExampleEmployer boss; | 112 ExampleEmployer boss; |
| 113 TestCompletionCallback callback; | 113 TestCompletionCallback callback; |
| 114 bool queued = boss.DoSomething(&callback); | 114 bool queued = boss.DoSomething(&callback); |
| 115 EXPECT_EQ(queued, true); | 115 EXPECT_EQ(queued, true); |
| 116 int result = callback.WaitForResult(); | 116 int result = callback.WaitForResult(); |
| 117 EXPECT_EQ(result, kMagicResult); | 117 EXPECT_EQ(result, kMagicResult); |
| 118 } | 118 } |
| 119 | 119 |
| 120 // TODO: test deleting ExampleEmployer while work outstanding | 120 // TODO: test deleting ExampleEmployer while work outstanding |
| OLD | NEW |