summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorjoi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-26 14:26:30 +0000
committerjoi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-26 14:26:30 +0000
commit8d6bc14ce560d5549ee0e0c6784bd0f8f48757d6 (patch)
treefb0f81e9d918929807f6ff0b502f601c6d1fd4f5 /net
parent5b52ad495b1afcfb6c71259cfa8e18dec60378aa (diff)
downloadchromium_src-8d6bc14ce560d5549ee0e0c6784bd0f8f48757d6.zip
chromium_src-8d6bc14ce560d5549ee0e0c6784bd0f8f48757d6.tar.gz
chromium_src-8d6bc14ce560d5549ee0e0c6784bd0f8f48757d6.tar.bz2
Fix scope issues in DHCP WPAD code pointed out by jar@.
BUG=none TEST=net_unittests Review URL: http://codereview.chromium.org/7064028 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86821 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/proxy/dhcp_proxy_script_adapter_fetcher_win.cc5
-rw-r--r--net/proxy/dhcp_proxy_script_adapter_fetcher_win.h67
-rw-r--r--net/proxy/dhcp_proxy_script_adapter_fetcher_win_unittest.cc4
-rw-r--r--net/proxy/dhcp_proxy_script_fetcher_factory.h2
-rw-r--r--net/proxy/dhcp_proxy_script_fetcher_win.cc8
-rw-r--r--net/proxy/dhcp_proxy_script_fetcher_win.h18
-rw-r--r--net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc4
7 files changed, 63 insertions, 45 deletions
diff --git a/net/proxy/dhcp_proxy_script_adapter_fetcher_win.cc b/net/proxy/dhcp_proxy_script_adapter_fetcher_win.cc
index df6b46a..017f246 100644
--- a/net/proxy/dhcp_proxy_script_adapter_fetcher_win.cc
+++ b/net/proxy/dhcp_proxy_script_adapter_fetcher_win.cc
@@ -210,6 +210,11 @@ void DhcpProxyScriptAdapterFetcher::TransitionToFinish() {
callback->Run(result_);
}
+DhcpProxyScriptAdapterFetcher::State
+ DhcpProxyScriptAdapterFetcher::state() const {
+ return state_;
+}
+
ProxyScriptFetcher* DhcpProxyScriptAdapterFetcher::ImplCreateScriptFetcher() {
return new ProxyScriptFetcherImpl(url_request_context_);
}
diff --git a/net/proxy/dhcp_proxy_script_adapter_fetcher_win.h b/net/proxy/dhcp_proxy_script_adapter_fetcher_win.h
index 166c7a7..79b3d1e 100644
--- a/net/proxy/dhcp_proxy_script_adapter_fetcher_win.h
+++ b/net/proxy/dhcp_proxy_script_adapter_fetcher_win.h
@@ -78,6 +78,35 @@ class NET_TEST DhcpProxyScriptAdapterFetcher
static std::string GetPacURLFromDhcp(const std::string& adapter_name);
protected:
+ // This is the state machine for fetching from a given adapter.
+ //
+ // The state machine goes from START->WAIT_DHCP when it starts
+ // a worker thread to fetch the PAC URL from DHCP.
+ //
+ // In state WAIT_DHCP, if the DHCP query finishes and has no URL, it
+ // moves to state FINISH. If there is a URL, it starts a
+ // ProxyScriptFetcher to fetch it and moves to state WAIT_URL.
+ //
+ // It goes from WAIT_URL->FINISH when the ProxyScriptFetcher completes.
+ //
+ // In state FINISH, completion is indicated to the outer class, with
+ // the results of the fetch if a PAC script was successfully fetched.
+ //
+ // In state WAIT_DHCP, our timeout occurring can push us to FINISH.
+ //
+ // In any state except FINISH, a call to Cancel() will move to state
+ // CANCEL and cause all outstanding work to be cancelled or its
+ // results ignored when available.
+ enum State {
+ STATE_START,
+ STATE_WAIT_DHCP,
+ STATE_WAIT_URL,
+ STATE_FINISH,
+ STATE_CANCEL,
+ };
+
+ State state() const;
+
// This inner class is used to encapsulate the worker thread, which has
// only a weak reference back to the main object, so that the main object
// can be destroyed before the thread ends. This also keeps the main
@@ -122,44 +151,18 @@ class NET_TEST DhcpProxyScriptAdapterFetcher
DISALLOW_COPY_AND_ASSIGN(WorkerThread);
};
- // Event/state transition handlers
- void OnQueryDhcpDone(const std::string& url);
- void OnTimeout();
- void OnFetcherDone(int result);
- void TransitionToFinish();
-
// Virtual methods introduced to allow unit testing.
virtual ProxyScriptFetcher* ImplCreateScriptFetcher();
virtual WorkerThread* ImplCreateWorkerThread(
const base::WeakPtr<DhcpProxyScriptAdapterFetcher>& owner);
virtual base::TimeDelta ImplGetTimeout() const;
- // This is the state machine for fetching from a given adapter.
- //
- // The state machine goes from START->WAIT_DHCP when it starts
- // a worker thread to fetch the PAC URL from DHCP.
- //
- // In state WAIT_DHCP, if the DHCP query finishes and has no URL, it
- // moves to state FINISH. If there is a URL, it starts a
- // ProxyScriptFetcher to fetch it and moves to state WAIT_URL.
- //
- // It goes from WAIT_URL->FINISH when the ProxyScriptFetcher completes.
- //
- // In state FINISH, completion is indicated to the outer class, with
- // the results of the fetch if a PAC script was successfully fetched.
- //
- // In state WAIT_DHCP, our timeout occurring can push us to FINISH.
- //
- // In any state except FINISH, a call to Cancel() will move to state
- // CANCEL and cause all outstanding work to be cancelled or its
- // results ignored when available.
- enum State {
- STATE_START,
- STATE_WAIT_DHCP,
- STATE_WAIT_URL,
- STATE_FINISH,
- STATE_CANCEL,
- };
+ private:
+ // Event/state transition handlers
+ void OnQueryDhcpDone(const std::string& url);
+ void OnTimeout();
+ void OnFetcherDone(int result);
+ void TransitionToFinish();
// Current state of this state machine.
State state_;
diff --git a/net/proxy/dhcp_proxy_script_adapter_fetcher_win_unittest.cc b/net/proxy/dhcp_proxy_script_adapter_fetcher_win_unittest.cc
index 36d137c..47852a9 100644
--- a/net/proxy/dhcp_proxy_script_adapter_fetcher_win_unittest.cc
+++ b/net/proxy/dhcp_proxy_script_adapter_fetcher_win_unittest.cc
@@ -107,11 +107,11 @@ class MockDhcpProxyScriptAdapterFetcher
}
bool IsWaitingForFetcher() const {
- return state_ == STATE_WAIT_URL;
+ return state() == STATE_WAIT_URL;
}
bool WasCancelled() const {
- return state_ == STATE_CANCEL;
+ return state() == STATE_CANCEL;
}
void FinishTest() {
diff --git a/net/proxy/dhcp_proxy_script_fetcher_factory.h b/net/proxy/dhcp_proxy_script_fetcher_factory.h
index 57e0172..273f321 100644
--- a/net/proxy/dhcp_proxy_script_fetcher_factory.h
+++ b/net/proxy/dhcp_proxy_script_fetcher_factory.h
@@ -58,7 +58,7 @@ class NET_API DhcpProxyScriptFetcherFactory {
// operating system.
static bool IsSupported();
- protected:
+ private:
bool feature_enabled_;
DISALLOW_COPY_AND_ASSIGN(DhcpProxyScriptFetcherFactory);
diff --git a/net/proxy/dhcp_proxy_script_fetcher_win.cc b/net/proxy/dhcp_proxy_script_fetcher_win.cc
index 383cc8c..94bf279 100644
--- a/net/proxy/dhcp_proxy_script_fetcher_win.cc
+++ b/net/proxy/dhcp_proxy_script_fetcher_win.cc
@@ -221,6 +221,14 @@ void DhcpProxyScriptFetcherWin::TransitionToDone() {
client_callback_->Run(result);
}
+int DhcpProxyScriptFetcherWin::num_pending_fetchers() const {
+ return num_pending_fetchers_;
+}
+
+URLRequestContext* DhcpProxyScriptFetcherWin::url_request_context() const {
+ return url_request_context_;
+}
+
DhcpProxyScriptAdapterFetcher*
DhcpProxyScriptFetcherWin::ImplCreateAdapterFetcher() {
return new DhcpProxyScriptAdapterFetcher(url_request_context_);
diff --git a/net/proxy/dhcp_proxy_script_fetcher_win.h b/net/proxy/dhcp_proxy_script_fetcher_win.h
index fc96e19..a220f56 100644
--- a/net/proxy/dhcp_proxy_script_fetcher_win.h
+++ b/net/proxy/dhcp_proxy_script_fetcher_win.h
@@ -44,11 +44,9 @@ class NET_TEST DhcpProxyScriptFetcherWin
static bool GetCandidateAdapterNames(std::set<std::string>* adapter_names);
protected:
- // Event/state transition handlers
- void CancelImpl();
- void OnFetcherDone(int result);
- void OnWaitTimer();
- void TransitionToDone();
+ int num_pending_fetchers() const;
+
+ URLRequestContext* url_request_context() const;
// Virtual methods introduced to allow unit testing.
virtual DhcpProxyScriptAdapterFetcher* ImplCreateAdapterFetcher();
@@ -56,6 +54,13 @@ class NET_TEST DhcpProxyScriptFetcherWin
std::set<std::string>* adapter_names);
virtual int ImplGetMaxWaitMs();
+ private:
+ // Event/state transition handlers
+ void CancelImpl();
+ void OnFetcherDone(int result);
+ void OnWaitTimer();
+ void TransitionToDone();
+
// This is the outer state machine for fetching PAC configuration from
// DHCP. It relies for sub-states on the state machine of the
// DhcpProxyScriptAdapterFetcher class.
@@ -117,9 +122,6 @@ class NET_TEST DhcpProxyScriptFetcherWin
scoped_refptr<URLRequestContext> url_request_context_;
- private:
- // TODO(joi): Move other members to private as appropriate.
-
// Time |Fetch()| was last called, 0 if never.
base::TimeTicks fetch_start_time_;
diff --git a/net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc b/net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc
index ec2134f..e22915b 100644
--- a/net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc
+++ b/net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc
@@ -185,7 +185,7 @@ class DelayingDhcpProxyScriptFetcherWin
}
DhcpProxyScriptAdapterFetcher* ImplCreateAdapterFetcher() OVERRIDE {
- return new DelayingDhcpProxyScriptAdapterFetcher(url_request_context_);
+ return new DelayingDhcpProxyScriptAdapterFetcher(url_request_context());
}
};
@@ -311,7 +311,7 @@ class MockDhcpProxyScriptFetcherWin : public DhcpProxyScriptFetcherWin {
}
bool HasPendingFetchers() {
- return num_pending_fetchers_ > 0;
+ return num_pending_fetchers() > 0;
}
int next_adapter_fetcher_index_;