summaryrefslogtreecommitdiffstats
path: root/net/proxy/single_threaded_proxy_resolver_unittest.cc
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-13 01:39:58 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-13 01:39:58 +0000
commit0cf348bee91869f8ec4b17995fc65bfb02c0755d (patch)
tree2e4b045102485224511bdb794ab4ed7024d1a94f /net/proxy/single_threaded_proxy_resolver_unittest.cc
parentec2191fc123ffe5208995a4f4bd3f4e350590a44 (diff)
downloadchromium_src-0cf348bee91869f8ec4b17995fc65bfb02c0755d.zip
chromium_src-0cf348bee91869f8ec4b17995fc65bfb02c0755d.tar.gz
chromium_src-0cf348bee91869f8ec4b17995fc65bfb02c0755d.tar.bz2
Add the ability to purge memory to the ProxyResolver.
BUG=23400 TEST=none Review URL: http://codereview.chromium.org/272018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28769 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/proxy/single_threaded_proxy_resolver_unittest.cc')
-rw-r--r--net/proxy/single_threaded_proxy_resolver_unittest.cc21
1 files changed, 21 insertions, 0 deletions
diff --git a/net/proxy/single_threaded_proxy_resolver_unittest.cc b/net/proxy/single_threaded_proxy_resolver_unittest.cc
index 7eee997..37bf14a 100644
--- a/net/proxy/single_threaded_proxy_resolver_unittest.cc
+++ b/net/proxy/single_threaded_proxy_resolver_unittest.cc
@@ -23,6 +23,7 @@ class MockProxyResolver : public ProxyResolver {
: ProxyResolver(true /*expects_pac_bytes*/),
wrong_loop_(MessageLoop::current()),
request_count_(0),
+ purge_count_(0),
resolve_latency_ms_(0) {}
// ProxyResolver implementation:
@@ -60,6 +61,13 @@ class MockProxyResolver : public ProxyResolver {
return OK;
}
+ virtual void PurgeMemory() {
+ CheckIsOnWorkerThread();
+ ++purge_count_;
+ }
+
+ int purge_count() const { return purge_count_; }
+
const std::string& last_pac_bytes() const { return last_pac_bytes_; }
void SetResolveLatency(int latency_ms) {
@@ -77,6 +85,7 @@ class MockProxyResolver : public ProxyResolver {
MessageLoop* wrong_loop_;
int request_count_;
+ int purge_count_;
std::string last_pac_bytes_;
int resolve_latency_ms_;
};
@@ -195,6 +204,18 @@ TEST(SingleThreadedProxyResolverTest, Basic) {
rv = callback3.WaitForResult();
EXPECT_EQ(3, rv);
EXPECT_EQ("PROXY request3:80", results3.ToPacString());
+
+ // Ensure that PurgeMemory() reaches the wrapped resolver and happens on the
+ // right thread.
+ EXPECT_EQ(0, mock->purge_count());
+ resolver->PurgeMemory();
+ // There is no way to get a callback directly when PurgeMemory() completes, so
+ // we queue up a dummy request after the PurgeMemory() call and wait until it
+ // finishes to ensure PurgeMemory() has had a chance to run.
+ TestCompletionCallback dummy_callback;
+ rv = resolver->SetPacScriptByData("dummy", &dummy_callback);
+ EXPECT_EQ(OK, dummy_callback.WaitForResult());
+ EXPECT_EQ(1, mock->purge_count());
}
// Cancel a request which is in progress, and then cancel a request which