summaryrefslogtreecommitdiffstats
path: root/net/proxy
diff options
context:
space:
mode:
authorparitosh.in <paritosh.in@samsung.com>2015-08-25 10:57:49 -0700
committerCommit bot <commit-bot@chromium.org>2015-08-25 17:58:18 +0000
commit1dfe37962765a6a7b829085f127b638939ec3778 (patch)
treea5f7d969be10d62681c6e97986cdec0a75c5c565 /net/proxy
parent6f354ef7adff5a642d064d4a92ba3e02d6184971 (diff)
downloadchromium_src-1dfe37962765a6a7b829085f127b638939ec3778.zip
chromium_src-1dfe37962765a6a7b829085f127b638939ec3778.tar.gz
chromium_src-1dfe37962765a6a7b829085f127b638939ec3778.tar.bz2
Returning scoped_ptr<> instead of raw pointer in DhcpProxyScriptFetcherFactory::Create
BUG=472381 Review URL: https://codereview.chromium.org/1273013004 Cr-Commit-Position: refs/heads/master@{#345376}
Diffstat (limited to 'net/proxy')
-rw-r--r--net/proxy/dhcp_proxy_script_fetcher_factory.cc10
-rw-r--r--net/proxy/dhcp_proxy_script_fetcher_factory.h9
-rw-r--r--net/proxy/proxy_service.cc4
-rw-r--r--net/proxy/proxy_service.h4
-rw-r--r--net/proxy/proxy_service_mojo.cc10
-rw-r--r--net/proxy/proxy_service_mojo.h10
-rw-r--r--net/proxy/proxy_service_mojo_unittest.cc4
-rw-r--r--net/proxy/proxy_service_unittest.cc64
-rw-r--r--net/proxy/proxy_service_v8.cc4
-rw-r--r--net/proxy/proxy_service_v8.h8
10 files changed, 64 insertions, 63 deletions
diff --git a/net/proxy/dhcp_proxy_script_fetcher_factory.cc b/net/proxy/dhcp_proxy_script_fetcher_factory.cc
index 01ede05..ab89118 100644
--- a/net/proxy/dhcp_proxy_script_fetcher_factory.cc
+++ b/net/proxy/dhcp_proxy_script_fetcher_factory.cc
@@ -18,18 +18,18 @@ DhcpProxyScriptFetcherFactory::DhcpProxyScriptFetcherFactory()
set_enabled(true);
}
-DhcpProxyScriptFetcher* DhcpProxyScriptFetcherFactory::Create(
+scoped_ptr<DhcpProxyScriptFetcher> DhcpProxyScriptFetcherFactory::Create(
URLRequestContext* context) {
if (!feature_enabled_) {
- return new DoNothingDhcpProxyScriptFetcher();
+ return make_scoped_ptr(new DoNothingDhcpProxyScriptFetcher());
} else {
DCHECK(IsSupported());
- DhcpProxyScriptFetcher* ret = NULL;
+ scoped_ptr<DhcpProxyScriptFetcher> ret;
#if defined(OS_WIN)
- ret = new DhcpProxyScriptFetcherWin(context);
+ ret.reset(new DhcpProxyScriptFetcherWin(context));
#endif
DCHECK(ret);
- return ret;
+ return ret.Pass();
}
}
diff --git a/net/proxy/dhcp_proxy_script_fetcher_factory.h b/net/proxy/dhcp_proxy_script_fetcher_factory.h
index 147435d..1c315ad 100644
--- a/net/proxy/dhcp_proxy_script_fetcher_factory.h
+++ b/net/proxy/dhcp_proxy_script_fetcher_factory.h
@@ -9,10 +9,10 @@
#include "base/memory/singleton.h"
#include "net/base/completion_callback.h"
#include "net/base/net_export.h"
+#include "net/proxy/dhcp_proxy_script_fetcher.h"
namespace net {
-class DhcpProxyScriptFetcher;
class URLRequestContext;
// Factory object for creating the appropriate concrete base class of
@@ -34,14 +34,15 @@ class NET_EXPORT DhcpProxyScriptFetcherFactory {
// Creates a new factory object with default settings.
DhcpProxyScriptFetcherFactory();
- // Ownership is transferred to the caller. url_request_context must be valid
- // and its lifetime must exceed that of the returned DhcpProxyScriptFetcher.
+ // url_request_context must be valid and its lifetime must exceed that of the
+ // returned DhcpProxyScriptFetcher.
//
// Note that while a request is in progress, the fetcher may be holding a
// reference to |url_request_context|. Be careful not to create cycles
// between the fetcher and the context; you can break such cycles by calling
// Cancel().
- DhcpProxyScriptFetcher* Create(URLRequestContext* url_request_context);
+ scoped_ptr<DhcpProxyScriptFetcher> Create(
+ URLRequestContext* url_request_context);
// Attempts to enable/disable the DHCP WPAD feature. Does nothing
// if |IsSupported()| returns false.
diff --git a/net/proxy/proxy_service.cc b/net/proxy/proxy_service.cc
index d2075c1..1925a97 100644
--- a/net/proxy/proxy_service.cc
+++ b/net/proxy/proxy_service.cc
@@ -1442,11 +1442,11 @@ int ProxyService::DidFinishResolvingProxy(const GURL& url,
void ProxyService::SetProxyScriptFetchers(
ProxyScriptFetcher* proxy_script_fetcher,
- DhcpProxyScriptFetcher* dhcp_proxy_script_fetcher) {
+ scoped_ptr<DhcpProxyScriptFetcher> dhcp_proxy_script_fetcher) {
DCHECK(CalledOnValidThread());
State previous_state = ResetProxyConfig(false);
proxy_script_fetcher_.reset(proxy_script_fetcher);
- dhcp_proxy_script_fetcher_.reset(dhcp_proxy_script_fetcher);
+ dhcp_proxy_script_fetcher_ = dhcp_proxy_script_fetcher.Pass();
if (previous_state != STATE_NONE)
ApplyProxyConfigIfAvailable();
}
diff --git a/net/proxy/proxy_service.h b/net/proxy/proxy_service.h
index e0f8077..69ff3d8 100644
--- a/net/proxy/proxy_service.h
+++ b/net/proxy/proxy_service.h
@@ -193,10 +193,10 @@ class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver,
// Sets the ProxyScriptFetcher and DhcpProxyScriptFetcher dependencies. This
// is needed if the ProxyResolver is of type ProxyResolverWithoutFetch.
- // ProxyService takes ownership of both objects.
+ // ProxyService takes ownership of proxy_script_fetcher.
void SetProxyScriptFetchers(
ProxyScriptFetcher* proxy_script_fetcher,
- DhcpProxyScriptFetcher* dhcp_proxy_script_fetcher);
+ scoped_ptr<DhcpProxyScriptFetcher> dhcp_proxy_script_fetcher);
ProxyScriptFetcher* GetProxyScriptFetcher() const;
// Tells this ProxyService to start using a new ProxyConfigService to
diff --git a/net/proxy/proxy_service_mojo.cc b/net/proxy/proxy_service_mojo.cc
index 689b870..92f8938 100644
--- a/net/proxy/proxy_service_mojo.cc
+++ b/net/proxy/proxy_service_mojo.cc
@@ -23,7 +23,7 @@ ProxyService* CreateProxyServiceUsingMojoFactory(
MojoProxyResolverFactory* mojo_proxy_factory,
ProxyConfigService* proxy_config_service,
ProxyScriptFetcher* proxy_script_fetcher,
- DhcpProxyScriptFetcher* dhcp_proxy_script_fetcher,
+ scoped_ptr<DhcpProxyScriptFetcher> dhcp_proxy_script_fetcher,
HostResolver* host_resolver,
NetLog* net_log,
NetworkDelegate* network_delegate) {
@@ -43,7 +43,7 @@ ProxyService* CreateProxyServiceUsingMojoFactory(
// Configure fetchers to use for PAC script downloads and auto-detect.
proxy_service->SetProxyScriptFetchers(proxy_script_fetcher,
- dhcp_proxy_script_fetcher);
+ dhcp_proxy_script_fetcher.Pass());
return proxy_service;
}
@@ -51,14 +51,14 @@ ProxyService* CreateProxyServiceUsingMojoFactory(
ProxyService* CreateProxyServiceUsingMojoInProcess(
ProxyConfigService* proxy_config_service,
ProxyScriptFetcher* proxy_script_fetcher,
- DhcpProxyScriptFetcher* dhcp_proxy_script_fetcher,
+ scoped_ptr<DhcpProxyScriptFetcher> dhcp_proxy_script_fetcher,
HostResolver* host_resolver,
NetLog* net_log,
NetworkDelegate* network_delegate) {
return CreateProxyServiceUsingMojoFactory(
InProcessMojoProxyResolverFactory::GetInstance(), proxy_config_service,
- proxy_script_fetcher, dhcp_proxy_script_fetcher, host_resolver, net_log,
- network_delegate);
+ proxy_script_fetcher, dhcp_proxy_script_fetcher.Pass(), host_resolver,
+ net_log, network_delegate);
}
} // namespace net
diff --git a/net/proxy/proxy_service_mojo.h b/net/proxy/proxy_service_mojo.h
index 8757421..d7faf08 100644
--- a/net/proxy/proxy_service_mojo.h
+++ b/net/proxy/proxy_service_mojo.h
@@ -6,13 +6,14 @@
#define NET_PROXY_PROXY_SERVICE_MOJO_H_
#include "base/basictypes.h"
+#include "base/memory/scoped_ptr.h"
+#include "net/proxy/dhcp_proxy_script_fetcher.h"
namespace net {
namespace interfaces {
class ProxyResolverFactory;
}
-class DhcpProxyScriptFetcher;
class HostResolver;
class MojoProxyResolverFactory;
class NetLog;
@@ -30,8 +31,7 @@ class ProxyService;
// any PAC scripts. The resulting ProxyService will take ownership of it.
//
// |dhcp_proxy_script_fetcher| specifies the dependency to use for attempting
-// to retrieve the most appropriate PAC script configured in DHCP. The
-// resulting ProxyService will take ownership of it.
+// to retrieve the most appropriate PAC script configured in DHCP.
//
// |host_resolver| points to the host resolving dependency the PAC script
// should use for any DNS queries. It must remain valid throughout the
@@ -40,7 +40,7 @@ ProxyService* CreateProxyServiceUsingMojoFactory(
MojoProxyResolverFactory* mojo_proxy_factory,
ProxyConfigService* proxy_config_service,
ProxyScriptFetcher* proxy_script_fetcher,
- DhcpProxyScriptFetcher* dhcp_proxy_script_fetcher,
+ scoped_ptr<DhcpProxyScriptFetcher> dhcp_proxy_script_fetcher,
HostResolver* host_resolver,
NetLog* net_log,
NetworkDelegate* network_delegate);
@@ -56,7 +56,7 @@ ProxyService* CreateProxyServiceUsingMojoFactory(
ProxyService* CreateProxyServiceUsingMojoInProcess(
ProxyConfigService* proxy_config_service,
ProxyScriptFetcher* proxy_script_fetcher,
- DhcpProxyScriptFetcher* dhcp_proxy_script_fetcher,
+ scoped_ptr<DhcpProxyScriptFetcher> dhcp_proxy_script_fetcher,
HostResolver* host_resolver,
NetLog* net_log,
NetworkDelegate* network_delegate);
diff --git a/net/proxy/proxy_service_mojo_unittest.cc b/net/proxy/proxy_service_mojo_unittest.cc
index 171f89b..28ad77b 100644
--- a/net/proxy/proxy_service_mojo_unittest.cc
+++ b/net/proxy/proxy_service_mojo_unittest.cc
@@ -129,8 +129,8 @@ class ProxyServiceMojoTest : public testing::Test,
proxy_service_.reset(CreateProxyServiceUsingMojoFactory(
this, new ProxyConfigServiceFixed(
ProxyConfig::CreateFromCustomPacURL(GURL(kPacUrl))),
- fetcher_, new DoNothingDhcpProxyScriptFetcher(), &mock_host_resolver_,
- &net_log_, &network_delegate_));
+ fetcher_, make_scoped_ptr(new DoNothingDhcpProxyScriptFetcher()),
+ &mock_host_resolver_, &net_log_, &network_delegate_));
}
scoped_ptr<base::ScopedClosureRunner> CreateResolver(
diff --git a/net/proxy/proxy_service_unittest.cc b/net/proxy/proxy_service_unittest.cc
index 6d6c747..55c575f 100644
--- a/net/proxy/proxy_service_unittest.cc
+++ b/net/proxy/proxy_service_unittest.cc
@@ -943,8 +943,8 @@ TEST_F(ProxyServiceTest, ProxyResolverFailsParsingJavaScriptMandatoryPac) {
ProxyService service(config_service, make_scoped_ptr(factory), NULL);
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
- DhcpProxyScriptFetcher* dhcp_fetcher = new DoNothingDhcpProxyScriptFetcher();
- service.SetProxyScriptFetchers(fetcher, dhcp_fetcher);
+ service.SetProxyScriptFetchers(
+ fetcher, make_scoped_ptr(new DoNothingDhcpProxyScriptFetcher()));
// Start resolve request.
GURL url("http://www.google.com/");
@@ -1859,8 +1859,8 @@ TEST_F(ProxyServiceTest, InitialPACScriptDownload) {
ProxyService service(config_service, make_scoped_ptr(factory), NULL);
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
- service.SetProxyScriptFetchers(fetcher,
- new DoNothingDhcpProxyScriptFetcher());
+ service.SetProxyScriptFetchers(
+ fetcher, make_scoped_ptr(new DoNothingDhcpProxyScriptFetcher()));
// Start 3 requests.
@@ -1966,8 +1966,8 @@ TEST_F(ProxyServiceTest, ChangeScriptFetcherWhilePACDownloadInProgress) {
ProxyService service(config_service, make_scoped_ptr(factory), NULL);
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
- service.SetProxyScriptFetchers(fetcher,
- new DoNothingDhcpProxyScriptFetcher());
+ service.SetProxyScriptFetchers(
+ fetcher, make_scoped_ptr(new DoNothingDhcpProxyScriptFetcher()));
// Start 2 requests.
@@ -1996,8 +1996,8 @@ TEST_F(ProxyServiceTest, ChangeScriptFetcherWhilePACDownloadInProgress) {
// the initialization with the new fetcher.
fetcher = new MockProxyScriptFetcher;
- service.SetProxyScriptFetchers(fetcher,
- new DoNothingDhcpProxyScriptFetcher());
+ service.SetProxyScriptFetchers(
+ fetcher, make_scoped_ptr(new DoNothingDhcpProxyScriptFetcher()));
// Nothing has been sent to the factory yet.
EXPECT_TRUE(factory->pending_requests().empty());
@@ -2027,8 +2027,8 @@ TEST_F(ProxyServiceTest, CancelWhilePACFetching) {
ProxyService service(config_service, make_scoped_ptr(factory), NULL);
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
- service.SetProxyScriptFetchers(fetcher,
- new DoNothingDhcpProxyScriptFetcher());
+ service.SetProxyScriptFetchers(
+ fetcher, make_scoped_ptr(new DoNothingDhcpProxyScriptFetcher()));
// Start 3 requests.
ProxyInfo info1;
@@ -2122,8 +2122,8 @@ TEST_F(ProxyServiceTest, FallbackFromAutodetectToCustomPac) {
ProxyService service(config_service, make_scoped_ptr(factory), NULL);
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
- service.SetProxyScriptFetchers(fetcher,
- new DoNothingDhcpProxyScriptFetcher());
+ service.SetProxyScriptFetchers(
+ fetcher, make_scoped_ptr(new DoNothingDhcpProxyScriptFetcher()));
// Start 2 requests.
@@ -2202,8 +2202,8 @@ TEST_F(ProxyServiceTest, FallbackFromAutodetectToCustomPac2) {
ProxyService service(config_service, make_scoped_ptr(factory), NULL);
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
- service.SetProxyScriptFetchers(fetcher,
- new DoNothingDhcpProxyScriptFetcher());
+ service.SetProxyScriptFetchers(
+ fetcher, make_scoped_ptr(new DoNothingDhcpProxyScriptFetcher()));
// Start 2 requests.
@@ -2277,8 +2277,8 @@ TEST_F(ProxyServiceTest, FallbackFromAutodetectToCustomToManual) {
ProxyService service(config_service, make_scoped_ptr(factory), NULL);
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
- service.SetProxyScriptFetchers(fetcher,
- new DoNothingDhcpProxyScriptFetcher());
+ service.SetProxyScriptFetchers(
+ fetcher, make_scoped_ptr(new DoNothingDhcpProxyScriptFetcher()));
// Start 2 requests.
@@ -2338,8 +2338,8 @@ TEST_F(ProxyServiceTest, BypassDoesntApplyToPac) {
ProxyService service(config_service, make_scoped_ptr(factory), NULL);
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
- service.SetProxyScriptFetchers(fetcher,
- new DoNothingDhcpProxyScriptFetcher());
+ service.SetProxyScriptFetchers(
+ fetcher, make_scoped_ptr(new DoNothingDhcpProxyScriptFetcher()));
// Start 1 requests.
@@ -2407,8 +2407,8 @@ TEST_F(ProxyServiceTest, DeleteWhileInitProxyResolverHasOutstandingFetch) {
ProxyService service(config_service, make_scoped_ptr(factory), NULL);
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
- service.SetProxyScriptFetchers(fetcher,
- new DoNothingDhcpProxyScriptFetcher());
+ service.SetProxyScriptFetchers(
+ fetcher, make_scoped_ptr(new DoNothingDhcpProxyScriptFetcher()));
// Start 1 request.
@@ -2542,8 +2542,8 @@ TEST_F(ProxyServiceTest, NetworkChangeTriggersPacRefetch) {
ProxyService service(config_service, make_scoped_ptr(factory), &log);
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
- service.SetProxyScriptFetchers(fetcher,
- new DoNothingDhcpProxyScriptFetcher());
+ service.SetProxyScriptFetchers(
+ fetcher, make_scoped_ptr(new DoNothingDhcpProxyScriptFetcher()));
// Disable the "wait after IP address changes" hack, so this unit-test can
// complete quickly.
@@ -2662,8 +2662,8 @@ TEST_F(ProxyServiceTest, PACScriptRefetchAfterFailure) {
ProxyService service(config_service, make_scoped_ptr(factory), NULL);
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
- service.SetProxyScriptFetchers(fetcher,
- new DoNothingDhcpProxyScriptFetcher());
+ service.SetProxyScriptFetchers(
+ fetcher, make_scoped_ptr(new DoNothingDhcpProxyScriptFetcher()));
// Start 1 request.
@@ -2767,8 +2767,8 @@ TEST_F(ProxyServiceTest, PACScriptRefetchAfterContentChange) {
ProxyService service(config_service, make_scoped_ptr(factory), NULL);
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
- service.SetProxyScriptFetchers(fetcher,
- new DoNothingDhcpProxyScriptFetcher());
+ service.SetProxyScriptFetchers(
+ fetcher, make_scoped_ptr(new DoNothingDhcpProxyScriptFetcher()));
// Start 1 request.
@@ -2878,8 +2878,8 @@ TEST_F(ProxyServiceTest, PACScriptRefetchAfterContentUnchanged) {
ProxyService service(config_service, make_scoped_ptr(factory), NULL);
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
- service.SetProxyScriptFetchers(fetcher,
- new DoNothingDhcpProxyScriptFetcher());
+ service.SetProxyScriptFetchers(
+ fetcher, make_scoped_ptr(new DoNothingDhcpProxyScriptFetcher()));
// Start 1 request.
@@ -2986,8 +2986,8 @@ TEST_F(ProxyServiceTest, PACScriptRefetchAfterSuccess) {
ProxyService service(config_service, make_scoped_ptr(factory), NULL);
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
- service.SetProxyScriptFetchers(fetcher,
- new DoNothingDhcpProxyScriptFetcher());
+ service.SetProxyScriptFetchers(
+ fetcher, make_scoped_ptr(new DoNothingDhcpProxyScriptFetcher()));
// Start 1 request.
@@ -3139,8 +3139,8 @@ TEST_F(ProxyServiceTest, PACScriptRefetchAfterActivity) {
ProxyService service(config_service, make_scoped_ptr(factory), NULL);
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
- service.SetProxyScriptFetchers(fetcher,
- new DoNothingDhcpProxyScriptFetcher());
+ service.SetProxyScriptFetchers(
+ fetcher, make_scoped_ptr(new DoNothingDhcpProxyScriptFetcher()));
// Start 1 request.
diff --git a/net/proxy/proxy_service_v8.cc b/net/proxy/proxy_service_v8.cc
index 46a6605..6815564 100644
--- a/net/proxy/proxy_service_v8.cc
+++ b/net/proxy/proxy_service_v8.cc
@@ -19,7 +19,7 @@ namespace net {
ProxyService* CreateProxyServiceUsingV8ProxyResolver(
ProxyConfigService* proxy_config_service,
ProxyScriptFetcher* proxy_script_fetcher,
- DhcpProxyScriptFetcher* dhcp_proxy_script_fetcher,
+ scoped_ptr<DhcpProxyScriptFetcher> dhcp_proxy_script_fetcher,
HostResolver* host_resolver,
NetLog* net_log,
NetworkDelegate* network_delegate) {
@@ -38,7 +38,7 @@ ProxyService* CreateProxyServiceUsingV8ProxyResolver(
// Configure fetchers to use for PAC script downloads and auto-detect.
proxy_service->SetProxyScriptFetchers(proxy_script_fetcher,
- dhcp_proxy_script_fetcher);
+ dhcp_proxy_script_fetcher.Pass());
return proxy_service;
}
diff --git a/net/proxy/proxy_service_v8.h b/net/proxy/proxy_service_v8.h
index 0e339eb..65e5d7c 100644
--- a/net/proxy/proxy_service_v8.h
+++ b/net/proxy/proxy_service_v8.h
@@ -6,11 +6,12 @@
#define NET_PROXY_PROXY_SERVICE_V8_H_
#include "base/basictypes.h"
+#include "base/memory/scoped_ptr.h"
#include "net/base/net_export.h"
+#include "net/proxy/dhcp_proxy_script_fetcher.h"
namespace net {
-class DhcpProxyScriptFetcher;
class HostResolver;
class NetLog;
class NetworkDelegate;
@@ -25,8 +26,7 @@ class ProxyService;
// any PAC scripts. The resulting ProxyService will take ownership of it.
//
// |dhcp_proxy_script_fetcher| specifies the dependency to use for attempting
-// to retrieve the most appropriate PAC script configured in DHCP. The
-// resulting ProxyService will take ownership of it.
+// to retrieve the most appropriate PAC script configured in DHCP.
//
// |host_resolver| points to the host resolving dependency the PAC script
// should use for any DNS queries. It must remain valid throughout the
@@ -40,7 +40,7 @@ class ProxyService;
NET_EXPORT ProxyService* CreateProxyServiceUsingV8ProxyResolver(
ProxyConfigService* proxy_config_service,
ProxyScriptFetcher* proxy_script_fetcher,
- DhcpProxyScriptFetcher* dhcp_proxy_script_fetcher,
+ scoped_ptr<DhcpProxyScriptFetcher> dhcp_proxy_script_fetcher,
HostResolver* host_resolver,
NetLog* net_log,
NetworkDelegate* network_delegate);