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

Issue 57011: Extract the parsing of proxy rules to ProxyConfig::ProxyRules, and unit-test.... (Closed)

Created:
11 years, 8 months ago by eroman
Modified:
9 years, 6 months ago
Reviewers:
wtc
CC:
chromium-reviews_googlegroups.com
Visibility:
Public.

Description

Extract the parsing of proxy rules to ProxyConfig::ProxyRules, and unit-test. This avoids re-parsing the rules every time a proxy resolve is done, and also adds extra tolerance for white space. The other motivation is to not have to fiddle around with strings as much in the various ProxyConfigServceXXXX implementations. Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=12829

Patch Set 1 #

Patch Set 2 : fix some lint errors #

Total comments: 21

Patch Set 3 : address wtc's comments #

Total comments: 3

Patch Set 4 : address wtc's second batch of comments #

Patch Set 5 : address wtc's second batch of comments -- second try, got rietveld 500 before... #

Unified diffs Side-by-side diffs Delta from patch set Stats (+465 lines, -104 lines) Patch
M net/net.gyp View 1 2 1 chunk +1 line, -0 lines 0 comments Download
M net/proxy/proxy_config.h View 1 2 3 2 chunks +56 lines, -16 lines 0 comments Download
M net/proxy/proxy_config.cc View 1 2 2 chunks +54 lines, -0 lines 0 comments Download
M net/proxy/proxy_config_service_fixed.h View 1 chunk +2 lines, -1 line 0 comments Download
M net/proxy/proxy_config_service_win.cc View 1 chunk +5 lines, -2 lines 0 comments Download
M net/proxy/proxy_config_service_win_unittest.cc View 9 chunks +79 lines, -35 lines 0 comments Download
A net/proxy/proxy_config_unittest.cc View 1 1 chunk +199 lines, -0 lines 0 comments Download
M net/proxy/proxy_info.h View 1 2 1 chunk +3 lines, -0 lines 0 comments Download
M net/proxy/proxy_info.cc View 1 chunk +4 lines, -0 lines 0 comments Download
M net/proxy/proxy_list.h View 1 chunk +3 lines, -0 lines 0 comments Download
M net/proxy/proxy_list.cc View 1 chunk +6 lines, -0 lines 0 comments Download
M net/proxy/proxy_resolver_mac.cc View 3 chunks +6 lines, -10 lines 0 comments Download
M net/proxy/proxy_server.h View 1 chunk +6 lines, -0 lines 0 comments Download
M net/proxy/proxy_service.h View 1 1 chunk +5 lines, -0 lines 0 comments Download
M net/proxy/proxy_service.cc View 1 2 3 3 chunks +33 lines, -37 lines 0 comments Download
M net/proxy/proxy_service_unittest.cc View 3 chunks +3 lines, -3 lines 0 comments Download

Messages

Total messages: 5 (0 generated)
eroman
11 years, 8 months ago (2009-03-30 16:00:47 UTC) #1
wtc
LGTM. http://codereview.chromium.org/57011/diff/1001/1017 File net/net.gyp (right): http://codereview.chromium.org/57011/diff/1001/1017#newcode429 Line 429: 'proxy/proxy_config_unittest.cc', Nit: should we list this after ...
11 years, 8 months ago (2009-03-30 19:06:32 UTC) #2
eroman
http://codereview.chromium.org/57011/diff/1001/1017 File net/net.gyp (right): http://codereview.chromium.org/57011/diff/1001/1017#newcode429 Line 429: 'proxy/proxy_config_unittest.cc', On 2009/03/30 19:06:32, wtc wrote: > Nit: ...
11 years, 8 months ago (2009-03-30 20:27:43 UTC) #3
wtc
LGTM. http://codereview.chromium.org/57011/diff/1001/1015 File net/proxy/proxy_config.h (right): http://codereview.chromium.org/57011/diff/1001/1015#newcode47 Line 47: // Set if |type| is SINGLE_PROXY. On ...
11 years, 8 months ago (2009-03-30 22:53:40 UTC) #4
eroman
11 years, 8 months ago (2009-03-30 23:55:28 UTC) #5
thanks for the review!

http://codereview.chromium.org/57011/diff/1001/1015
File net/proxy/proxy_config.h (right):

http://codereview.chromium.org/57011/diff/1001/1015#newcode47
Line 47: // Set if |type| is SINGLE_PROXY.
On 2009/03/30 22:53:40, wtc wrote:
> On 2009/03/30 20:27:43, eroman wrote:
> >
> > I would really prefer not to use a union.
> > 
> > If you are concerned about the extra sizeof(ProxyServer) storage used by
> > non-union implementation, I can re-use |proxy_for_http| for the single-proxy
> > case (but I would prefer not to for readability).
> 
> My rationale for using a union is that it makes your
> intention clear to people familiar with unions.  You
> are relying on comments to convey your intention.  If
> you use a union, the code will become self-documenting.
> 
> I am not that concerned about wasting an empty std::string
> here.  In any case, I'll let you decide.

My reason for opting against unions, is that unions are totally borked in C++.

In particular a union is going to blow up if you give it members that require
initialization. Here for example, the desire is to have the members be of type
ProxyServer. This however is a no-go, since ProxyServer defines a default
constructor. (In fact this won't even compile). To work around this gets ugly,
and you lose the safety net against using uninitialized data.

http://codereview.chromium.org/57011/diff/1001/1003
File net/proxy/proxy_service.cc (right):

http://codereview.chromium.org/57011/diff/1001/1003#newcode334
Line 334: proxy_rules.MapSchemeToProxy(url.scheme())) {
On 2009/03/30 22:53:40, wtc wrote:
> On 2009/03/30 20:27:43, eroman wrote:
> >
> > Maybe I should just define entry prior to the "if"? (The main reason I
avoided
> > that, is then I need to put braces around the "case".
> 
> Oh, I didn't realize you're declaring a local variable
> 'entry' there.  So you may ignore my previous suggestion
> of aligning this line with the opening '(' on the previous
> line.
> 
> Yes, I would declare 'entry' before the "if", at the cost
> of adding braces around this case.

Done.

http://codereview.chromium.org/57011/diff/40/42#newcode344
Line 344: }
On 2009/03/30 22:53:41, wtc wrote:
> Nit: add a 'break' at the end of the 'default' case.

Done.

Powered by Google App Engine
This is Rietveld 408576698