summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authortedvessenes@gmail.com <tedvessenes@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-11 15:41:43 +0000
committertedvessenes@gmail.com <tedvessenes@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-11 15:41:43 +0000
commit0f2e45ec2650ebd32037ca109f1876ed85ce1fd5 (patch)
tree0e289579bccf4d39273e60010eeed8699fa00bd8 /net
parentb80ffe2725c3d5ca17d21e3743c06689bca46935 (diff)
downloadchromium_src-0f2e45ec2650ebd32037ca109f1876ed85ce1fd5.zip
chromium_src-0f2e45ec2650ebd32037ca109f1876ed85ce1fd5.tar.gz
chromium_src-0f2e45ec2650ebd32037ca109f1876ed85ce1fd5.tar.bz2
Switch to TimeDelta interfaces for process waiting functions in net and ipc.
R=agl@chromium.org BUG=108171 Review URL: https://chromiumcodereview.appspot.com/10692155 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@146124 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/base/file_stream_unittest.cc4
-rw-r--r--net/dns/dns_transaction_unittest.cc6
-rw-r--r--net/proxy/dhcp_proxy_script_adapter_fetcher_win_unittest.cc18
-rw-r--r--net/proxy/dhcp_proxy_script_fetcher_win.cc7
-rw-r--r--net/proxy/dhcp_proxy_script_fetcher_win.h2
-rw-r--r--net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc61
-rw-r--r--net/test/local_test_server.cc2
-rw-r--r--net/test/local_test_server_posix.cc3
8 files changed, 53 insertions, 50 deletions
diff --git a/net/base/file_stream_unittest.cc b/net/base/file_stream_unittest.cc
index 7cda76d..1042784 100644
--- a/net/base/file_stream_unittest.cc
+++ b/net/base/file_stream_unittest.cc
@@ -44,9 +44,7 @@ class NetLogForNotifyingFileClosure : public NetLog {
// Wait until a file closure event is recorded.
bool WaitForClosure() {
- const base::TimeDelta timeout(
- base::TimeDelta::FromMilliseconds(
- TestTimeouts::action_max_timeout_ms()));
+ const base::TimeDelta timeout(TestTimeouts::action_max_timeout());
return on_closure_.TimedWait(timeout);
}
diff --git a/net/dns/dns_transaction_unittest.cc b/net/dns/dns_transaction_unittest.cc
index 51c5b6a..5e61f27 100644
--- a/net/dns/dns_transaction_unittest.cc
+++ b/net/dns/dns_transaction_unittest.cc
@@ -510,8 +510,7 @@ TEST_F(DnsTransactionTest, NoDomain) {
TEST_F(DnsTransactionTest, Timeout) {
config_.attempts = 3;
// Use short timeout to speed up the test.
- config_.timeout = base::TimeDelta::FromMilliseconds(
- TestTimeouts::tiny_timeout_ms());
+ config_.timeout = TestTimeouts::tiny_timeout();
ConfigureFactory();
AddTimeout(kT0HostName, kT0Qtype);
@@ -533,8 +532,7 @@ TEST_F(DnsTransactionTest, ServerFallbackAndRotate) {
config_.rotate = true;
ConfigureNumServers(3);
// Use short timeout to speed up the test.
- config_.timeout = base::TimeDelta::FromMilliseconds(
- TestTimeouts::tiny_timeout_ms());
+ config_.timeout = TestTimeouts::tiny_timeout();
ConfigureFactory();
// Responses for first request.
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 0c612eb..2e9bd4c 100644
--- a/net/proxy/dhcp_proxy_script_adapter_fetcher_win_unittest.cc
+++ b/net/proxy/dhcp_proxy_script_adapter_fetcher_win_unittest.cc
@@ -35,8 +35,8 @@ class MockDhcpProxyScriptAdapterFetcher
public:
explicit MockDhcpProxyScriptAdapterFetcher(URLRequestContext* context)
: DhcpProxyScriptAdapterFetcher(context),
- dhcp_delay_ms_(1),
- timeout_ms_(TestTimeouts::action_timeout_ms()),
+ dhcp_delay_(base::TimeDelta::FromMilliseconds(1)),
+ timeout_(TestTimeouts::action_timeout()),
configured_url_(kPacUrl),
fetcher_delay_ms_(1),
fetcher_result_(OK),
@@ -75,20 +75,20 @@ class MockDhcpProxyScriptAdapterFetcher
}
base::WaitableEvent test_finished_event_;
- TimeDelta dhcp_delay_;
+ base::TimeDelta dhcp_delay_;
std::string configured_url_;
};
virtual DhcpQuery* ImplCreateDhcpQuery() OVERRIDE {
dhcp_query_ = new DelayingDhcpQuery();
- dhcp_query_->dhcp_delay_ = TimeDelta::FromMilliseconds(dhcp_delay_ms_);
+ dhcp_query_->dhcp_delay_ = dhcp_delay_;
dhcp_query_->configured_url_ = configured_url_;
return dhcp_query_;
}
// Use a shorter timeout so tests can finish more quickly.
virtual base::TimeDelta ImplGetTimeout() const OVERRIDE {
- return base::TimeDelta::FromMilliseconds(timeout_ms_);
+ return timeout_;
}
void OnFetcherTimer() {
@@ -117,8 +117,8 @@ class MockDhcpProxyScriptAdapterFetcher
dhcp_query_->test_finished_event_.Signal();
}
- int dhcp_delay_ms_;
- int timeout_ms_;
+ base::TimeDelta dhcp_delay_;
+ base::TimeDelta timeout_;
std::string configured_url_;
int fetcher_delay_ms_;
int fetcher_result_;
@@ -183,8 +183,8 @@ TEST(DhcpProxyScriptAdapterFetcher, TimeoutDuringDhcp) {
// present on the network) accessing DHCP can take on the order of tens
// of seconds.
FetcherClient client;
- client.fetcher_->dhcp_delay_ms_ = TestTimeouts::action_max_timeout_ms();
- client.fetcher_->timeout_ms_ = 25;
+ client.fetcher_->dhcp_delay_ = TestTimeouts::action_max_timeout();
+ client.fetcher_->timeout_ = base::TimeDelta::FromMilliseconds(25);
PerfTimer timer;
client.RunTest();
diff --git a/net/proxy/dhcp_proxy_script_fetcher_win.cc b/net/proxy/dhcp_proxy_script_fetcher_win.cc
index ab24aa3..d7392fe 100644
--- a/net/proxy/dhcp_proxy_script_fetcher_win.cc
+++ b/net/proxy/dhcp_proxy_script_fetcher_win.cc
@@ -194,8 +194,7 @@ void DhcpProxyScriptFetcherWin::OnFetcherDone(int result) {
if (state_ == STATE_NO_RESULTS) {
state_ = STATE_SOME_RESULTS;
wait_timer_.Start(FROM_HERE,
- base::TimeDelta::FromMilliseconds(ImplGetMaxWaitMs()),
- this, &DhcpProxyScriptFetcherWin::OnWaitTimer);
+ ImplGetMaxWait(), this, &DhcpProxyScriptFetcherWin::OnWaitTimer);
}
}
@@ -283,8 +282,8 @@ DhcpProxyScriptFetcherWin::AdapterQuery*
return new AdapterQuery();
}
-int DhcpProxyScriptFetcherWin::ImplGetMaxWaitMs() {
- return kMaxWaitAfterFirstResultMs;
+base::TimeDelta DhcpProxyScriptFetcherWin::ImplGetMaxWait() {
+ return base::TimeDelta::FromMilliseconds(kMaxWaitAfterFirstResultMs);
}
bool DhcpProxyScriptFetcherWin::GetCandidateAdapterNames(
diff --git a/net/proxy/dhcp_proxy_script_fetcher_win.h b/net/proxy/dhcp_proxy_script_fetcher_win.h
index 29b98e8..6c93a7b 100644
--- a/net/proxy/dhcp_proxy_script_fetcher_win.h
+++ b/net/proxy/dhcp_proxy_script_fetcher_win.h
@@ -84,7 +84,7 @@ class NET_EXPORT_PRIVATE DhcpProxyScriptFetcherWin
// Virtual methods introduced to allow unit testing.
virtual DhcpProxyScriptAdapterFetcher* ImplCreateAdapterFetcher();
virtual AdapterQuery* ImplCreateAdapterQuery();
- virtual int ImplGetMaxWaitMs();
+ virtual base::TimeDelta ImplGetMaxWait();
virtual void ImplOnGetCandidateAdapterNamesDone() {}
private:
diff --git a/net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc b/net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc
index e05f7c1..bbe28fb 100644
--- a/net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc
+++ b/net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc
@@ -308,10 +308,11 @@ class MockDhcpProxyScriptFetcherWin : public DhcpProxyScriptFetcherWin {
bool did_finish,
int result,
string16 pac_script,
- int fetch_delay_ms) {
+ base::TimeDelta fetch_delay) {
scoped_ptr<DummyDhcpProxyScriptAdapterFetcher> adapter_fetcher(
new DummyDhcpProxyScriptAdapterFetcher(url_request_context()));
- adapter_fetcher->Configure(did_finish, result, pac_script, fetch_delay_ms);
+ adapter_fetcher->Configure(
+ did_finish, result, pac_script, fetch_delay.InMilliseconds());
PushBackAdapter(adapter_name, adapter_fetcher.release());
}
@@ -325,8 +326,8 @@ class MockDhcpProxyScriptFetcherWin : public DhcpProxyScriptFetcherWin {
return adapter_query_.get();
}
- int ImplGetMaxWaitMs() OVERRIDE {
- return max_wait_ms_;
+ base::TimeDelta ImplGetMaxWait() OVERRIDE {
+ return max_wait_;
}
void ImplOnGetCandidateAdapterNamesDone() OVERRIDE {
@@ -347,7 +348,7 @@ class MockDhcpProxyScriptFetcherWin : public DhcpProxyScriptFetcherWin {
num_fetchers_created_ = 0;
adapter_fetchers_.clear();
adapter_query_ = new MockAdapterQuery();
- max_wait_ms_ = TestTimeouts::tiny_timeout_ms();
+ max_wait_ = TestTimeouts::tiny_timeout();
}
bool HasPendingFetchers() {
@@ -363,7 +364,7 @@ class MockDhcpProxyScriptFetcherWin : public DhcpProxyScriptFetcherWin {
scoped_refptr<MockAdapterQuery> adapter_query_;
- int max_wait_ms_;
+ base::TimeDelta max_wait_;
int num_fetchers_created_;
base::WaitableEvent worker_finished_event_;
};
@@ -439,11 +440,12 @@ TEST(DhcpProxyScriptFetcherWin, NormalCaseURLConfiguredOneAdapter) {
void TestNormalCaseURLConfiguredMultipleAdapters(FetcherClient* client) {
client->fetcher_.ConfigureAndPushBackAdapter(
- "most_preferred", true, ERR_PAC_NOT_IN_DHCP, L"", 1);
+ "most_preferred", true, ERR_PAC_NOT_IN_DHCP, L"",
+ base::TimeDelta::FromMilliseconds(1));
client->fetcher_.ConfigureAndPushBackAdapter(
- "second", true, OK, L"bingo", 50);
+ "second", true, OK, L"bingo", base::TimeDelta::FromMilliseconds(50));
client->fetcher_.ConfigureAndPushBackAdapter(
- "third", true, OK, L"rocko", 1);
+ "third", true, OK, L"rocko", base::TimeDelta::FromMilliseconds(1));
client->RunTest();
client->RunMessageLoopUntilComplete();
ASSERT_EQ(OK, client->result_);
@@ -458,13 +460,14 @@ TEST(DhcpProxyScriptFetcherWin, NormalCaseURLConfiguredMultipleAdapters) {
void TestNormalCaseURLConfiguredMultipleAdaptersWithTimeout(
FetcherClient* client) {
client->fetcher_.ConfigureAndPushBackAdapter(
- "most_preferred", true, ERR_PAC_NOT_IN_DHCP, L"", 1);
+ "most_preferred", true, ERR_PAC_NOT_IN_DHCP, L"",
+ base::TimeDelta::FromMilliseconds(1));
// This will time out.
client->fetcher_.ConfigureAndPushBackAdapter(
"second", false, ERR_IO_PENDING, L"bingo",
- TestTimeouts::action_timeout_ms());
+ TestTimeouts::action_timeout());
client->fetcher_.ConfigureAndPushBackAdapter(
- "third", true, OK, L"rocko", 1);
+ "third", true, OK, L"rocko", base::TimeDelta::FromMilliseconds(1));
client->RunTest();
client->RunMessageLoopUntilComplete();
ASSERT_EQ(OK, client->result_);
@@ -480,17 +483,20 @@ TEST(DhcpProxyScriptFetcherWin,
void TestFailureCaseURLConfiguredMultipleAdaptersWithTimeout(
FetcherClient* client) {
client->fetcher_.ConfigureAndPushBackAdapter(
- "most_preferred", true, ERR_PAC_NOT_IN_DHCP, L"", 1);
+ "most_preferred", true, ERR_PAC_NOT_IN_DHCP, L"",
+ base::TimeDelta::FromMilliseconds(1));
// This will time out.
client->fetcher_.ConfigureAndPushBackAdapter(
"second", false, ERR_IO_PENDING, L"bingo",
- TestTimeouts::action_timeout_ms());
+ TestTimeouts::action_timeout());
// This is the first non-ERR_PAC_NOT_IN_DHCP error and as such
// should be chosen.
client->fetcher_.ConfigureAndPushBackAdapter(
- "third", true, ERR_PAC_STATUS_NOT_OK, L"", 1);
+ "third", true, ERR_PAC_STATUS_NOT_OK, L"",
+ base::TimeDelta::FromMilliseconds(1));
client->fetcher_.ConfigureAndPushBackAdapter(
- "fourth", true, ERR_NOT_IMPLEMENTED, L"", 1);
+ "fourth", true, ERR_NOT_IMPLEMENTED, L"",
+ base::TimeDelta::FromMilliseconds(1));
client->RunTest();
client->RunMessageLoopUntilComplete();
ASSERT_EQ(ERR_PAC_STATUS_NOT_OK, client->result_);
@@ -505,15 +511,17 @@ TEST(DhcpProxyScriptFetcherWin,
void TestFailureCaseNoURLConfigured(FetcherClient* client) {
client->fetcher_.ConfigureAndPushBackAdapter(
- "most_preferred", true, ERR_PAC_NOT_IN_DHCP, L"", 1);
+ "most_preferred", true, ERR_PAC_NOT_IN_DHCP, L"",
+ base::TimeDelta::FromMilliseconds(1));
// This will time out.
client->fetcher_.ConfigureAndPushBackAdapter(
"second", false, ERR_IO_PENDING, L"bingo",
- TestTimeouts::action_timeout_ms());
+ TestTimeouts::action_timeout());
// This is the first non-ERR_PAC_NOT_IN_DHCP error and as such
// should be chosen.
client->fetcher_.ConfigureAndPushBackAdapter(
- "third", true, ERR_PAC_NOT_IN_DHCP, L"", 1);
+ "third", true, ERR_PAC_NOT_IN_DHCP, L"",
+ base::TimeDelta::FromMilliseconds(1));
client->RunTest();
client->RunMessageLoopUntilComplete();
ASSERT_EQ(ERR_PAC_NOT_IN_DHCP, client->result_);
@@ -544,15 +552,17 @@ void TestShortCircuitLessPreferredAdapters(FetcherClient* client) {
// time. Verify that we complete quickly and do not wait for the slow
// adapters, i.e. we finish before timeout.
client->fetcher_.ConfigureAndPushBackAdapter(
- "1", true, ERR_PAC_NOT_IN_DHCP, L"", 1);
+ "1", true, ERR_PAC_NOT_IN_DHCP, L"",
+ base::TimeDelta::FromMilliseconds(1));
client->fetcher_.ConfigureAndPushBackAdapter(
- "2", true, OK, L"bingo", 1);
+ "2", true, OK, L"bingo",
+ base::TimeDelta::FromMilliseconds(1));
client->fetcher_.ConfigureAndPushBackAdapter(
- "3", true, OK, L"wrongo", TestTimeouts::action_max_timeout_ms());
+ "3", true, OK, L"wrongo", TestTimeouts::action_max_timeout());
// Increase the timeout to ensure the short circuit mechanism has
// time to kick in before the timeout waiting for more adapters kicks in.
- client->fetcher_.max_wait_ms_ = TestTimeouts::action_timeout_ms();
+ client->fetcher_.max_wait_ = TestTimeouts::action_timeout();
PerfTimer timer;
client->RunTest();
@@ -562,9 +572,8 @@ void TestShortCircuitLessPreferredAdapters(FetcherClient* client) {
// timeout, to get a second signal that it was the shortcut mechanism
// (in OnFetcherDone) that kicked in, and not the timeout waiting for
// more adapters.
- ASSERT_GT(base::TimeDelta::FromMilliseconds(
- client->fetcher_.max_wait_ms_ - (client->fetcher_.max_wait_ms_ / 10)),
- timer.Elapsed());
+ ASSERT_GT(client->fetcher_.max_wait_ - (client->fetcher_.max_wait_ / 10),
+ timer.Elapsed());
}
TEST(DhcpProxyScriptFetcherWin, ShortCircuitLessPreferredAdapters) {
diff --git a/net/test/local_test_server.cc b/net/test/local_test_server.cc
index 7fe3e58..e67d4f9 100644
--- a/net/test/local_test_server.cc
+++ b/net/test/local_test_server.cc
@@ -122,7 +122,7 @@ bool LocalTestServer::Stop() {
return true;
// First check if the process has already terminated.
- bool ret = base::WaitForSingleProcess(process_handle_, 0);
+ bool ret = base::WaitForSingleProcess(process_handle_, base::TimeDelta());
if (!ret)
ret = base::KillProcess(process_handle_, 1, true);
diff --git a/net/test/local_test_server_posix.cc b/net/test/local_test_server_posix.cc
index 3756b69..3e47a0f 100644
--- a/net/test/local_test_server_posix.cc
+++ b/net/test/local_test_server_posix.cc
@@ -141,8 +141,7 @@ bool LocalTestServer::LaunchPython(const FilePath& testserver_path) {
bool LocalTestServer::WaitToStart() {
file_util::ScopedFD child_fd_closer(child_fd_closer_.release());
- base::TimeDelta remaining_time = base::TimeDelta::FromMilliseconds(
- TestTimeouts::action_timeout_ms());
+ base::TimeDelta remaining_time = TestTimeouts::action_timeout();
uint32 server_data_len = 0;
if (!ReadData(child_fd_, sizeof(server_data_len),