Skip to content

Commit

Permalink
Remove PurgeMemory() from the proxy service. The MemoryPurger is gone…
Browse files Browse the repository at this point in the history
…, so this

is unused.

BUG=350455
TEST=none
R=eroman@chromium.org

Review URL: https://codereview.chromium.org/193883002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@256301 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
pkasting@chromium.org committed Mar 11, 2014
1 parent 344c623 commit 85889c7
Show file tree
Hide file tree
Showing 11 changed files with 1 addition and 83 deletions.
18 changes: 0 additions & 18 deletions net/proxy/multi_threaded_proxy_resolver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ class MultiThreadedProxyResolver::Executor
// and resolver.
void Destroy();

void PurgeMemory();

// Returns the outstanding job, or NULL.
Job* outstanding_job() const { return outstanding_job_.get(); }

Expand Down Expand Up @@ -370,13 +368,6 @@ void MultiThreadedProxyResolver::Executor::Destroy() {
outstanding_job_ = NULL;
}

void MultiThreadedProxyResolver::Executor::PurgeMemory() {
thread_->message_loop()->PostTask(
FROM_HERE,
base::Bind(&ProxyResolver::PurgeMemory,
base::Unretained(resolver_.get())));
}

MultiThreadedProxyResolver::Executor::~Executor() {
// The important cleanup happens as part of Destroy(), which should always be
// called first.
Expand Down Expand Up @@ -483,15 +474,6 @@ void MultiThreadedProxyResolver::CancelSetPacScript() {
ReleaseAllExecutors();
}

void MultiThreadedProxyResolver::PurgeMemory() {
DCHECK(CalledOnValidThread());
for (ExecutorList::iterator it = executors_.begin();
it != executors_.end(); ++it) {
Executor* executor = it->get();
executor->PurgeMemory();
}
}

int MultiThreadedProxyResolver::SetPacScript(
const scoped_refptr<ProxyResolverScriptData>& script_data,
const CompletionCallback&callback) {
Expand Down
1 change: 0 additions & 1 deletion net/proxy/multi_threaded_proxy_resolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ class NET_EXPORT_PRIVATE MultiThreadedProxyResolver
virtual void CancelRequest(RequestHandle request) OVERRIDE;
virtual LoadState GetLoadState(RequestHandle request) const OVERRIDE;
virtual void CancelSetPacScript() OVERRIDE;
virtual void PurgeMemory() OVERRIDE;
virtual int SetPacScript(
const scoped_refptr<ProxyResolverScriptData>& script_data,
const CompletionCallback& callback) OVERRIDE;
Expand Down
27 changes: 1 addition & 26 deletions net/proxy/multi_threaded_proxy_resolver_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ class MockProxyResolver : public ProxyResolver {
MockProxyResolver()
: ProxyResolver(true /*expects_pac_bytes*/),
wrong_loop_(base::MessageLoop::current()),
request_count_(0),
purge_count_(0) {}
request_count_(0) {}

// ProxyResolver implementation.
virtual int GetProxyForURL(const GURL& query_url,
Expand Down Expand Up @@ -80,12 +79,6 @@ class MockProxyResolver : public ProxyResolver {
return OK;
}

virtual void PurgeMemory() OVERRIDE {
CheckIsOnWorkerThread();
++purge_count_;
}

int purge_count() const { return purge_count_; }
int request_count() const { return request_count_; }

const ProxyResolverScriptData* last_script_data() const {
Expand All @@ -107,7 +100,6 @@ class MockProxyResolver : public ProxyResolver {

base::MessageLoop* wrong_loop_;
int request_count_;
int purge_count_;
scoped_refptr<ProxyResolverScriptData> last_script_data_;
base::TimeDelta resolve_latency_;
};
Expand Down Expand Up @@ -196,10 +188,6 @@ class ForwardingProxyResolver : public ProxyResolver {
return impl_->SetPacScript(script_data, callback);
}

virtual void PurgeMemory() OVERRIDE {
impl_->PurgeMemory();
}

private:
ProxyResolver* impl_;
};
Expand Down Expand Up @@ -321,19 +309,6 @@ TEST(MultiThreadedProxyResolverTest, SingleThread_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.SetPacScript(ProxyResolverScriptData::FromUTF8("dummy"),
dummy_callback.callback());
EXPECT_EQ(OK, dummy_callback.WaitForResult());
EXPECT_EQ(1, mock->purge_count());
}

// Tests that the NetLog is updated to include the time the request was waiting
Expand Down
5 changes: 0 additions & 5 deletions net/proxy/proxy_resolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,6 @@ class NET_EXPORT_PRIVATE ProxyResolver {

virtual void CancelSetPacScript() = 0;

// Frees any unneeded memory held by the resolver, e.g. garbage in the JS
// engine. Most subclasses don't need to do anything, so we provide a default
// no-op implementation.
virtual void PurgeMemory() {}

// Called to set the PAC script backend to use.
// Returns ERR_IO_PENDING in the case of asynchronous completion, and notifies
// the result through |callback|.
Expand Down
11 changes: 0 additions & 11 deletions net/proxy/proxy_resolver_v8.cc
Original file line number Diff line number Diff line change
Expand Up @@ -504,12 +504,6 @@ class ProxyResolverV8::Context {
return OK;
}

void PurgeMemory() {
v8::Locker locked(isolate_);
v8::Isolate::Scope isolate_scope(isolate_);
v8::V8::LowMemoryNotification();
}

private:
bool GetFindProxyForURL(v8::Local<v8::Value>* function) {
v8::Local<v8::Context> context =
Expand Down Expand Up @@ -751,11 +745,6 @@ void ProxyResolverV8::CancelSetPacScript() {
NOTREACHED();
}

void ProxyResolverV8::PurgeMemory() {
if (context_)
context_->PurgeMemory();
}

int ProxyResolverV8::SetPacScript(
const scoped_refptr<ProxyResolverScriptData>& script_data,
const CompletionCallback& /*callback*/) {
Expand Down
1 change: 0 additions & 1 deletion net/proxy/proxy_resolver_v8.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ class NET_EXPORT_PRIVATE ProxyResolverV8 : public ProxyResolver {
virtual void CancelRequest(RequestHandle request) OVERRIDE;
virtual LoadState GetLoadState(RequestHandle request) const OVERRIDE;
virtual void CancelSetPacScript() OVERRIDE;
virtual void PurgeMemory() OVERRIDE;
virtual int SetPacScript(
const scoped_refptr<ProxyResolverScriptData>& script_data,
const net::CompletionCallback& /*callback*/) OVERRIDE;
Expand Down
9 changes: 0 additions & 9 deletions net/proxy/proxy_resolver_v8_tracing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1152,15 +1152,6 @@ void ProxyResolverV8Tracing::CancelSetPacScript() {
set_pac_script_job_ = NULL;
}

void ProxyResolverV8Tracing::PurgeMemory() {
thread_->message_loop()->PostTask(
FROM_HERE,
base::Bind(&ProxyResolverV8::PurgeMemory,
// The use of unretained is safe, since the worker thread
// cannot outlive |this|.
base::Unretained(v8_resolver_.get())));
}

int ProxyResolverV8Tracing::SetPacScript(
const scoped_refptr<ProxyResolverScriptData>& script_data,
const CompletionCallback& callback) {
Expand Down
1 change: 0 additions & 1 deletion net/proxy/proxy_resolver_v8_tracing.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ class NET_EXPORT_PRIVATE ProxyResolverV8Tracing
virtual void CancelRequest(RequestHandle request) OVERRIDE;
virtual LoadState GetLoadState(RequestHandle request) const OVERRIDE;
virtual void CancelSetPacScript() OVERRIDE;
virtual void PurgeMemory() OVERRIDE;
virtual int SetPacScript(
const scoped_refptr<ProxyResolverScriptData>& script_data,
const CompletionCallback& callback) OVERRIDE;
Expand Down
1 change: 0 additions & 1 deletion net/proxy/proxy_resolver_v8_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ class ProxyResolverV8WithMockBindings : public ProxyResolverV8 {
}

virtual ~ProxyResolverV8WithMockBindings() {
PurgeMemory();
}

MockJSBindings* mock_js_bindings() {
Expand Down
6 changes: 0 additions & 6 deletions net/proxy/proxy_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1355,12 +1355,6 @@ void ProxyService::ResetConfigService(
ApplyProxyConfigIfAvailable();
}

void ProxyService::PurgeMemory() {
DCHECK(CalledOnValidThread());
if (resolver_.get())
resolver_->PurgeMemory();
}

void ProxyService::ForceReloadProxyConfig() {
DCHECK(CalledOnValidThread());
ResetProxyConfig(false);
Expand Down
4 changes: 0 additions & 4 deletions net/proxy/proxy_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,6 @@ class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver,
// |new_proxy_config_service|.
void ResetConfigService(ProxyConfigService* new_proxy_config_service);

// Tells the resolver to purge any memory it does not need.
void PurgeMemory();


// Returns the last configuration fetched from ProxyConfigService.
const ProxyConfig& fetched_config() {
return fetched_config_;
Expand Down

0 comments on commit 85889c7

Please sign in to comment.