Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/browser/net/resolve_proxy_msg_helper.h" | 5 #include "chrome/browser/net/resolve_proxy_msg_helper.h" |
| 6 | 6 |
| 7 #include "base/waitable_event.h" | 7 #include "base/waitable_event.h" |
| 8 #include "net/base/net_errors.h" | 8 #include "net/base/net_errors.h" |
| 9 #include "net/proxy/proxy_config_service.h" | 9 #include "net/proxy/proxy_config_service.h" |
| 10 #include "net/proxy/proxy_resolver.h" | 10 #include "net/proxy/proxy_resolver.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 std::deque<ResultFuture*> futures_; | 127 std::deque<ResultFuture*> futures_; |
| 128 scoped_ptr<ResolveProxyMsgHelper> resolve_proxy_msg_helper_; | 128 scoped_ptr<ResolveProxyMsgHelper> resolve_proxy_msg_helper_; |
| 129 }; | 129 }; |
| 130 | 130 |
| 131 // Helper class to start async requests on an io thread, and return a | 131 // Helper class to start async requests on an io thread, and return a |
| 132 // result future. The caller then uses ResultFuture::WaitUntilDone() to | 132 // result future. The caller then uses ResultFuture::WaitUntilDone() to |
| 133 // get at the results. It "bridges" the originating thread with the helper | 133 // get at the results. It "bridges" the originating thread with the helper |
| 134 // io thread. | 134 // io thread. |
| 135 class RunnerBridge { | 135 class RunnerBridge { |
| 136 public: | 136 public: |
| 137 RunnerBridge() : io_thread_("io_thread"), done_(true, false) { | 137 RunnerBridge() : io_thread_("io_thread"), done_(false, false) { |
|
Dean McNamee
2009/03/24 12:31:21
Was this just a bug?
| |
| 138 // Start an io thread where we will run the async requests. | 138 // Start an io thread where we will run the async requests. |
| 139 base::Thread::Options options; | 139 base::Thread::Options options; |
| 140 options.message_loop_type = MessageLoop::TYPE_IO; | 140 options.message_loop_type = MessageLoop::TYPE_IO; |
| 141 io_thread_.StartWithOptions(options); | 141 io_thread_.StartWithOptions(options); |
| 142 | 142 |
| 143 // Construct the state that lives on io thread. | 143 // Construct the state that lives on io thread. |
| 144 io_thread_.message_loop()->PostTask(FROM_HERE, NewRunnableMethod( | 144 io_thread_.message_loop()->PostTask(FROM_HERE, NewRunnableMethod( |
| 145 this, &RunnerBridge::DoConstruct)); | 145 this, &RunnerBridge::DoConstruct)); |
| 146 done_.Wait(); | 146 done_.Wait(); |
| 147 } | 147 } |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 344 EXPECT_FALSE( | 344 EXPECT_FALSE( |
| 345 result1->TimedWaitUntilDone(base::TimeDelta::FromMilliseconds(2))); | 345 result1->TimedWaitUntilDone(base::TimeDelta::FromMilliseconds(2))); |
| 346 EXPECT_FALSE( | 346 EXPECT_FALSE( |
| 347 result2->TimedWaitUntilDone(base::TimeDelta::FromMilliseconds(2))); | 347 result2->TimedWaitUntilDone(base::TimeDelta::FromMilliseconds(2))); |
| 348 EXPECT_FALSE( | 348 EXPECT_FALSE( |
| 349 result3->TimedWaitUntilDone(base::TimeDelta::FromMilliseconds(2))); | 349 result3->TimedWaitUntilDone(base::TimeDelta::FromMilliseconds(2))); |
| 350 | 350 |
| 351 // It should also be the case that msg1, msg2, msg3 were deleted by the | 351 // It should also be the case that msg1, msg2, msg3 were deleted by the |
| 352 // cancellation. (Else will show up as a leak in Purify). | 352 // cancellation. (Else will show up as a leak in Purify). |
| 353 } | 353 } |
| OLD | NEW |