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

Side by Side Diff: chrome/common/net/test_url_fetcher_factory.h

Issue 3198001: Fix leaks in GoogleURLTrackerTest::CreateRequestContext() (Closed)
Patch Set: Created 10 years, 4 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
« no previous file with comments | « chrome/browser/google_url_tracker_unittest.cc ('k') | no next file » | 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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_COMMON_NET_TEST_URL_FETCHER_FACTORY_H_ 5 #ifndef CHROME_COMMON_NET_TEST_URL_FETCHER_FACTORY_H_
6 #define CHROME_COMMON_NET_TEST_URL_FETCHER_FACTORY_H_ 6 #define CHROME_COMMON_NET_TEST_URL_FETCHER_FACTORY_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
11 11
12 #include "chrome/common/net/url_fetcher.h" 12 #include "chrome/common/net/url_fetcher.h"
13 #include "googleurl/src/gurl.h" 13 #include "googleurl/src/gurl.h"
14 14
15 // TestURLFetcher and TestURLFetcherFactory are used for testing consumers of 15 // TestURLFetcher and TestURLFetcherFactory are used for testing consumers of
16 // URLFetcher. TestURLFetcherFactory is a URLFetcher::Factory that creates 16 // URLFetcher. TestURLFetcherFactory is a URLFetcher::Factory that creates
17 // TestURLFetchers. TestURLFetcher::Start is overriden to do nothing. It is 17 // TestURLFetchers. TestURLFetcher::Start is overriden to do nothing. It is
18 // expected that you'll grab the delegate from the TestURLFetcher and invoke 18 // expected that you'll grab the delegate from the TestURLFetcher and invoke
19 // the callback method when appropriate. In this way it's easy to mock a 19 // the callback method when appropriate. In this way it's easy to mock a
20 // URLFetcher. 20 // URLFetcher.
21 // Typical usage: 21 // Typical usage:
22 // // TestURLFetcher requires a MessageLoop: 22 // // TestURLFetcher requires a MessageLoop:
23 // MessageLoopForUI message_loop; 23 // MessageLoopForIO message_loop;
24 // // and IO thread to clean up request_context etc.
25 // ChromeThread io_thread(ChromeThread::IO, &message_loop);
24 // // Create and register factory. 26 // // Create and register factory.
25 // TestURLFetcherFactory factory; 27 // TestURLFetcherFactory factory;
26 // URLFetcher::set_factory(&factory); 28 // URLFetcher::set_factory(&factory);
27 // // Do something that triggers creation of a URLFetcher. 29 // // Do something that triggers creation of a URLFetcher.
28 // TestURLFetcher* fetcher = factory.GetFetcherByID(expected_id); 30 // TestURLFetcher* fetcher = factory.GetFetcherByID(expected_id);
29 // DCHECK(fetcher); 31 // DCHECK(fetcher);
30 // // Notify delegate with whatever data you want. 32 // // Notify delegate with whatever data you want.
31 // fetcher->delegate()->OnURLFetchComplete(...); 33 // fetcher->delegate()->OnURLFetchComplete(...);
32 // // Make sure consumer of URLFetcher does the right thing. 34 // // Make sure consumer of URLFetcher does the right thing.
33 // ... 35 // ...
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 76
75 private: 77 private:
76 // Maps from id passed to create to the returned URLFetcher. 78 // Maps from id passed to create to the returned URLFetcher.
77 typedef std::map<int, TestURLFetcher*> Fetchers; 79 typedef std::map<int, TestURLFetcher*> Fetchers;
78 Fetchers fetchers_; 80 Fetchers fetchers_;
79 81
80 DISALLOW_COPY_AND_ASSIGN(TestURLFetcherFactory); 82 DISALLOW_COPY_AND_ASSIGN(TestURLFetcherFactory);
81 }; 83 };
82 84
83 #endif // CHROME_COMMON_NET_TEST_URL_FETCHER_FACTORY_H_ 85 #endif // CHROME_COMMON_NET_TEST_URL_FETCHER_FACTORY_H_
OLDNEW
« no previous file with comments | « chrome/browser/google_url_tracker_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698