Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: chrome/browser/net/url_fetcher_unittest.cc

Issue 1837003: Created a stock implementation of the MessageLoopProxy interface than can be ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Rearranged header files Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/net/url_fetcher.cc ('k') | chrome/browser/net/url_request_context_getter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/browser/chrome_thread.h" 8 #include "chrome/browser/chrome_thread.h"
9 #include "chrome/browser/net/url_fetcher.h" 9 #include "chrome/browser/net/url_fetcher.h"
10 #include "chrome/browser/net/url_fetcher_protect.h" 10 #include "chrome/browser/net/url_fetcher_protect.h"
(...skipping 13 matching lines...) Expand all
24 24
25 const wchar_t kDocRoot[] = L"chrome/test/data"; 25 const wchar_t kDocRoot[] = L"chrome/test/data";
26 26
27 class TestURLRequestContextGetter : public URLRequestContextGetter { 27 class TestURLRequestContextGetter : public URLRequestContextGetter {
28 public: 28 public:
29 virtual URLRequestContext* GetURLRequestContext() { 29 virtual URLRequestContext* GetURLRequestContext() {
30 if (!context_) 30 if (!context_)
31 context_ = new TestURLRequestContext(); 31 context_ = new TestURLRequestContext();
32 return context_; 32 return context_;
33 } 33 }
34 virtual scoped_refptr<MessageLoopProxy> GetIOMessageLoopProxy() { 34 virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() {
35 return ChromeThread::GetMessageLoopProxyForThread(ChromeThread::IO); 35 return ChromeThread::GetMessageLoopProxyForThread(ChromeThread::IO);
36 } 36 }
37 37
38 private: 38 private:
39 ~TestURLRequestContextGetter() {} 39 ~TestURLRequestContextGetter() {}
40 40
41 scoped_refptr<URLRequestContext> context_; 41 scoped_refptr<URLRequestContext> context_;
42 }; 42 };
43 43
44 class URLFetcherTest : public testing::Test, public URLFetcher::Delegate { 44 class URLFetcherTest : public testing::Test, public URLFetcher::Delegate {
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 public: 178 public:
179 CancelTestURLRequestContextGetter() : context_created_(false, false) { 179 CancelTestURLRequestContextGetter() : context_created_(false, false) {
180 } 180 }
181 virtual URLRequestContext* GetURLRequestContext() { 181 virtual URLRequestContext* GetURLRequestContext() {
182 if (!context_) { 182 if (!context_) {
183 context_ = new CancelTestURLRequestContext(); 183 context_ = new CancelTestURLRequestContext();
184 context_created_.Signal(); 184 context_created_.Signal();
185 } 185 }
186 return context_; 186 return context_;
187 } 187 }
188 virtual scoped_refptr<MessageLoopProxy> GetIOMessageLoopProxy() { 188 virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() {
189 return ChromeThread::GetMessageLoopProxyForThread(ChromeThread::IO); 189 return ChromeThread::GetMessageLoopProxyForThread(ChromeThread::IO);
190 } 190 }
191 void WaitForContextCreation() { 191 void WaitForContextCreation() {
192 context_created_.Wait(); 192 context_created_.Wait();
193 } 193 }
194 194
195 private: 195 private:
196 ~CancelTestURLRequestContextGetter() {} 196 ~CancelTestURLRequestContextGetter() {}
197 197
198 base::WaitableEvent context_created_; 198 base::WaitableEvent context_created_;
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 // time difference from now). 590 // time difference from now).
591 591
592 base::Thread t("URLFetcher test thread"); 592 base::Thread t("URLFetcher test thread");
593 ASSERT_TRUE(t.Start()); 593 ASSERT_TRUE(t.Start());
594 t.message_loop()->PostTask(FROM_HERE, new FetcherWrapperTask(this, url)); 594 t.message_loop()->PostTask(FROM_HERE, new FetcherWrapperTask(this, url));
595 595
596 MessageLoop::current()->Run(); 596 MessageLoop::current()->Run();
597 } 597 }
598 598
599 } // namespace. 599 } // namespace.
OLDNEW
« no previous file with comments | « chrome/browser/net/url_fetcher.cc ('k') | chrome/browser/net/url_request_context_getter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698