summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-17 22:21:14 +0000
committerericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-17 22:21:14 +0000
commite8d536191b4a0f0264bb20693e87b60813e573dc (patch)
treebfeb61d7dee7f1f21506ccb6f6abb5935983e3fd
parent8071f91036958af3c569f06b326f66982930226e (diff)
downloadchromium_src-e8d536191b4a0f0264bb20693e87b60813e573dc.zip
chromium_src-e8d536191b4a0f0264bb20693e87b60813e573dc.tar.gz
chromium_src-e8d536191b4a0f0264bb20693e87b60813e573dc.tar.bz2
Misc cleanups
- leak in unittest - remove a platform ifdef Review URL: http://codereview.chromium.org/7500 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3573 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--net/build/net.vcproj4
-rw-r--r--net/http/http_network_layer.cc3
-rw-r--r--net/http/http_network_transaction_unittest.cc28
-rw-r--r--net/net.xcodeproj/project.pbxproj2
-rw-r--r--net/proxy/proxy_resolver_null.h28
-rw-r--r--net/proxy/proxy_service.cc8
6 files changed, 47 insertions, 26 deletions
diff --git a/net/build/net.vcproj b/net/build/net.vcproj
index b711b49..aa71faf 100644
--- a/net/build/net.vcproj
+++ b/net/build/net.vcproj
@@ -1009,6 +1009,10 @@
>
</File>
<File
+ RelativePath="..\proxy\proxy_resolver_null.h"
+ >
+ </File>
+ <File
RelativePath="..\proxy\proxy_resolver_winhttp.cc"
>
</File>
diff --git a/net/http/http_network_layer.cc b/net/http/http_network_layer.cc
index 8c504fc..1107884 100644
--- a/net/http/http_network_layer.cc
+++ b/net/http/http_network_layer.cc
@@ -9,6 +9,7 @@
#include "net/http/http_network_session.h"
#include "net/http/http_network_transaction.h"
#include "net/proxy/proxy_resolver_fixed.h"
+#include "net/proxy/proxy_resolver_null.h"
#if defined(OS_WIN)
#include "net/http/http_transaction_winhttp.h"
#include "net/proxy/proxy_resolver_winhttp.h"
@@ -53,7 +54,7 @@ HttpNetworkLayer::HttpNetworkLayer(const ProxyInfo* pi)
proxy_resolver = new ProxyResolverWinHttp();
#else
NOTIMPLEMENTED();
- proxy_resolver = NULL;
+ proxy_resolver = new ProxyResolverNull();
#endif
}
session_ = new HttpNetworkSession(proxy_resolver);
diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc
index 2f63d86..7b2f04f 100644
--- a/net/http/http_network_transaction_unittest.cc
+++ b/net/http/http_network_transaction_unittest.cc
@@ -11,6 +11,7 @@
#include "net/http/http_network_transaction.h"
#include "net/http/http_transaction_unittest.h"
#include "net/proxy/proxy_resolver_fixed.h"
+#include "net/proxy/proxy_resolver_null.h"
#include "testing/gtest/include/gtest/gtest.h"
//-----------------------------------------------------------------------------
@@ -195,26 +196,17 @@ class MockClientSocketFactory : public net::ClientSocketFactory {
MockClientSocketFactory mock_socket_factory;
-class NullProxyResolver : public net::ProxyResolver {
- public:
- virtual int GetProxyConfig(net::ProxyConfig* config) {
- return net::ERR_FAILED;
+net::HttpNetworkSession* CreateSession(net::ProxyResolver* proxy_resolver) {
+ if (!proxy_resolver) {
+ proxy_resolver = new net::ProxyResolverNull();
}
- virtual int GetProxyForURL(const std::string& query_url,
- const std::string& pac_url,
- net::ProxyInfo* results) {
- return net::ERR_FAILED;
- }
-};
-
-// TODO(eroman): google style disallows default arguments...
-net::HttpNetworkSession* CreateSession(
- net::ProxyResolver* proxy_resolver = NULL) {
- if (!proxy_resolver)
- proxy_resolver = new NullProxyResolver();
return new net::HttpNetworkSession(proxy_resolver);
}
+net::HttpNetworkSession* CreateSession() {
+ return CreateSession(NULL);
+}
+
class HttpNetworkTransactionTest : public PlatformTest {
public:
virtual void SetUp() {
@@ -261,8 +253,10 @@ SimpleGetHelperResult SimpleGetHelper(MockRead data_reads[]) {
EXPECT_EQ(net::ERR_IO_PENDING, rv);
out.rv = callback.WaitForResult();
- if (out.rv != net::OK)
+ if (out.rv != net::OK) {
+ trans->Destroy();
return out;
+ }
const net::HttpResponseInfo* response = trans->GetResponseInfo();
EXPECT_TRUE(response != NULL);
diff --git a/net/net.xcodeproj/project.pbxproj b/net/net.xcodeproj/project.pbxproj
index 99f8673..2828f5a 100644
--- a/net/net.xcodeproj/project.pbxproj
+++ b/net/net.xcodeproj/project.pbxproj
@@ -410,6 +410,7 @@
0435A48D0E8DD74300E4DF08 /* http_auth_handler_basic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = http_auth_handler_basic.h; sourceTree = "<group>"; };
0435A48E0E8DD74B00E4DF08 /* http_auth_handler_digest.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = http_auth_handler_digest.cc; sourceTree = "<group>"; };
0435A4900E8DD75200E4DF08 /* http_auth_handler_digest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = http_auth_handler_digest.h; sourceTree = "<group>"; };
+ 04AC41720EA941AE0063A0AB /* proxy_resolver_null.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = proxy_resolver_null.h; path = proxy/proxy_resolver_null.h; sourceTree = "<group>"; };
04C626D50E8DE39E0067E92A /* http_auth_handler_digest_unittest.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = http_auth_handler_digest_unittest.cc; sourceTree = "<group>"; };
04C626D70E8DE3AA0067E92A /* http_auth_handler_basic_unittest.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = http_auth_handler_basic_unittest.cc; sourceTree = "<group>"; };
04C626D90E8DE3BA0067E92A /* http_auth_unittest.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = http_auth_unittest.cc; sourceTree = "<group>"; };
@@ -1135,6 +1136,7 @@
children = (
E49DD33A0E8933C0003C7A87 /* proxy_resolver_fixed.h */,
E49DD33B0E8933C0003C7A87 /* proxy_resolver_fixed.cc */,
+ 04AC41720EA941AE0063A0AB /* proxy_resolver_null.h */,
E49DD3350E8933A2003C7A87 /* proxy_service.h */,
E49DD3360E8933A2003C7A87 /* proxy_service.cc */,
7BA361EC0E8C38D30023C8B9 /* proxy_service_unittest.cc */,
diff --git a/net/proxy/proxy_resolver_null.h b/net/proxy/proxy_resolver_null.h
new file mode 100644
index 0000000..b9f0b32
--- /dev/null
+++ b/net/proxy/proxy_resolver_null.h
@@ -0,0 +1,28 @@
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef NET_PROXY_PROXY_RESOLVER_NULL_H_
+#define NET_PROXY_PROXY_RESOLVER_NULL_H_
+
+#include "net/proxy/proxy_service.h"
+
+namespace net {
+
+// Implementation of ProxyResolver that always fails.
+class ProxyResolverNull : public ProxyResolver {
+ public:
+ virtual int GetProxyConfig(ProxyConfig* config) {
+ return ERR_FAILED;
+ }
+ virtual int GetProxyForURL(const std::string& query_url,
+ const std::string& pac_url,
+ ProxyInfo* results) {
+ return ERR_FAILED;
+ }
+};
+
+} // namespace net
+
+#endif // NET_PROXY_PROXY_RESOLVER_NULL_H_
+
diff --git a/net/proxy/proxy_service.cc b/net/proxy/proxy_service.cc
index af53ff8..be11692 100644
--- a/net/proxy/proxy_service.cc
+++ b/net/proxy/proxy_service.cc
@@ -421,14 +421,6 @@ void ProxyService::DidCompletePacRequest(int config_id, int result_code) {
}
void ProxyService::UpdateConfig() {
-#if !defined(WIN_OS)
- if (!resolver_) {
- // Tied to the NOTIMPLEMENTED in HttpNetworkLayer::HttpNetworkLayer()
- NOTIMPLEMENTED();
- return;
- }
-#endif
-
ProxyConfig latest;
if (resolver_->GetProxyConfig(&latest) != OK)
return;