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 "chrome/common/chrome_plugin_lib.h" | 8 #include "chrome/common/chrome_plugin_lib.h" |
9 #include "chrome/common/net/url_fetcher.h" | 9 #include "chrome/common/net/url_fetcher.h" |
10 #include "chrome/common/net/url_fetcher_protect.h" | 10 #include "chrome/common/net/url_fetcher_protect.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 public: | 27 public: |
28 explicit TestURLRequestContextGetter( | 28 explicit TestURLRequestContextGetter( |
29 base::MessageLoopProxy* io_message_loop_proxy) | 29 base::MessageLoopProxy* io_message_loop_proxy) |
30 : io_message_loop_proxy_(io_message_loop_proxy) { | 30 : io_message_loop_proxy_(io_message_loop_proxy) { |
31 } | 31 } |
32 virtual URLRequestContext* GetURLRequestContext() { | 32 virtual URLRequestContext* GetURLRequestContext() { |
33 if (!context_) | 33 if (!context_) |
34 context_ = new TestURLRequestContext(); | 34 context_ = new TestURLRequestContext(); |
35 return context_; | 35 return context_; |
36 } | 36 } |
37 virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() { | 37 virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() const { |
38 return io_message_loop_proxy_; | 38 return io_message_loop_proxy_; |
39 } | 39 } |
40 | 40 |
41 protected: | 41 protected: |
42 scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; | 42 scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; |
43 | 43 |
44 private: | 44 private: |
45 ~TestURLRequestContextGetter() {} | 45 ~TestURLRequestContextGetter() {} |
46 | 46 |
47 scoped_refptr<URLRequestContext> context_; | 47 scoped_refptr<URLRequestContext> context_; |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 : io_message_loop_proxy_(io_message_loop_proxy), | 192 : io_message_loop_proxy_(io_message_loop_proxy), |
193 context_created_(false, false) { | 193 context_created_(false, false) { |
194 } | 194 } |
195 virtual URLRequestContext* GetURLRequestContext() { | 195 virtual URLRequestContext* GetURLRequestContext() { |
196 if (!context_) { | 196 if (!context_) { |
197 context_ = new CancelTestURLRequestContext(); | 197 context_ = new CancelTestURLRequestContext(); |
198 context_created_.Signal(); | 198 context_created_.Signal(); |
199 } | 199 } |
200 return context_; | 200 return context_; |
201 } | 201 } |
202 virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() { | 202 virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() const { |
203 return io_message_loop_proxy_; | 203 return io_message_loop_proxy_; |
204 } | 204 } |
205 void WaitForContextCreation() { | 205 void WaitForContextCreation() { |
206 context_created_.Wait(); | 206 context_created_.Wait(); |
207 } | 207 } |
208 | 208 |
209 private: | 209 private: |
210 ~CancelTestURLRequestContextGetter() {} | 210 ~CancelTestURLRequestContextGetter() {} |
211 | 211 |
212 scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; | 212 scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 // time difference from now). | 604 // time difference from now). |
605 | 605 |
606 base::Thread t("URLFetcher test thread"); | 606 base::Thread t("URLFetcher test thread"); |
607 ASSERT_TRUE(t.Start()); | 607 ASSERT_TRUE(t.Start()); |
608 t.message_loop()->PostTask(FROM_HERE, new FetcherWrapperTask(this, url)); | 608 t.message_loop()->PostTask(FROM_HERE, new FetcherWrapperTask(this, url)); |
609 | 609 |
610 MessageLoop::current()->Run(); | 610 MessageLoop::current()->Run(); |
611 } | 611 } |
612 | 612 |
613 } // namespace. | 613 } // namespace. |
OLD | NEW |