| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/memory/ref_counted.h" | 6 #include "base/memory/ref_counted.h" |
| 7 #include "base/message_loop_proxy.h" | 7 #include "base/message_loop_proxy.h" |
| 8 #include "base/synchronization/waitable_event.h" | 8 #include "base/synchronization/waitable_event.h" |
| 9 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 testing::Test::SetUp(); | 119 testing::Test::SetUp(); |
| 120 | 120 |
| 121 io_message_loop_proxy_ = base::MessageLoopProxy::current(); | 121 io_message_loop_proxy_ = base::MessageLoopProxy::current(); |
| 122 } | 122 } |
| 123 | 123 |
| 124 virtual void TearDown() { | 124 virtual void TearDown() { |
| 125 fetcher_ = NULL; | 125 fetcher_ = NULL; |
| 126 // Deleting the fetcher causes a task to be posted to the IO thread to | 126 // Deleting the fetcher causes a task to be posted to the IO thread to |
| 127 // release references to the URLRequestContextGetter. We need to run all | 127 // release references to the URLRequestContextGetter. We need to run all |
| 128 // pending tasks to execute that (this is the IO thread). | 128 // pending tasks to execute that (this is the IO thread). |
| 129 MessageLoop::current()->RunAllPending(); | 129 MessageLoop::current()->RunUntilIdle(); |
| 130 EXPECT_EQ(0, g_request_context_getter_instances); | 130 EXPECT_EQ(0, g_request_context_getter_instances); |
| 131 } | 131 } |
| 132 | 132 |
| 133 // URLFetcher is designed to run on the main UI thread, but in our tests | 133 // URLFetcher is designed to run on the main UI thread, but in our tests |
| 134 // we assume that the current thread is the IO thread where the URLFetcher | 134 // we assume that the current thread is the IO thread where the URLFetcher |
| 135 // dispatches its requests to. When we wish to simulate being used from | 135 // dispatches its requests to. When we wish to simulate being used from |
| 136 // a UI thread, we dispatch a worker thread to do so. | 136 // a UI thread, we dispatch a worker thread to do so. |
| 137 MessageLoopForIO io_loop_; | 137 MessageLoopForIO io_loop_; |
| 138 scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; | 138 scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; |
| 139 int max_retries_; | 139 int max_retries_; |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 FilePath(kDocRoot)); | 369 FilePath(kDocRoot)); |
| 370 ASSERT_TRUE(test_server.Start()); | 370 ASSERT_TRUE(test_server.Start()); |
| 371 | 371 |
| 372 GURL url(test_server.GetURL("defaultresponse")); | 372 GURL url(test_server.GetURL("defaultresponse")); |
| 373 CreateFetcher(url, 11); | 373 CreateFetcher(url, 11); |
| 374 | 374 |
| 375 MessageLoop::current()->Run(); | 375 MessageLoop::current()->Run(); |
| 376 } | 376 } |
| 377 | 377 |
| 378 } // namespace. | 378 } // namespace. |
| OLD | NEW |