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 "content/common/net/url_fetcher_impl.h" | 5 #include "content/common/net/url_fetcher_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop_proxy.h" | 8 #include "base/message_loop_proxy.h" |
9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
10 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 using base::Time; | 25 using base::Time; |
26 using base::TimeDelta; | 26 using base::TimeDelta; |
27 | 27 |
28 // TODO(eroman): Add a regression test for http://crbug.com/40505. | 28 // TODO(eroman): Add a regression test for http://crbug.com/40505. |
29 | 29 |
30 namespace { | 30 namespace { |
31 | 31 |
32 const FilePath::CharType kDocRoot[] = FILE_PATH_LITERAL("chrome/test/data"); | 32 const FilePath::CharType kDocRoot[] = FILE_PATH_LITERAL("chrome/test/data"); |
33 const char kTestServerFilePrefix[] = "files/"; | 33 const char kTestServerFilePrefix[] = "files/"; |
34 | 34 |
35 class TestURLRequestContextGetter : public net::URLRequestContextGetter { | |
36 public: | |
37 explicit TestURLRequestContextGetter( | |
38 base::MessageLoopProxy* io_message_loop_proxy) | |
39 : io_message_loop_proxy_(io_message_loop_proxy) { | |
40 } | |
41 virtual net::URLRequestContext* GetURLRequestContext() { | |
42 if (!context_) | |
43 context_ = new TestURLRequestContext(); | |
44 return context_; | |
45 } | |
46 virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() const { | |
47 return io_message_loop_proxy_; | |
48 } | |
49 | |
50 protected: | |
51 scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; | |
52 | |
53 private: | |
54 virtual ~TestURLRequestContextGetter() {} | |
55 | |
56 scoped_refptr<net::URLRequestContext> context_; | |
57 }; | |
58 | |
59 } // namespace | 35 } // namespace |
60 | 36 |
61 class URLFetcherTest : public testing::Test, | 37 class URLFetcherTest : public testing::Test, |
62 public content::URLFetcherDelegate { | 38 public content::URLFetcherDelegate { |
63 public: | 39 public: |
64 URLFetcherTest() : fetcher_(NULL) { } | 40 URLFetcherTest() : fetcher_(NULL) { } |
65 | 41 |
66 static int GetNumFetcherCores() { | 42 static int GetNumFetcherCores() { |
67 return URLFetcherImpl::GetNumFetcherCores(); | 43 return URLFetcherImpl::GetNumFetcherCores(); |
68 } | 44 } |
(...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
913 io_message_loop_proxy()->PostTaskAndReply( | 889 io_message_loop_proxy()->PostTaskAndReply( |
914 FROM_HERE, | 890 FROM_HERE, |
915 base::Bind(&CancelAllOnIO), | 891 base::Bind(&CancelAllOnIO), |
916 MessageLoop::QuitClosure()); | 892 MessageLoop::QuitClosure()); |
917 MessageLoop::current()->Run(); | 893 MessageLoop::current()->Run(); |
918 EXPECT_EQ(0, GetNumFetcherCores()); | 894 EXPECT_EQ(0, GetNumFetcherCores()); |
919 delete fetcher_; | 895 delete fetcher_; |
920 } | 896 } |
921 | 897 |
922 } // namespace. | 898 } // namespace. |
OLD | NEW |