0

net: Add NET_API to more code to enable building

a shared net library on Linux, and update base and
crypto API definitions.

BUG=76997
TEST=none
Review URL: http://codereview.chromium.org/7240021

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@91234 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
rvargas@google.com
2011-06-30 23:51:24 +00:00
parent 3be6c69d07
commit 84ea2d04c0
11 changed files with 76 additions and 44 deletions

@@ -8,15 +8,18 @@
#if defined(BASE_DLL) #if defined(BASE_DLL)
#if defined(WIN32) #if defined(WIN32)
#if defined(BASE_IMPLEMENTATION) #if defined(BASE_IMPLEMENTATION)
#define BASE_API __declspec(dllexport) #define BASE_API __declspec(dllexport)
#else #else
#define BASE_API __declspec(dllimport) #define BASE_API __declspec(dllimport)
#endif // defined(BASE_IMPLEMENTATION) #endif // defined(BASE_IMPLEMENTATION)
#else
#else // defined(WIN32)
#define BASE_API __attribute__((visibility("default"))) #define BASE_API __attribute__((visibility("default")))
#endif // defined(WIN32) #endif
#else
#else // defined(BASE_DLL)
#define BASE_API #define BASE_API
#endif #endif

@@ -8,15 +8,18 @@
#if defined(CRYPTO_DLL) #if defined(CRYPTO_DLL)
#if defined(WIN32) #if defined(WIN32)
#if defined(CRYPTO_IMPLEMENTATION) #if defined(CRYPTO_IMPLEMENTATION)
#define CRYPTO_API __declspec(dllexport) #define CRYPTO_API __declspec(dllexport)
#else #else
#define CRYPTO_API __declspec(dllimport) #define CRYPTO_API __declspec(dllimport)
#endif // defined(CRYPTO_IMPLEMENTATION) #endif // defined(CRYPTO_IMPLEMENTATION)
#else
#else // defined(WIN32)
#define CRYPTO_API __attribute__((visibility("default"))) #define CRYPTO_API __attribute__((visibility("default")))
#endif // defined(WIN32) #endif
#else
#else // defined(CRYPTO_DLL)
#define CRYPTO_API #define CRYPTO_API
#endif #endif

@@ -10,7 +10,9 @@
// exported to consumers, and NET_TEST that allows unit tests to access features // exported to consumers, and NET_TEST that allows unit tests to access features
// not intended to be used directly by real consumers. // not intended to be used directly by real consumers.
#if defined(WIN32) && defined(NET_DLL) #if defined(NET_DLL)
#if defined(WIN32)
#if defined(NET_IMPLEMENTATION) #if defined(NET_IMPLEMENTATION)
#define NET_API __declspec(dllexport) #define NET_API __declspec(dllexport)
#define NET_TEST __declspec(dllexport) #define NET_TEST __declspec(dllexport)
@@ -18,7 +20,13 @@
#define NET_API __declspec(dllimport) #define NET_API __declspec(dllimport)
#define NET_TEST __declspec(dllimport) #define NET_TEST __declspec(dllimport)
#endif // defined(NET_IMPLEMENTATION) #endif // defined(NET_IMPLEMENTATION)
#else
#else // defined(WIN32)
#define NET_API __attribute__((visibility("default")))
#define NET_TEST __attribute__((visibility("default")))
#endif
#else /// defined(NET_DLL)
#define NET_API #define NET_API
#define NET_TEST #define NET_TEST
#endif #endif

@@ -1,4 +1,4 @@
// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
@@ -11,6 +11,7 @@
#include "base/gtest_prod_util.h" #include "base/gtest_prod_util.h"
#include "base/native_library.h" #include "base/native_library.h"
#include "base/string16.h" #include "base/string16.h"
#include "net/base/net_api.h"
#include "net/http/http_auth.h" #include "net/http/http_auth.h"
#define GSS_USE_FUNCTION_POINTERS #define GSS_USE_FUNCTION_POINTERS
@@ -26,7 +27,7 @@ extern gss_OID CHROME_GSS_KRB5_MECH_OID_DESC;
// library. The default implementation attempts to load one of the standard // library. The default implementation attempts to load one of the standard
// GSSAPI library implementations, then simply passes the arguments on to // GSSAPI library implementations, then simply passes the arguments on to
// that implementation. // that implementation.
class GSSAPILibrary { class NET_TEST GSSAPILibrary {
public: public:
virtual ~GSSAPILibrary() {} virtual ~GSSAPILibrary() {}
@@ -98,7 +99,7 @@ class GSSAPILibrary {
}; };
// GSSAPISharedLibrary class is defined here so that unit tests can access it. // GSSAPISharedLibrary class is defined here so that unit tests can access it.
class GSSAPISharedLibrary : public GSSAPILibrary { class NET_TEST GSSAPISharedLibrary : public GSSAPILibrary {
public: public:
// If |gssapi_library_name| is empty, hard-coded default library names are // If |gssapi_library_name| is empty, hard-coded default library names are
// used. // used.
@@ -213,7 +214,7 @@ class ScopedSecurityContext {
// TODO(ahendrickson): Share code with HttpAuthSSPI. // TODO(ahendrickson): Share code with HttpAuthSSPI.
class HttpAuthGSSAPI { class NET_TEST HttpAuthGSSAPI {
public: public:
HttpAuthGSSAPI(GSSAPILibrary* library, HttpAuthGSSAPI(GSSAPILibrary* library,
const std::string& scheme, const std::string& scheme,

@@ -1,4 +1,4 @@
// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
@@ -35,7 +35,7 @@ namespace net {
class URLSecurityManager; class URLSecurityManager;
// Code for handling HTTP NTLM authentication. // Code for handling HTTP NTLM authentication.
class HttpAuthHandlerNTLM : public HttpAuthHandler { class NET_TEST HttpAuthHandlerNTLM : public HttpAuthHandler {
public: public:
class Factory : public HttpAuthHandlerFactory { class Factory : public HttpAuthHandlerFactory {
public: public:

@@ -63,8 +63,36 @@ void HttpNetworkSession::RemoveResponseDrainer(
response_drainers_.erase(drainer); response_drainers_.erase(drainer);
} }
SOCKSClientSocketPool* HttpNetworkSession::GetSocketPoolForSOCKSProxy(
const HostPortPair& socks_proxy) {
return socket_pool_manager_.GetSocketPoolForSOCKSProxy(socks_proxy);
}
HttpProxyClientSocketPool* HttpNetworkSession::GetSocketPoolForHTTPProxy(
const HostPortPair& http_proxy) {
return socket_pool_manager_.GetSocketPoolForHTTPProxy(http_proxy);
}
SSLClientSocketPool* HttpNetworkSession::GetSocketPoolForSSLWithProxy(
const HostPortPair& proxy_server) {
return socket_pool_manager_.GetSocketPoolForSSLWithProxy(proxy_server);
}
Value* HttpNetworkSession::SocketPoolInfoToValue() const {
return socket_pool_manager_.SocketPoolInfoToValue();
}
Value* HttpNetworkSession::SpdySessionPoolInfoToValue() const { Value* HttpNetworkSession::SpdySessionPoolInfoToValue() const {
return spdy_session_pool_.SpdySessionPoolInfoToValue(); return spdy_session_pool_.SpdySessionPoolInfoToValue();
} }
void HttpNetworkSession::CloseAllConnections() {
socket_pool_manager_.FlushSocketPools();
spdy_session_pool_.CloseCurrentSessions();
}
void HttpNetworkSession::CloseIdleConnections() {
socket_pool_manager_.CloseIdleSockets();
}
} // namespace net } // namespace net

@@ -98,19 +98,13 @@ class NET_API HttpNetworkSession
} }
SOCKSClientSocketPool* GetSocketPoolForSOCKSProxy( SOCKSClientSocketPool* GetSocketPoolForSOCKSProxy(
const HostPortPair& socks_proxy) { const HostPortPair& socks_proxy);
return socket_pool_manager_.GetSocketPoolForSOCKSProxy(socks_proxy);
}
HttpProxyClientSocketPool* GetSocketPoolForHTTPProxy( HttpProxyClientSocketPool* GetSocketPoolForHTTPProxy(
const HostPortPair& http_proxy) { const HostPortPair& http_proxy);
return socket_pool_manager_.GetSocketPoolForHTTPProxy(http_proxy);
}
SSLClientSocketPool* GetSocketPoolForSSLWithProxy( SSLClientSocketPool* GetSocketPoolForSSLWithProxy(
const HostPortPair& proxy_server) { const HostPortPair& proxy_server);
return socket_pool_manager_.GetSocketPoolForSSLWithProxy(proxy_server);
}
CertVerifier* cert_verifier() { return cert_verifier_; } CertVerifier* cert_verifier() { return cert_verifier_; }
ProxyService* proxy_service() { return proxy_service_; } ProxyService* proxy_service() { return proxy_service_; }
@@ -133,23 +127,14 @@ class NET_API HttpNetworkSession
// Creates a Value summary of the state of the socket pools. The caller is // Creates a Value summary of the state of the socket pools. The caller is
// responsible for deleting the returned value. // responsible for deleting the returned value.
Value* SocketPoolInfoToValue() const { Value* SocketPoolInfoToValue() const;
return socket_pool_manager_.SocketPoolInfoToValue();
}
// Creates a Value summary of the state of the SPDY sessions. The caller is // Creates a Value summary of the state of the SPDY sessions. The caller is
// responsible for deleting the returned value. // responsible for deleting the returned value.
Value* SpdySessionPoolInfoToValue() const; Value* SpdySessionPoolInfoToValue() const;
void CloseAllConnections() { void CloseAllConnections();
socket_pool_manager_.FlushSocketPools(); void CloseIdleConnections();
spdy_session_pool_.CloseCurrentSessions();
}
void CloseIdleConnections() {
socket_pool_manager_.CloseIdleSockets();
}
private: private:
friend class base::RefCounted<HttpNetworkSession>; friend class base::RefCounted<HttpNetworkSession>;

@@ -6,6 +6,8 @@
#define NET_OCSP_NSS_OCSP_H_ #define NET_OCSP_NSS_OCSP_H_
#pragma once #pragma once
#include "net/base/net_api.h"
namespace net { namespace net {
class URLRequestContext; class URLRequestContext;
@@ -13,19 +15,19 @@ class URLRequestContext;
// Sets the MessageLoop for OCSP to the current message loop. // Sets the MessageLoop for OCSP to the current message loop.
// This should be called before EnsureOCSPInit() if you want to // This should be called before EnsureOCSPInit() if you want to
// control the message loop for OCSP. // control the message loop for OCSP.
void SetMessageLoopForOCSP(); NET_API void SetMessageLoopForOCSP();
// Initializes OCSP handlers for NSS. This must be called before any // Initializes OCSP handlers for NSS. This must be called before any
// certificate verification functions. This function is thread-safe, and OCSP // certificate verification functions. This function is thread-safe, and OCSP
// handlers will only ever be initialized once. ShutdownOCSP() must be called // handlers will only ever be initialized once. ShutdownOCSP() must be called
// on shutdown. // on shutdown.
void EnsureOCSPInit(); NET_API void EnsureOCSPInit();
// This should be called once on shutdown to stop issuing URLRequests for OCSP. // This should be called once on shutdown to stop issuing URLRequests for OCSP.
void ShutdownOCSP(); NET_API void ShutdownOCSP();
// Set URLRequestContext for OCSP handlers. // Set URLRequestContext for OCSP handlers.
void SetURLRequestContextForOCSP(URLRequestContext* request_context); NET_API void SetURLRequestContextForOCSP(URLRequestContext* request_context);
} // namespace net } // namespace net

@@ -16,6 +16,7 @@
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/message_loop.h" #include "base/message_loop.h"
#include "base/observer_list.h" #include "base/observer_list.h"
#include "net/base/net_api.h"
#include "net/proxy/proxy_config.h" #include "net/proxy/proxy_config.h"
#include "net/proxy/proxy_config_service.h" #include "net/proxy/proxy_config_service.h"
#include "net/proxy/proxy_server.h" #include "net/proxy/proxy_server.h"
@@ -24,7 +25,7 @@ namespace net {
// Implementation of ProxyConfigService that retrieves the system proxy // Implementation of ProxyConfigService that retrieves the system proxy
// settings from environment variables, gconf, gsettings, or kioslaverc (KDE). // settings from environment variables, gconf, gsettings, or kioslaverc (KDE).
class BASE_API ProxyConfigServiceLinux : public ProxyConfigService { class NET_TEST ProxyConfigServiceLinux : public ProxyConfigService {
public: public:
// Forward declaration of Delegate. // Forward declaration of Delegate.

@@ -20,7 +20,8 @@ namespace net {
class BoundNetLog; class BoundNetLog;
// A client socket that uses TCP as the transport layer. // A client socket that uses TCP as the transport layer.
class TCPClientSocketLibevent : public StreamSocket, base::NonThreadSafe { class NET_TEST TCPClientSocketLibevent : public StreamSocket,
public base::NonThreadSafe {
public: public:
// The IP address(es) and port number to connect to. The TCP socket will try // The IP address(es) and port number to connect to. The TCP socket will try
// each IP address in the list until it succeeds in establishing a // each IP address in the list until it succeeds in establishing a

@@ -16,9 +16,9 @@ namespace net {
class IPEndPoint; class IPEndPoint;
class TCPServerSocketLibevent : public ServerSocket, class NET_TEST TCPServerSocketLibevent : public ServerSocket,
public base::NonThreadSafe, public base::NonThreadSafe,
public MessageLoopForIO::Watcher { public MessageLoopForIO::Watcher {
public: public:
TCPServerSocketLibevent(net::NetLog* net_log, TCPServerSocketLibevent(net::NetLog* net_log,
const net::NetLog::Source& source); const net::NetLog::Source& source);