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

Issue 149511: Refactorings surrounding HostResolver:... (Closed)

Created:
11 years, 5 months ago by eroman
Modified:
9 years, 6 months ago
CC:
chromium-reviews_googlegroups.com, darin (slow to review), brettw, willchan no longer on Chromium, Ben Goodger (Google)
Visibility:
Public.

Description

Refactorings surrounding HostResolver: (1) Extract HostResolver to an interface. The existing concrete implementation is now named HostResolverImpl. This makes it possible to create mocks with more complex behavior (i.e. choose via rules if response will be sync vs async). (2) Transform HostMapper into HostResolverProc. Conceptually HostResolverProc maps a hostname to a socket address, whereas HostMapper mapped a hostname to another hostname (so you were still at the mercy of the system's host resolver). With HostResolverProc you can specify the exact AddressList, making it possible to run tests requiring IPv6 socketaddrs on systems (like WinXP) that don't actually support it. (3) Add a MockHostResolver implementation of HostResolver. This replaces the [ScopedHostMapper + RuleBasedHostMapper + HostResolver] combo. It is less clunky and a bit more expressive. BUG=http://crbug.com/16452 R=willchan TEST=existing Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=20795

Patch Set 1 #

Total comments: 2

Patch Set 2 : Sync respository #

Total comments: 2

Patch Set 3 : Default MockHostResolver to NOT use caching -- this makes it a more consistent mock #

Patch Set 4 : Address willchan's comments -- make the proc a parameter to HostResolverImpl() #

Total comments: 20

Patch Set 5 : Address willchan's comments -- Add a CreateSystemHostResolver() factory method + nits #

Patch Set 6 : Address willchan's comments #

Patch Set 7 : Fix declaration order in dns_master_unittest.cc: the hostresolver must not outlive the message loop #

Patch Set 8 : Merge in socks5_client_socket_unittest.cc #

Unified diffs Side-by-side diffs Delta from patch set Stats (+747 lines, -3188 lines) Patch
MM chrome/browser/browser_unittest.cc View 1 2 3 4 5 6 7 5 chunks +10 lines, -10 lines 0 comments Download
M chrome/browser/net/dns_global.cc View 1 2 3 4 5 6 7 1 chunk +1 line, -5 lines 0 comments Download
M chrome/browser/net/dns_master_unittest.cc View 1 2 3 4 5 6 7 16 chunks +44 lines, -44 lines 0 comments Download
MM chrome/browser/search_engines/template_url_scraper_unittest.cc View 1 2 3 4 5 6 7 2 chunks +4 lines, -4 lines 0 comments Download
M chrome/test/in_process_browser_test.h View 1 2 3 4 5 6 7 2 chunks +5 lines, -5 lines 0 comments Download
M chrome/test/in_process_browser_test.cc View 1 2 3 4 5 6 7 3 chunks +10 lines, -9 lines 0 comments Download
M chrome/test/unit/chrome_test_suite.h View 1 2 3 4 5 6 7 4 chunks +13 lines, -11 lines 0 comments Download
M net/base/address_list_unittest.cc View 1 2 3 4 5 6 7 2 chunks +4 lines, -19 lines 0 comments Download
M net/base/host_resolver.h View 1 2 3 4 5 6 7 5 chunks +18 lines, -141 lines 0 comments Download
M net/base/host_resolver.cc View 1 2 3 4 5 6 7 2 chunks +2 lines, -606 lines 0 comments Download
A + net/base/host_resolver_impl.h View 1 2 3 4 chunks +39 lines, -203 lines 0 comments Download
A + net/base/host_resolver_impl.cc View 1 2 3 4 5 6 19 chunks +59 lines, -243 lines 0 comments Download
A + net/base/host_resolver_impl_unittest.cc View 1 2 3 27 chunks +130 lines, -106 lines 0 comments Download
A net/base/host_resolver_proc.h View 1 2 3 4 1 chunk +69 lines, -0 lines 0 comments Download
A + net/base/host_resolver_proc.cc View 1 2 3 6 chunks +37 lines, -524 lines 0 comments Download
D net/base/host_resolver_unittest.cc View 1 2 3 4 5 6 7 1 chunk +0 lines, -899 lines 0 comments Download
A + net/base/mock_host_resolver.h View 1 2 3 4 2 chunks +83 lines, -110 lines 0 comments Download
A + net/base/mock_host_resolver.cc View 1 2 3 1 chunk +122 lines, -138 lines 0 comments Download
M net/base/run_all_unittests.cc View 1 2 3 4 5 6 7 3 chunks +6 lines, -6 lines 0 comments Download
M net/ftp/ftp_network_transaction_unittest.cc View 1 2 3 4 5 6 7 4 chunks +5 lines, -6 lines 0 comments Download
M net/http/http_network_layer_unittest.cc View 1 2 3 4 5 6 7 4 chunks +4 lines, -4 lines 0 comments Download
M net/http/http_network_transaction_unittest.cc View 1 2 3 4 5 6 7 5 chunks +13 lines, -12 lines 0 comments Download
M net/net.gyp View 1 2 3 4 5 6 7 3 chunks +8 lines, -2 lines 0 comments Download
M net/proxy/proxy_resolver_perftest.cc View 1 2 3 4 5 6 7 2 chunks +3 lines, -1 line 0 comments Download
M net/proxy/proxy_resolver_v8.h View 1 2 3 4 5 6 7 1 chunk +1 line, -1 line 0 comments Download
M net/proxy/proxy_resolver_v8_unittest.cc View 1 2 3 4 5 6 7 4 chunks +8 lines, -6 lines 0 comments Download
M net/proxy/proxy_script_fetcher_unittest.cc View 1 2 3 4 5 6 7 1 chunk +1 line, -1 line 0 comments Download
M net/socket/client_socket_pool_base_unittest.cc View 1 2 3 4 5 6 7 6 chunks +5 lines, -6 lines 0 comments Download
M net/socket/socks5_client_socket_unittest.cc View 6 chunks +7 lines, -15 lines 0 comments Download
M net/socket/socks_client_socket_unittest.cc View 1 2 3 4 5 6 7 5 chunks +5 lines, -18 lines 0 comments Download
M net/socket/ssl_client_socket_unittest.cc View 1 2 3 4 5 6 7 8 chunks +9 lines, -13 lines 0 comments Download
M net/socket/ssl_test_util.cc View 1 2 3 4 5 6 7 1 chunk +1 line, -1 line 0 comments Download
M net/socket/tcp_client_socket_pool_unittest.cc View 1 2 3 4 5 6 7 4 chunks +11 lines, -11 lines 0 comments Download
M net/socket/tcp_client_socket_unittest.cc View 1 2 3 4 5 6 7 1 chunk +1 line, -1 line 0 comments Download
M net/socket/tcp_pinger_unittest.cc View 1 2 3 4 5 6 7 2 chunks +2 lines, -2 lines 0 comments Download
M net/tools/fetch/fetch_client.cc View 1 2 3 4 5 6 7 1 chunk +3 lines, -1 line 0 comments Download
M net/url_request/url_request_unittest.h View 1 2 3 4 5 6 7 2 chunks +2 lines, -2 lines 0 comments Download
M net/url_request/url_request_unittest.cc View 1 2 3 4 5 6 7 1 chunk +1 line, -1 line 0 comments Download
M webkit/tools/test_shell/test_shell_request_context.cc View 1 2 3 4 5 6 7 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 7 (0 generated)
eroman
11 years, 5 months ago (2009-07-12 03:03:36 UTC) #1
willchan no longer on Chromium
I haven't read through the whole thing yet. I have some general high level comments ...
11 years, 5 months ago (2009-07-12 04:26:55 UTC) #2
eroman
http://codereview.chromium.org/149511/diff/1/23 File net/base/mock_host_resolver.h (right): http://codereview.chromium.org/149511/diff/1/23#newcode36 Line 36: class MockHostResolver : public HostResolverImpl { On 2009/07/12 ...
11 years, 5 months ago (2009-07-12 10:56:09 UTC) #3
willchan no longer on Chromium
LGTM, this is a clear improvement over the existing test setup. http://codereview.chromium.org/149511/diff/1133/211 File chrome/browser/net/dns_global.cc (right): ...
11 years, 5 months ago (2009-07-14 17:04:57 UTC) #4
eroman
http://codereview.chromium.org/149511/diff/1133/211 File chrome/browser/net/dns_global.cc (right): http://codereview.chromium.org/149511/diff/1133/211#newcode482 Line 482: global_host_resolver = new net::HostResolverImpl( On 2009/07/14 17:04:57, willchan ...
11 years, 5 months ago (2009-07-14 20:32:27 UTC) #5
willchan no longer on Chromium
still lgtm http://codereview.chromium.org/149511/diff/1133/194 File net/base/host_resolver.h (right): http://codereview.chromium.org/149511/diff/1133/194#newcode129 Line 129: }; On 2009/07/14 20:32:27, eroman wrote: ...
11 years, 5 months ago (2009-07-14 22:24:45 UTC) #6
eroman
11 years, 5 months ago (2009-07-15 02:10:56 UTC) #7
http://codereview.chromium.org/149511/diff/1133/194
File net/base/host_resolver.h (right):

http://codereview.chromium.org/149511/diff/1133/194#newcode129
Line 129: };
On 2009/07/14 22:24:46, willchan wrote:
> On 2009/07/14 20:32:27, eroman wrote:
> > On 2009/07/14 17:04:57, willchan wrote:
> > > DISALLOW_COPY_AND_ASSIGN
> > 
> > I don't think this is necessary:
> > 
> > HostResolver is an interface (abstract class) -- if I call
> > DISALLOW_COPY_AND_ASSIGN it means I will need to additionally define a
default
> > ctor to get things compiling. Since this isn't a concrete class, the
> > copy/assignment constructors will not be used anyway.
> 
> You're right, but if you put the DISALLOW_COPY_AND_ASSIGN here, then all
derived
> classes with inherit the declaration (with the missing definition), so even if
> they forget DISALLOW_COPY_AND_ASSIGN, a call to the derived class's copy
> constructor will fail since it will automatically call the parent class's.
> 
> That said, if you still disagree, I don't feel strongly, so go ahead and
commit
> this anyway.

Done.

http://codereview.chromium.org/149511/diff/1133/197
File net/base/host_resolver_impl.cc (right):

http://codereview.chromium.org/149511/diff/1133/197#newcode335
Line 335: *out_req = reinterpret_cast<RequestHandle>(req);
On 2009/07/14 22:24:46, willchan wrote:
> On 2009/07/14 20:32:27, eroman wrote:
> > On 2009/07/14 17:04:57, willchan wrote:
> > > Hm, I think it's nice to avoid reinterpret_cast<> when possible.  What do
> you
> > > think about simply having a HostResolverRequest class?  It can be forward
> > > declared in host_resolver.h and defined in host_resolver_impl.cc.
> > 
> > The issue is that different subclasses of HostResolver may want different
> > internal classes as their RequestHandle. To do away with reinterpret cast
> means
> > I would need a shared base class among implementations (and virtual dtor in
> case
> > of abuse). I think the semantics of naming it "RequestHandle" are a bit
> cleaner
> > since that way each implementation can use whatever class hiearchy it wants
> (no
> > need for multiple-inheritance).
> 
> I see.  I didn't see multiple subclasses using the RequestHandle, but if you
> want to handle this case, then you're right, reinterpret_cast<> is the only
> solution.  Fine by me.

OK, left as is.

Powered by Google App Engine
This is Rietveld 408576698