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 #include "base/message_loop_proxy.h" | 5 #include "base/message_loop_proxy.h" |
6 #include "base/thread.h" | 6 #include "base/thread.h" |
7 #include "base/waitable_event.h" | 7 #include "base/waitable_event.h" |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 #include "chrome/common/chrome_plugin_lib.h" | 9 #include "chrome/common/chrome_plugin_lib.h" |
10 #include "chrome/common/net/url_fetcher.h" | 10 #include "chrome/common/net/url_fetcher.h" |
11 #include "chrome/common/net/url_fetcher_protect.h" | 11 #include "chrome/common/net/url_fetcher_protect.h" |
12 #include "chrome/common/net/url_request_context_getter.h" | 12 #include "chrome/common/net/url_request_context_getter.h" |
13 #include "net/http/http_response_headers.h" | 13 #include "net/http/http_response_headers.h" |
14 #include "net/url_request/url_request_unittest.h" | 14 #include "net/url_request/url_request_unittest.h" |
15 #include "net/test/test_server.h" | 15 #include "net/test/test_server.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
17 | 17 |
18 #if defined(OS_LINUX) | 18 #if defined(USE_NSS) |
19 #include "net/ocsp/nss_ocsp.h" | 19 #include "net/ocsp/nss_ocsp.h" |
20 #endif | 20 #endif |
21 | 21 |
22 using base::Time; | 22 using base::Time; |
23 using base::TimeDelta; | 23 using base::TimeDelta; |
24 | 24 |
25 // TODO(eroman): Add a regression test for http://crbug.com/40505. | 25 // TODO(eroman): Add a regression test for http://crbug.com/40505. |
26 | 26 |
27 namespace { | 27 namespace { |
28 | 28 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 } | 72 } |
73 | 73 |
74 protected: | 74 protected: |
75 virtual void SetUp() { | 75 virtual void SetUp() { |
76 testing::Test::SetUp(); | 76 testing::Test::SetUp(); |
77 | 77 |
78 io_message_loop_proxy_ = base::MessageLoopProxy::CreateForCurrentThread(); | 78 io_message_loop_proxy_ = base::MessageLoopProxy::CreateForCurrentThread(); |
79 | 79 |
80 // Ensure that any plugin operations done by other tests are cleaned up. | 80 // Ensure that any plugin operations done by other tests are cleaned up. |
81 ChromePluginLib::UnloadAllPlugins(); | 81 ChromePluginLib::UnloadAllPlugins(); |
82 #if defined(OS_LINUX) | 82 #if defined(USE_NSS) |
83 net::EnsureOCSPInit(); | 83 net::EnsureOCSPInit(); |
84 #endif | 84 #endif |
85 } | 85 } |
86 | 86 |
87 virtual void TearDown() { | 87 virtual void TearDown() { |
88 #if defined(OS_LINUX) | 88 #if defined(USE_NSS) |
89 net::ShutdownOCSP(); | 89 net::ShutdownOCSP(); |
90 #endif | 90 #endif |
91 } | 91 } |
92 | 92 |
93 // URLFetcher is designed to run on the main UI thread, but in our tests | 93 // URLFetcher is designed to run on the main UI thread, but in our tests |
94 // we assume that the current thread is the IO thread where the URLFetcher | 94 // we assume that the current thread is the IO thread where the URLFetcher |
95 // dispatches its requests to. When we wish to simulate being used from | 95 // dispatches its requests to. When we wish to simulate being used from |
96 // a UI thread, we dispatch a worker thread to do so. | 96 // a UI thread, we dispatch a worker thread to do so. |
97 MessageLoopForIO io_loop_; | 97 MessageLoopForIO io_loop_; |
98 scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; | 98 scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; |
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 // time difference from now). | 619 // time difference from now). |
620 | 620 |
621 base::Thread t("URLFetcher test thread"); | 621 base::Thread t("URLFetcher test thread"); |
622 ASSERT_TRUE(t.Start()); | 622 ASSERT_TRUE(t.Start()); |
623 t.message_loop()->PostTask(FROM_HERE, new FetcherWrapperTask(this, url)); | 623 t.message_loop()->PostTask(FROM_HERE, new FetcherWrapperTask(this, url)); |
624 | 624 |
625 MessageLoop::current()->Run(); | 625 MessageLoop::current()->Run(); |
626 } | 626 } |
627 | 627 |
628 } // namespace. | 628 } // namespace. |
OLD | NEW |