| 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 #ifndef NET_URL_REQUEST_TEST_URL_FETCHER_FACTORY_H_ | 5 #ifndef NET_URL_REQUEST_TEST_URL_FETCHER_FACTORY_H_ |
| 6 #define NET_URL_REQUEST_TEST_URL_FETCHER_FACTORY_H_ | 6 #define NET_URL_REQUEST_TEST_URL_FETCHER_FACTORY_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <list> | 10 #include <list> |
| 11 #include <map> | 11 #include <map> |
| 12 #include <memory> | 12 #include <memory> |
| 13 #include <string> | 13 #include <string> |
| 14 #include <utility> | 14 #include <utility> |
| 15 | 15 |
| 16 #include "base/callback.h" | 16 #include "base/callback.h" |
| 17 #include "base/compiler_specific.h" | 17 #include "base/compiler_specific.h" |
| 18 #include "base/files/file_path.h" | 18 #include "base/files/file_path.h" |
| 19 #include "base/macros.h" | 19 #include "base/macros.h" |
| 20 #include "base/memory/weak_ptr.h" | 20 #include "base/memory/weak_ptr.h" |
| 21 #include "base/sequenced_task_runner.h" | 21 #include "base/sequenced_task_runner.h" |
| 22 #include "base/threading/non_thread_safe.h" | 22 #include "base/threading/thread_checker.h" |
| 23 #include "net/http/http_request_headers.h" | 23 #include "net/http/http_request_headers.h" |
| 24 #include "net/http/http_status_code.h" | 24 #include "net/http/http_status_code.h" |
| 25 #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" | 25 #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" |
| 26 #include "net/url_request/url_fetcher_factory.h" | 26 #include "net/url_request/url_fetcher_factory.h" |
| 27 #include "net/url_request/url_request_status.h" | 27 #include "net/url_request/url_request_status.h" |
| 28 #include "url/gurl.h" | 28 #include "url/gurl.h" |
| 29 | 29 |
| 30 namespace net { | 30 namespace net { |
| 31 | 31 |
| 32 // Changes URLFetcher's Factory for the lifetime of the object. | 32 // Changes URLFetcher's Factory for the lifetime of the object. |
| 33 // Note that this scoper cannot be nested (to make it even harder to misuse). | 33 // Note that this scoper cannot be nested (to make it even harder to misuse). |
| 34 class ScopedURLFetcherFactory : public base::NonThreadSafe { | 34 class ScopedURLFetcherFactory { |
| 35 public: | 35 public: |
| 36 explicit ScopedURLFetcherFactory(URLFetcherFactory* factory); | 36 explicit ScopedURLFetcherFactory(URLFetcherFactory* factory); |
| 37 virtual ~ScopedURLFetcherFactory(); | 37 virtual ~ScopedURLFetcherFactory(); |
| 38 | 38 |
| 39 private: | 39 private: |
| 40 THREAD_CHECKER(thread_checker_); |
| 41 |
| 40 DISALLOW_COPY_AND_ASSIGN(ScopedURLFetcherFactory); | 42 DISALLOW_COPY_AND_ASSIGN(ScopedURLFetcherFactory); |
| 41 }; | 43 }; |
| 42 | 44 |
| 43 // TestURLFetcher and TestURLFetcherFactory are used for testing consumers of | 45 // TestURLFetcher and TestURLFetcherFactory are used for testing consumers of |
| 44 // URLFetcher. TestURLFetcherFactory is a URLFetcherFactory that creates | 46 // URLFetcher. TestURLFetcherFactory is a URLFetcherFactory that creates |
| 45 // TestURLFetchers. TestURLFetcher::Start is overriden to do nothing. It is | 47 // TestURLFetchers. TestURLFetcher::Start is overriden to do nothing. It is |
| 46 // expected that you'll grab the delegate from the TestURLFetcher and invoke | 48 // expected that you'll grab the delegate from the TestURLFetcher and invoke |
| 47 // the callback method when appropriate. In this way it's easy to mock a | 49 // the callback method when appropriate. In this way it's easy to mock a |
| 48 // URLFetcher. | 50 // URLFetcher. |
| 49 // Typical usage: | 51 // Typical usage: |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 int id, | 475 int id, |
| 474 const GURL& url, | 476 const GURL& url, |
| 475 URLFetcher::RequestType request_type, | 477 URLFetcher::RequestType request_type, |
| 476 URLFetcherDelegate* d, | 478 URLFetcherDelegate* d, |
| 477 NetworkTrafficAnnotationTag traffic_annotation) override; | 479 NetworkTrafficAnnotationTag traffic_annotation) override; |
| 478 }; | 480 }; |
| 479 | 481 |
| 480 } // namespace net | 482 } // namespace net |
| 481 | 483 |
| 482 #endif // NET_URL_REQUEST_TEST_URL_FETCHER_FACTORY_H_ | 484 #endif // NET_URL_REQUEST_TEST_URL_FETCHER_FACTORY_H_ |
| OLD | NEW |