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 CHROME_BROWSER_POLICY_TESTING_POLICY_URL_FETCHER_FACTORY_H_ | 5 #ifndef CHROME_BROWSER_POLICY_TESTING_POLICY_URL_FETCHER_FACTORY_H_ |
6 #define CHROME_BROWSER_POLICY_TESTING_POLICY_URL_FETCHER_FACTORY_H_ | 6 #define CHROME_BROWSER_POLICY_TESTING_POLICY_URL_FETCHER_FACTORY_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "content/public/test/test_url_fetcher_factory.h" | 13 #include "net/url_request/test_url_fetcher_factory.h" |
14 #include "net/url_request/url_fetcher_delegate.h" | 14 #include "net/url_request/url_fetcher_delegate.h" |
15 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
16 | 16 |
17 class GURL; | 17 class GURL; |
18 | 18 |
19 namespace enterprise_management { | 19 namespace enterprise_management { |
20 class DeviceManagementRequest; | 20 class DeviceManagementRequest; |
21 } | 21 } |
22 | 22 |
23 namespace policy { | 23 namespace policy { |
24 | 24 |
25 class EventLogger; | 25 class EventLogger; |
26 class LoggingWorkScheduler; | 26 class LoggingWorkScheduler; |
27 class TestingPolicyURLFetcher; | 27 class TestingPolicyURLFetcher; |
28 | 28 |
29 struct TestURLResponse { | 29 struct TestURLResponse { |
30 std::string response_data; | 30 std::string response_data; |
31 int response_code; | 31 int response_code; |
32 }; | 32 }; |
33 | 33 |
34 // Creates mock URLFetchers whose behavior can be controlled in tests. To do so | 34 // Creates mock URLFetchers whose behavior can be controlled in tests. To do so |
35 // set mock expectations on the method |Intercept|. | 35 // set mock expectations on the method |Intercept|. |
36 class TestingPolicyURLFetcherFactory : public net::URLFetcherFactory, | 36 class TestingPolicyURLFetcherFactory : public net::URLFetcherFactory, |
37 public ScopedURLFetcherFactory { | 37 public net::ScopedURLFetcherFactory { |
38 public: | 38 public: |
39 explicit TestingPolicyURLFetcherFactory(EventLogger* logger); | 39 explicit TestingPolicyURLFetcherFactory(EventLogger* logger); |
40 virtual ~TestingPolicyURLFetcherFactory(); | 40 virtual ~TestingPolicyURLFetcherFactory(); |
41 | 41 |
42 virtual net::URLFetcher* CreateURLFetcher( | 42 virtual net::URLFetcher* CreateURLFetcher( |
43 int id, | 43 int id, |
44 const GURL& url, | 44 const GURL& url, |
45 net::URLFetcher::RequestType request_type, | 45 net::URLFetcher::RequestType request_type, |
46 net::URLFetcherDelegate* delegate) OVERRIDE; | 46 net::URLFetcherDelegate* delegate) OVERRIDE; |
47 | 47 |
(...skipping 21 matching lines...) Expand all Loading... |
69 scoped_ptr<LoggingWorkScheduler> scheduler_; | 69 scoped_ptr<LoggingWorkScheduler> scheduler_; |
70 | 70 |
71 base::WeakPtrFactory<TestingPolicyURLFetcherFactory> weak_ptr_factory_; | 71 base::WeakPtrFactory<TestingPolicyURLFetcherFactory> weak_ptr_factory_; |
72 | 72 |
73 DISALLOW_COPY_AND_ASSIGN(TestingPolicyURLFetcherFactory); | 73 DISALLOW_COPY_AND_ASSIGN(TestingPolicyURLFetcherFactory); |
74 }; | 74 }; |
75 | 75 |
76 } // namespace policy | 76 } // namespace policy |
77 | 77 |
78 #endif // CHROME_BROWSER_POLICY_TESTING_POLICY_URL_FETCHER_FACTORY_H_ | 78 #endif // CHROME_BROWSER_POLICY_TESTING_POLICY_URL_FETCHER_FACTORY_H_ |
OLD | NEW |