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

Side by Side Diff: chrome/browser/policy/testing_policy_url_fetcher_factory.h

Issue 8395038: Make test URLFetcher implementations not derive from the URLFetcher implementation, since we want... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: move factory to its own file and remove Create function from URLFetcher impl Created 9 years, 1 month 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
OLDNEW
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 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
(...skipping 11 matching lines...) Expand all
22 class LoggingWorkScheduler; 22 class LoggingWorkScheduler;
23 class TestingPolicyURLFetcher; 23 class TestingPolicyURLFetcher;
24 24
25 struct TestURLResponse { 25 struct TestURLResponse {
26 std::string response_data; 26 std::string response_data;
27 int response_code; 27 int response_code;
28 }; 28 };
29 29
30 // Creates mock URLFetchers whose behavior can be controlled in tests. To do so 30 // Creates mock URLFetchers whose behavior can be controlled in tests. To do so
31 // set mock expectations on the method |Intercept|. 31 // set mock expectations on the method |Intercept|.
32 class TestingPolicyURLFetcherFactory : public URLFetcher::Factory, 32 class TestingPolicyURLFetcherFactory : public content::URLFetcherFactory,
33 public ScopedURLFetcherFactory { 33 public ScopedURLFetcherFactory {
34 public: 34 public:
35 explicit TestingPolicyURLFetcherFactory(EventLogger* logger); 35 explicit TestingPolicyURLFetcherFactory(EventLogger* logger);
36 virtual ~TestingPolicyURLFetcherFactory(); 36 virtual ~TestingPolicyURLFetcherFactory();
37 37
38 virtual URLFetcher* CreateURLFetcher( 38 virtual content::URLFetcher* CreateURLFetcher(
39 int id, 39 int id,
40 const GURL& url, 40 const GURL& url,
41 URLFetcher::RequestType request_type, 41 content::URLFetcher::RequestType request_type,
42 content::URLFetcherDelegate* delegate) OVERRIDE; 42 content::URLFetcherDelegate* delegate) OVERRIDE;
43 43
44 LoggingWorkScheduler* scheduler(); 44 LoggingWorkScheduler* scheduler();
45 45
46 // Called back by TestingPolicyURLFetcher objects. Uses |Intercept| to get 46 // Called back by TestingPolicyURLFetcher objects. Uses |Intercept| to get
47 // the response and notifies |logger_| of a network request event. 47 // the response and notifies |logger_| of a network request event.
48 void GetResponse(const std::string& auth_header, 48 void GetResponse(const std::string& auth_header,
49 const std::string& request_type, 49 const std::string& request_type,
50 TestURLResponse* response); 50 TestURLResponse* response);
51 51
52 // Place EXPECT_CALLs on this method to control the responses of the 52 // Place EXPECT_CALLs on this method to control the responses of the
53 // produced URLFetchers. The response data should be copied into |response|. 53 // produced URLFetchers. The response data should be copied into |response|.
54 MOCK_METHOD3(Intercept, void(const std::string& auth_header, 54 MOCK_METHOD3(Intercept, void(const std::string& auth_header,
55 const std::string& request_type, 55 const std::string& request_type,
56 TestURLResponse* response)); 56 TestURLResponse* response));
57 57
58 private: 58 private:
59 EventLogger* logger_; 59 EventLogger* logger_;
60 scoped_ptr<LoggingWorkScheduler> scheduler_; 60 scoped_ptr<LoggingWorkScheduler> scheduler_;
61 61
62 base::WeakPtrFactory<TestingPolicyURLFetcherFactory> weak_ptr_factory_; 62 base::WeakPtrFactory<TestingPolicyURLFetcherFactory> weak_ptr_factory_;
63 63
64 DISALLOW_COPY_AND_ASSIGN(TestingPolicyURLFetcherFactory); 64 DISALLOW_COPY_AND_ASSIGN(TestingPolicyURLFetcherFactory);
65 }; 65 };
66 66
67 } // namespace policy 67 } // namespace policy
68 68
69 #endif // CHROME_BROWSER_POLICY_TESTING_POLICY_URL_FETCHER_FACTORY_H_ 69 #endif // CHROME_BROWSER_POLICY_TESTING_POLICY_URL_FETCHER_FACTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698