| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CONTENT_TEST_TEST_URL_FETCHER_FACTORY_H_ | 5 #ifndef CONTENT_TEST_TEST_URL_FETCHER_FACTORY_H_ |
| 6 #define CONTENT_TEST_TEST_URL_FETCHER_FACTORY_H_ | 6 #define CONTENT_TEST_TEST_URL_FETCHER_FACTORY_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <list> | 9 #include <list> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 // TestURLFetcher and TestURLFetcherFactory are used for testing consumers of | 31 // TestURLFetcher and TestURLFetcherFactory are used for testing consumers of |
| 32 // URLFetcher. TestURLFetcherFactory is a URLFetcher::Factory that creates | 32 // URLFetcher. TestURLFetcherFactory is a URLFetcher::Factory that creates |
| 33 // TestURLFetchers. TestURLFetcher::Start is overriden to do nothing. It is | 33 // TestURLFetchers. TestURLFetcher::Start is overriden to do nothing. It is |
| 34 // expected that you'll grab the delegate from the TestURLFetcher and invoke | 34 // expected that you'll grab the delegate from the TestURLFetcher and invoke |
| 35 // the callback method when appropriate. In this way it's easy to mock a | 35 // the callback method when appropriate. In this way it's easy to mock a |
| 36 // URLFetcher. | 36 // URLFetcher. |
| 37 // Typical usage: | 37 // Typical usage: |
| 38 // // TestURLFetcher requires a MessageLoop: | 38 // // TestURLFetcher requires a MessageLoop: |
| 39 // MessageLoopForUI message_loop; | 39 // MessageLoopForUI message_loop; |
| 40 // // And io_thread to release URLRequestContextGetter in URLFetcher::Core. | 40 // // And io_thread to release URLRequestContextGetter in URLFetcher::Core. |
| 41 // BrowserThread io_thread(BrowserThread::IO, &message_loop); | 41 // BrowserThreadImpl io_thread(BrowserThread::IO, &message_loop); |
| 42 // // Create factory (it automatically sets itself as URLFetcher's factory). | 42 // // Create factory (it automatically sets itself as URLFetcher's factory). |
| 43 // TestURLFetcherFactory factory; | 43 // TestURLFetcherFactory factory; |
| 44 // // Do something that triggers creation of a URLFetcher. | 44 // // Do something that triggers creation of a URLFetcher. |
| 45 // TestURLFetcher* fetcher = factory.GetFetcherByID(expected_id); | 45 // TestURLFetcher* fetcher = factory.GetFetcherByID(expected_id); |
| 46 // DCHECK(fetcher); | 46 // DCHECK(fetcher); |
| 47 // // Notify delegate with whatever data you want. | 47 // // Notify delegate with whatever data you want. |
| 48 // fetcher->delegate()->OnURLFetchComplete(...); | 48 // fetcher->delegate()->OnURLFetchComplete(...); |
| 49 // // Make sure consumer of URLFetcher does the right thing. | 49 // // Make sure consumer of URLFetcher does the right thing. |
| 50 // ... | 50 // ... |
| 51 // | 51 // |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 // This method will create a real URLFetcher. | 277 // This method will create a real URLFetcher. |
| 278 virtual content::URLFetcher* CreateURLFetcher( | 278 virtual content::URLFetcher* CreateURLFetcher( |
| 279 int id, | 279 int id, |
| 280 const GURL& url, | 280 const GURL& url, |
| 281 content::URLFetcher::RequestType request_type, | 281 content::URLFetcher::RequestType request_type, |
| 282 content::URLFetcherDelegate* d) OVERRIDE; | 282 content::URLFetcherDelegate* d) OVERRIDE; |
| 283 | 283 |
| 284 }; | 284 }; |
| 285 | 285 |
| 286 #endif // CONTENT_TEST_TEST_URL_FETCHER_FACTORY_H_ | 286 #endif // CONTENT_TEST_TEST_URL_FETCHER_FACTORY_H_ |
| OLD | NEW |