summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2010-07-29 18:22:28 +0100
committerKristian Monsen <kristianm@google.com>2010-08-11 11:34:17 +0100
commit00d26a728db2814620f390b418a7d6325ce5aca6 (patch)
tree1a08a766ac3682d979bba42bb32150b3e6b93fdc /net
parentb3a45980d5cfbb62c937045255faa29a8ffea9f3 (diff)
downloadexternal_chromium-00d26a728db2814620f390b418a7d6325ce5aca6.zip
external_chromium-00d26a728db2814620f390b418a7d6325ce5aca6.tar.gz
external_chromium-00d26a728db2814620f390b418a7d6325ce5aca6.tar.bz2
Collection of all the changs to external chromium.
Time is running out, I guess we have to submit this and remember to upstream. Rebased to chromium r53293 Change-Id: Ie61ca0433b1eedd90144aee87c5efcd68fdc37ac
Diffstat (limited to 'net')
-rw-r--r--net/base/address_list.cc1
-rw-r--r--net/base/bandwidth_metrics.h2
-rw-r--r--net/base/file_stream_posix.cc4
-rw-r--r--net/base/gzip_filter.cc5
-rw-r--r--net/base/host_resolver.cc5
-rw-r--r--net/base/host_resolver_impl.cc17
-rw-r--r--net/base/host_resolver_proc.cc4
-rw-r--r--net/base/https_prober.h1
-rw-r--r--net/base/mime_util.cc6
-rw-r--r--net/base/net_util.cc11
-rw-r--r--net/base/sdch_filter.cc2
-rw-r--r--net/base/sdch_manager.cc8
-rw-r--r--net/base/upload_data_stream.cc2
-rw-r--r--net/base/x509_certificate.cc3
-rw-r--r--net/base/x509_certificate.h5
-rw-r--r--net/base/x509_certificate_openssl.cc64
-rw-r--r--net/disk_cache/backend_impl.cc4
-rw-r--r--net/disk_cache/file_posix.cc5
-rw-r--r--net/disk_cache/mem_backend_impl.cc5
-rw-r--r--net/flip/flip_framer.cc8
-rw-r--r--net/flip/flip_network_transaction.cc3
-rw-r--r--net/flip/flip_session.cc24
-rwxr-xr-xnet/flip/flip_stream.cc2
-rw-r--r--net/http/des.cc8
-rw-r--r--net/http/http_cache_transaction.cc2
-rw-r--r--net/http/http_network_transaction.cc4
-rw-r--r--net/proxy/proxy_config_service_linux.h2
-rw-r--r--net/proxy/proxy_service.cc2
-rw-r--r--net/socket/client_socket_factory.cc4
-rw-r--r--net/socket/socks5_client_socket.cc2
-rw-r--r--net/socket/socks_client_socket.cc2
-rw-r--r--net/socket/ssl_client_socket_openssl.cc522
-rw-r--r--net/socket/ssl_client_socket_openssl.h141
-rw-r--r--net/socket/tcp_client_socket_pool.cc2
-rw-r--r--net/url_request/url_request.h4
-rw-r--r--net/url_request/url_request_job.cc2
-rw-r--r--net/url_request/url_request_job_manager.cc2
37 files changed, 877 insertions, 13 deletions
diff --git a/net/base/address_list.cc b/net/base/address_list.cc
index 1c97311..0fbf38a 100644
--- a/net/base/address_list.cc
+++ b/net/base/address_list.cc
@@ -4,6 +4,7 @@
#include "net/base/address_list.h"
+#include <netinet/in.h>
#include <stdlib.h>
#include "base/logging.h"
diff --git a/net/base/bandwidth_metrics.h b/net/base/bandwidth_metrics.h
index c290ca9..2396157 100644
--- a/net/base/bandwidth_metrics.h
+++ b/net/base/bandwidth_metrics.h
@@ -95,7 +95,9 @@ class BandwidthMetrics {
LOG(INFO) << "Bandwidth: " << kbps
<< "Kbps (avg " << bandwidth() << "Kbps)";
int kbps_int = static_cast<int>(kbps);
+#ifndef ANDROID
UMA_HISTOGRAM_COUNTS_10000("Net.DownloadBandwidth", kbps_int);
+#endif
}
}
}
diff --git a/net/base/file_stream_posix.cc b/net/base/file_stream_posix.cc
index ba91db2..6b2656a 100644
--- a/net/base/file_stream_posix.cc
+++ b/net/base/file_stream_posix.cc
@@ -26,7 +26,9 @@
#include "net/base/net_errors.h"
// We cast back and forth, so make sure it's the size we're expecting.
-COMPILE_ASSERT(sizeof(int64) == sizeof(off_t), off_t_64_bit);
+//COMPILE_ASSERT(sizeof(int64) == sizeof(off_t), off_t_64_bit);
+COMPILE_ASSERT(sizeof(int32) == sizeof(off_t), off_t_32_bit);
+// I don't tink this will be a problem for now
// Make sure our Whence mappings match the system headers.
COMPILE_ASSERT(net::FROM_BEGIN == SEEK_SET &&
diff --git a/net/base/gzip_filter.cc b/net/base/gzip_filter.cc
index f1920da..cce597a 100644
--- a/net/base/gzip_filter.cc
+++ b/net/base/gzip_filter.cc
@@ -16,6 +16,11 @@
#define MOZ_Z_inflateInit_ inflateInit_
#define MOZ_Z_inflateReset inflateReset
#else
+#define MOZ_Z_inflate inflate
+#define MOZ_Z_inflateEnd inflateEnd
+#define MOZ_Z_inflateInit2_ inflateInit2_
+#define MOZ_Z_inflateInit_ inflateInit_
+#define MOZ_Z_inflateReset inflateReset
#include "third_party/zlib/zlib.h"
#endif
diff --git a/net/base/host_resolver.cc b/net/base/host_resolver.cc
index 320406c..82a5f7e 100644
--- a/net/base/host_resolver.cc
+++ b/net/base/host_resolver.cc
@@ -35,8 +35,13 @@ int SingleRequestHostResolver::Resolve(const HostResolver::RequestInfo& info,
// we can clear out |cur_request_*|.
CompletionCallback* transient_callback = callback ? &callback_ : NULL;
+#ifdef ANDROID
+ HostResolver* hr = CreateSystemHostResolver(NULL);
+ int rv = hr->Resolve(info, addresses, transient_callback, &request, net_log);
+#else
int rv = resolver_->Resolve(
info, addresses, transient_callback, &request, net_log);
+#endif
if (rv == ERR_IO_PENDING) {
// Cleared in OnResolveCompletion().
diff --git a/net/base/host_resolver_impl.cc b/net/base/host_resolver_impl.cc
index ffba57f..c06e065 100644
--- a/net/base/host_resolver_impl.cc
+++ b/net/base/host_resolver_impl.cc
@@ -49,22 +49,34 @@ HostCache* CreateDefaultCache() {
return cache;
}
+HostResolver* systemResolver = NULL;
} // anonymous namespace
HostResolver* CreateSystemHostResolver(size_t max_concurrent_resolves) {
// Maximum of 50 concurrent threads.
// TODO(eroman): Adjust this, do some A/B experiments.
+#ifdef ANDROID
+ static const size_t kDefaultMaxJobs = 4u;
+#else
static const size_t kDefaultMaxJobs = 50u;
+#endif
if (max_concurrent_resolves == HostResolver::kDefaultParallelism)
max_concurrent_resolves = kDefaultMaxJobs;
+#ifdef ANDROID
+ // TODO: Clean this up!
+ if (!systemResolver)
+ systemResolver = new HostResolverImpl(
+ NULL, CreateDefaultCache(), max_concurrent_resolves);
+#else
HostResolverImpl* resolver =
new HostResolverImpl(NULL, CreateDefaultCache(),
max_concurrent_resolves);
+#endif
- return resolver;
+ return systemResolver;
}
static int ResolveAddrInfo(HostResolverProc* resolver_proc,
@@ -133,7 +145,10 @@ class HostResolveFailedParams : public NetLog::EventParameters {
std::vector<int> GetAllGetAddrinfoOSErrors() {
int os_errors[] = {
#if defined(OS_POSIX)
+#ifndef ANDROID
+ // "obsoleted ..." see bionic/libc/include/netdb.h
EAI_ADDRFAMILY,
+#endif
EAI_AGAIN,
EAI_BADFLAGS,
EAI_FAIL,
diff --git a/net/base/host_resolver_proc.cc b/net/base/host_resolver_proc.cc
index 804135c..39bd808 100644
--- a/net/base/host_resolver_proc.cc
+++ b/net/base/host_resolver_proc.cc
@@ -10,6 +10,8 @@
#include <resolv.h>
#endif
+#include <netinet/in.h>
+
#include "base/logging.h"
#include "base/time.h"
#include "net/base/address_list.h"
@@ -223,7 +225,7 @@ int SystemHostResolverProc(const std::string& host,
hints.ai_socktype = SOCK_STREAM;
int err = getaddrinfo(host.c_str(), NULL, &hints, &ai);
-#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_OPENBSD)
+#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_OPENBSD) && !defined(ANDROID)
net::DnsReloadTimer* dns_timer = Singleton<net::DnsReloadTimer>::get();
// If we fail, re-initialise the resolver just in case there have been any
// changes to /etc/resolv.conf and retry. See http://crbug.com/11380 for info.
diff --git a/net/base/https_prober.h b/net/base/https_prober.h
index 327fc16..952176b 100644
--- a/net/base/https_prober.h
+++ b/net/base/https_prober.h
@@ -23,6 +23,7 @@ namespace net {
class HTTPSProberDelegate {
public:
virtual void ProbeComplete(bool result) = 0;
+ virtual ~HTTPSProberDelegate() {};
};
// HTTPSProber is a singleton object that manages HTTPS probes. A HTTPS probe
diff --git a/net/base/mime_util.cc b/net/base/mime_util.cc
index 5863b68..9163eeb 100644
--- a/net/base/mime_util.cc
+++ b/net/base/mime_util.cc
@@ -163,8 +163,10 @@ bool MimeUtil::GetMimeTypeFromExtension(const FilePath::StringType& ext,
return true;
}
+#ifndef ANDROID
if (GetPlatformMimeTypeFromExtension(ext, result))
return true;
+#endif
mime_type = FindMimeType(secondary_mappings, arraysize(secondary_mappings),
ext_narrow_str.c_str());
@@ -480,7 +482,11 @@ bool GetMimeTypeFromFile(const FilePath& file_path, std::string* mime_type) {
bool GetPreferredExtensionForMimeType(const std::string& mime_type,
FilePath::StringType* extension) {
+#ifdef ANDROID
+ return false;
+#else
return GetMimeUtil()->GetPreferredExtensionForMimeType(mime_type, extension);
+#endif
}
bool IsSupportedImageMimeType(const char* mime_type) {
diff --git a/net/base/net_util.cc b/net/base/net_util.cc
index c7b6a6f..4accc49 100644
--- a/net/base/net_util.cc
+++ b/net/base/net_util.cc
@@ -22,7 +22,9 @@
#include <wspiapi.h> // Needed for Win2k compat.
#elif defined(OS_POSIX)
#include <fcntl.h>
+#ifndef ANDROID
#include <ifaddrs.h>
+#endif
#include <netdb.h>
#include <net/if.h>
#include <netinet/in.h>
@@ -65,6 +67,10 @@
#include "unicode/datefmt.h"
+#ifdef ANDROID
+#include "netinet/in6.h"
+#endif
+
using base::Time;
namespace {
@@ -1682,7 +1688,10 @@ static void IPv6SupportResults(IPv6SupportStatus result) {
// to do a test resolution, and a test connection, to REALLY verify support.
// static
bool IPv6Supported() {
-#if defined(OS_POSIX)
+#ifdef ANDROID
+ // Android does not have the ifaddrs.h header
+ return false;
+#elif defined(OS_POSIX)
int test_socket = socket(AF_INET6, SOCK_STREAM, 0);
if (test_socket == -1) {
IPv6SupportResults(IPV6_CANNOT_CREATE_SOCKETS);
diff --git a/net/base/sdch_filter.cc b/net/base/sdch_filter.cc
index 725ee3e..0ab4381 100644
--- a/net/base/sdch_filter.cc
+++ b/net/base/sdch_filter.cc
@@ -33,6 +33,7 @@ SdchFilter::SdchFilter(const FilterContext& filter_context)
}
SdchFilter::~SdchFilter() {
+#ifndef ANDROID
// All code here is for gathering stats, and can be removed when SDCH is
// considered stable.
@@ -110,6 +111,7 @@ SdchFilter::~SdchFilter() {
return;
}
} // end of switch.
+#endif
}
bool SdchFilter::InitDecoding(Filter::FilterType filter_type) {
diff --git a/net/base/sdch_manager.cc b/net/base/sdch_manager.cc
index 6a8709b..0957382 100644
--- a/net/base/sdch_manager.cc
+++ b/net/base/sdch_manager.cc
@@ -32,7 +32,7 @@ SdchManager* SdchManager::Global() {
// static
void SdchManager::SdchErrorRecovery(ProblemCodes problem) {
- UMA_HISTOGRAM_ENUMERATION("Sdch3.ProblemCodes_4", problem, MAX_PROBLEM_CODE);
+// UMA_HISTOGRAM_ENUMERATION("Sdch3.ProblemCodes_4", problem, MAX_PROBLEM_CODE);
}
// static
@@ -269,7 +269,7 @@ bool SdchManager::AddSdchDictionary(const std::string& dictionary_text,
return false;
}
- UMA_HISTOGRAM_COUNTS("Sdch3.Dictionary size loaded", dictionary_text.size());
+// UMA_HISTOGRAM_COUNTS("Sdch3.Dictionary size loaded", dictionary_text.size());
DLOG(INFO) << "Loaded dictionary with client hash " << client_hash <<
" and server hash " << server_hash;
Dictionary* dictionary =
@@ -309,8 +309,8 @@ void SdchManager::GetAvailDictionaryList(const GURL& target_url,
list->append(it->second->client_hash());
}
// Watch to see if we have corrupt or numerous dictionaries.
- if (count > 0)
- UMA_HISTOGRAM_COUNTS("Sdch3.Advertisement_Count", count);
+// if (count > 0)
+// UMA_HISTOGRAM_COUNTS("Sdch3.Advertisement_Count", count);
}
SdchManager::Dictionary::Dictionary(const std::string& dictionary_text,
diff --git a/net/base/upload_data_stream.cc b/net/base/upload_data_stream.cc
index 140aa8a..bc38e1b 100644
--- a/net/base/upload_data_stream.cc
+++ b/net/base/upload_data_stream.cc
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+
+
#include "net/base/upload_data_stream.h"
#include "base/file_util.h"
diff --git a/net/base/x509_certificate.cc b/net/base/x509_certificate.cc
index f5b28a6..7f607ea 100644
--- a/net/base/x509_certificate.cc
+++ b/net/base/x509_certificate.cc
@@ -53,6 +53,9 @@ bool X509Certificate::IsSameOSCert(X509Certificate::OSCertHandle a,
#elif defined(USE_NSS)
return a->derCert.len == b->derCert.len &&
memcmp(a->derCert.data, b->derCert.data, a->derCert.len) == 0;
+#elif defined(USE_OPENSSL)
+ // ANDROID needs this but doesn't have UNREACHED()
+ return false;
#else
// TODO(snej): not implemented
UNREACHED();
diff --git a/net/base/x509_certificate.h b/net/base/x509_certificate.h
index d6b3447..4d65919 100644
--- a/net/base/x509_certificate.h
+++ b/net/base/x509_certificate.h
@@ -24,6 +24,9 @@
#elif defined(USE_NSS)
// Forward declaration; real one in <cert.h>
struct CERTCertificateStr;
+#elif defined(USE_OPENSSL)
+// real dec in x509.h
+struct x509_st;
#endif
class Pickle;
@@ -44,6 +47,8 @@ class X509Certificate : public base::RefCountedThreadSafe<X509Certificate> {
typedef SecCertificateRef OSCertHandle;
#elif defined(USE_NSS)
typedef struct CERTCertificateStr* OSCertHandle;
+#elif defined(USE_OPENSSL)
+ typedef struct x509_st* OSCertHandle;
#else
// TODO(ericroman): not implemented
typedef void* OSCertHandle;
diff --git a/net/base/x509_certificate_openssl.cc b/net/base/x509_certificate_openssl.cc
new file mode 100644
index 0000000..2e2baf0
--- /dev/null
+++ b/net/base/x509_certificate_openssl.cc
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2010, The Android Open Source Project
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "net/base/x509_certificate.h"
+
+#include "openssl/x509.h"
+
+namespace net {
+
+X509Certificate::OSCertHandle X509Certificate::DupOSCertHandle(
+ OSCertHandle cert_handle) {
+ return NULL;
+}
+
+void X509Certificate::FreeOSCertHandle(OSCertHandle cert) {
+}
+
+void X509Certificate::Initialize() {
+}
+
+SHA1Fingerprint X509Certificate::CalculateFingerprint(
+ OSCertHandle cert) {
+ SHA1Fingerprint sha1;
+ memcpy(sha1.data, cert->sha1_hash, 20);
+ return sha1;
+}
+
+X509Certificate::OSCertHandle X509Certificate::CreateOSCertHandleFromBytes(
+ char const*, int) {
+ return NULL;
+}
+
+X509Certificate* X509Certificate::CreateFromPickle(const Pickle& pickle,
+ void** pickle_iter) {
+ return NULL;
+}
+
+void X509Certificate::Persist(Pickle* pickle) {
+}
+
+
+} // namespace net
diff --git a/net/disk_cache/backend_impl.cc b/net/disk_cache/backend_impl.cc
index 13b17f4..84f023d 100644
--- a/net/disk_cache/backend_impl.cc
+++ b/net/disk_cache/backend_impl.cc
@@ -1257,7 +1257,11 @@ void BackendImpl::AdjustMaxCacheSize(int table_len) {
DCHECK(!table_len || data_->header.magic);
// The user is not setting the size, let's figure it out.
+#ifdef ANDROID
+ int64 available = 10 * 1024 * 1024; // 10 MB
+#else
int64 available = base::SysInfo::AmountOfFreeDiskSpace(path_);
+#endif
if (available < 0) {
max_size_ = kDefaultCacheSize;
return;
diff --git a/net/disk_cache/file_posix.cc b/net/disk_cache/file_posix.cc
index 295f744..38834a6 100644
--- a/net/disk_cache/file_posix.cc
+++ b/net/disk_cache/file_posix.cc
@@ -307,7 +307,12 @@ bool File::Write(const void* buffer, size_t buffer_len, size_t offset) {
if (buffer_len > ULONG_MAX || offset > ULONG_MAX)
return false;
+#ifdef ANDROID
+ int ret = pwrite(platform_file_, const_cast<void*>(buffer), buffer_len, offset);
+#else
int ret = pwrite(platform_file_, buffer, buffer_len, offset);
+#endif
+
return (static_cast<size_t>(ret) == buffer_len);
}
diff --git a/net/disk_cache/mem_backend_impl.cc b/net/disk_cache/mem_backend_impl.cc
index fe57d7d..b5064b2 100644
--- a/net/disk_cache/mem_backend_impl.cc
+++ b/net/disk_cache/mem_backend_impl.cc
@@ -41,6 +41,7 @@ Backend* MemBackendImpl::CreateBackend(int max_bytes) {
}
bool MemBackendImpl::Init() {
+#ifndef ANDROID
if (max_size_)
return true;
@@ -58,7 +59,9 @@ bool MemBackendImpl::Init() {
max_size_ = kDefaultCacheSize * 5;
else
max_size_ = static_cast<int32>(total_memory);
-
+#else
+ max_size_ = kDefaultCacheSize*3;
+#endif
return true;
}
diff --git a/net/flip/flip_framer.cc b/net/flip/flip_framer.cc
index f200ac6..b165a33 100644
--- a/net/flip/flip_framer.cc
+++ b/net/flip/flip_framer.cc
@@ -636,8 +636,10 @@ FlipFrame* FlipFramer::CompressFrame(const FlipFrame* frame) {
int header_length;
const char* payload;
+#ifndef ANDROID
static StatsCounter pre_compress_bytes("flip.PreCompressSize");
static StatsCounter post_compress_bytes("flip.PostCompressSize");
+#endif
if (!enable_compression_)
return DuplicateFrame(frame);
@@ -678,8 +680,10 @@ FlipFrame* FlipFramer::CompressFrame(const FlipFrame* frame) {
int compressed_size = compressed_max_size - compressor_->avail_out;
new_frame->set_length(header_length + compressed_size - FlipFrame::size());
+#ifndef ANDROID
pre_compress_bytes.Add(payload_length);
post_compress_bytes.Add(new_frame->length());
+#endif
return new_frame;
}
@@ -689,8 +693,10 @@ FlipFrame* FlipFramer::DecompressFrame(const FlipFrame* frame) {
int header_length;
const char* payload;
+#ifndef ANDROID
static StatsCounter pre_decompress_bytes("flip.PreDeCompressSize");
static StatsCounter post_decompress_bytes("flip.PostDeCompressSize");
+#endif
if (!enable_compression_)
return DuplicateFrame(frame);
@@ -747,8 +753,10 @@ FlipFrame* FlipFramer::DecompressFrame(const FlipFrame* frame) {
int decompressed_size = decompressed_max_size - decompressor_->avail_out;
new_frame->set_length(header_length + decompressed_size - FlipFrame::size());
+#ifndef ANDROID
pre_decompress_bytes.Add(frame->length());
post_decompress_bytes.Add(new_frame->length());
+#endif
return new_frame;
}
diff --git a/net/flip/flip_network_transaction.cc b/net/flip/flip_network_transaction.cc
index 440e666..e234b33 100644
--- a/net/flip/flip_network_transaction.cc
+++ b/net/flip/flip_network_transaction.cc
@@ -48,7 +48,10 @@ int FlipNetworkTransaction::Start(const HttpRequestInfo* request_info,
CHECK(request_info);
CHECK(callback);
+// missing flockf
+#ifndef ANDROID
SIMPLE_STATS_COUNTER("FlipNetworkTransaction.Count");
+#endif
load_log_ = load_log;
request_ = request_info;
diff --git a/net/flip/flip_session.cc b/net/flip/flip_session.cc
index d91c37c..7cf7b2a 100644
--- a/net/flip/flip_session.cc
+++ b/net/flip/flip_session.cc
@@ -237,6 +237,7 @@ FlipSession::~FlipSession() {
DCHECK(!session_->flip_session_pool()->HasSession(
HostResolver::RequestInfo(domain_, 80)));
+#ifndef ANDROID
// Record per-session histograms here.
UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdyStreamsPerSession",
streams_initiated_count_,
@@ -250,11 +251,14 @@ FlipSession::~FlipSession() {
UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdyStreamsAbandonedPerSession",
streams_abandoned_count_,
0, 300, 50);
+#endif
}
void FlipSession::InitializeWithSocket(ClientSocketHandle* connection) {
+#ifndef ANDROID
static StatsCounter flip_sessions("flip.sessions");
flip_sessions.Increment();
+#endif
AdjustSocketBufferSizes(connection->socket());
@@ -279,8 +283,10 @@ net::Error FlipSession::Connect(const std::string& group_name,
state_ = CONNECTING;
+#ifndef ANDROID
static StatsCounter flip_sessions("flip.sessions");
flip_sessions.Increment();
+#endif
int rv = connection_->Init(group_name, host, priority, &connect_callback_,
session_->tcp_socket_pool(), load_log);
@@ -334,8 +340,10 @@ scoped_refptr<FlipStream> FlipSession::GetOrCreateStream(
stream->set_path(path);
ActivateStream(stream);
+#ifndef ANDROID
UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdyPriorityCount",
static_cast<int>(request.priority), 0, 10, 11);
+#endif
LOG(INFO) << "FlipStream: Creating stream " << stream_id << " for " << url;
@@ -360,8 +368,10 @@ scoped_refptr<FlipStream> FlipSession::GetOrCreateStream(
memcpy(buffer->data(), syn_frame->data(), length);
queue_.push(FlipIOBuffer(buffer, length, request.priority, stream));
+#ifndef ANDROID
static StatsCounter flip_requests("flip.requests");
flip_requests.Increment();
+#endif
LOG(INFO) << "FETCHING: " << request.url.spec();
streams_initiated_count_++;
@@ -465,7 +475,9 @@ void FlipSession::OnTCPConnect(int result) {
// socket (or have an error trying to do so).
DCHECK(!connection_->socket() || !connection_->is_reused());
+#ifndef ANDROID
UpdateConnectionTypeHistograms(CONNECTION_SPDY, result >= 0);
+#endif
if (result != net::OK) {
DCHECK_LT(result, 0);
@@ -720,11 +732,15 @@ void FlipSession::WriteSocket() {
void FlipSession::CloseAllStreams(net::Error code) {
LOG(INFO) << "Closing all FLIP Streams";
+#ifndef ANDROID
static StatsCounter abandoned_streams("flip.abandoned_streams");
static StatsCounter abandoned_push_streams("flip.abandoned_push_streams");
+#endif
if (active_streams_.size()) {
+#ifndef ANDROID
abandoned_streams.Add(active_streams_.size());
+#endif
// Create a copy of the list, since aborting streams can invalidate
// our list.
@@ -749,7 +765,9 @@ void FlipSession::CloseAllStreams(net::Error code) {
if (pushed_streams_.size()) {
streams_abandoned_count_ += pushed_streams_.size();
+#ifndef ANDROID
abandoned_push_streams.Add(pushed_streams_.size());
+#endif
pushed_streams_.clear();
}
}
@@ -801,7 +819,9 @@ void FlipSession::DeactivateStream(flip::FlipStreamId id) {
}
scoped_refptr<FlipStream> FlipSession::GetPushStream(const std::string& path) {
+#ifndef ANDROID
static StatsCounter used_push_streams("flip.claimed_push_streams");
+#endif
LOG(INFO) << "Looking for push stream: " << path;
@@ -814,7 +834,9 @@ scoped_refptr<FlipStream> FlipSession::GetPushStream(const std::string& path) {
if (path == stream->path()) {
CHECK(stream->pushed());
pushed_streams_.erase(it);
+#ifndef ANDROID
used_push_streams.Increment();
+#endif
LOG(INFO) << "Push Stream Claim for: " << path;
break;
}
@@ -931,8 +953,10 @@ void FlipSession::OnSyn(const flip::FlipSynStreamControlFrame* frame,
LOG(INFO) << "Got pushed stream for " << stream->path();
+#ifndef ANDROID
static StatsCounter push_requests("flip.pushed_streams");
push_requests.Increment();
+#endif
}
void FlipSession::OnSynReply(const flip::FlipSynReplyControlFrame* frame,
diff --git a/net/flip/flip_stream.cc b/net/flip/flip_stream.cc
index b3d0978..5b18c54 100755
--- a/net/flip/flip_stream.cc
+++ b/net/flip/flip_stream.cc
@@ -421,6 +421,7 @@ void FlipStream::UpdateHistograms() {
recv_last_byte_time_.is_null())
return;
+#ifndef ANDROID
UMA_HISTOGRAM_TIMES("Net.SpdyStreamTimeToFirstByte",
recv_first_byte_time_ - send_time_);
UMA_HISTOGRAM_TIMES("Net.SpdyStreamDownloadTime",
@@ -430,6 +431,7 @@ void FlipStream::UpdateHistograms() {
UMA_HISTOGRAM_COUNTS("Net.SpdySendBytes", send_bytes_);
UMA_HISTOGRAM_COUNTS("Net.SpdyRecvBytes", recv_bytes_);
+#endif
}
} // namespace net
diff --git a/net/http/des.cc b/net/http/des.cc
index 0ca12b9..a611f51 100644
--- a/net/http/des.cc
+++ b/net/http/des.cc
@@ -215,6 +215,14 @@ void DESEncrypt(const uint8* key, const uint8* src, uint8* hash) {
CryptReleaseContext(provider, 0);
}
+#elif defined(USE_OPENSSL)
+
+// To be implemented with openssl
+void DESEncrypt(const uint8* key, const uint8* src, uint8* hash) {
+ int* a = NULL;
+ int c = *a;
+}
+
#endif
} // namespace net
diff --git a/net/http/http_cache_transaction.cc b/net/http/http_cache_transaction.cc
index 2ea08b8..9bbf4d1 100644
--- a/net/http/http_cache_transaction.cc
+++ b/net/http/http_cache_transaction.cc
@@ -1868,7 +1868,7 @@ void HttpCache::Transaction::HistogramHeaders(
// |value| goes from 0 to 63. Actually, the max value should be 47 (0x2f)
// but we'll see.
- UMA_HISTOGRAM_ENUMERATION("HttpCache.ResponseHeaders", value, 65);
+// UMA_HISTOGRAM_ENUMERATION("HttpCache.ResponseHeaders", value, 65);
}
void HttpCache::Transaction::OnIOComplete(int result) {
diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc
index a85a1ca..6783a0a 100644
--- a/net/http/http_network_transaction.cc
+++ b/net/http/http_network_transaction.cc
@@ -1621,6 +1621,10 @@ void HttpNetworkTransaction::ResetConnectionAndRequestForResend() {
}
int HttpNetworkTransaction::ReconsiderProxyAfterError(int error) {
+#ifdef ANDROID
+ // Android crashes :(
+ return error;
+#endif
DCHECK(!pac_request_);
// A failure to resolve the hostname or any error related to establishing a
diff --git a/net/proxy/proxy_config_service_linux.h b/net/proxy/proxy_config_service_linux.h
index c6e9c90..44ea4de 100644
--- a/net/proxy/proxy_config_service_linux.h
+++ b/net/proxy/proxy_config_service_linux.h
@@ -222,8 +222,10 @@ class ProxyConfigServiceLinux : public ProxyConfigService {
void SetupAndFetchInitialConfig(MessageLoop* glib_default_loop,
MessageLoop* io_loop,
MessageLoopForIO* file_loop) {
+#ifndef ANDROID
delegate_->SetupAndFetchInitialConfig(glib_default_loop, io_loop,
file_loop);
+#endif
}
void OnCheckProxyConfigSettings() {
delegate_->OnCheckProxyConfigSettings();
diff --git a/net/proxy/proxy_service.cc b/net/proxy/proxy_service.cc
index 8f9d28c..33af9c6 100644
--- a/net/proxy/proxy_service.cc
+++ b/net/proxy/proxy_service.cc
@@ -587,7 +587,7 @@ ProxyConfigService* ProxyService::CreateSystemProxyConfigService(
return new ProxyConfigServiceWin();
#elif defined(OS_MACOSX)
return new ProxyConfigServiceMac();
-#elif defined(OS_LINUX)
+#elif defined(OS_LINUX) && !defined(ANDROID)
ProxyConfigServiceLinux* linux_config_service
= new ProxyConfigServiceLinux();
diff --git a/net/socket/client_socket_factory.cc b/net/socket/client_socket_factory.cc
index fbccfcb..622bccd 100644
--- a/net/socket/client_socket_factory.cc
+++ b/net/socket/client_socket_factory.cc
@@ -11,6 +11,8 @@
#include "net/socket/ssl_client_socket_win.h"
#elif defined(USE_NSS)
#include "net/socket/ssl_client_socket_nss.h"
+#elif defined(USE_OPENSSL)
+#include "net/socket/ssl_client_socket_openssl.h"
#elif defined(OS_MACOSX)
#include "net/socket/ssl_client_socket_mac.h"
#include "net/socket/ssl_client_socket_nss.h"
@@ -29,6 +31,8 @@ SSLClientSocket* DefaultSSLClientSocketFactory(
return new SSLClientSocketWin(transport_socket, hostname, ssl_config);
#elif defined(USE_NSS)
return new SSLClientSocketNSS(transport_socket, hostname, ssl_config);
+#elif defined(USE_OPENSSL)
+ return new SSLClientSocketOpenSSL(transport_socket, hostname, ssl_config);
#elif defined(OS_MACOSX)
// TODO(wtc): SSLClientSocketNSS can't do SSL client authentication using
// Mac OS X CDSA/CSSM yet (http://crbug.com/45369), so fall back on
diff --git a/net/socket/socks5_client_socket.cc b/net/socket/socks5_client_socket.cc
index 997fb25..392483d 100644
--- a/net/socket/socks5_client_socket.cc
+++ b/net/socket/socks5_client_socket.cc
@@ -4,6 +4,8 @@
#include "net/socket/socks5_client_socket.h"
+#include <netinet/in.h>
+
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/format_macros.h"
diff --git a/net/socket/socks_client_socket.cc b/net/socket/socks_client_socket.cc
index 32c4e3b..0af80b4 100644
--- a/net/socket/socks_client_socket.cc
+++ b/net/socket/socks_client_socket.cc
@@ -4,6 +4,8 @@
#include "net/socket/socks_client_socket.h"
+#include <netinet/in.h>
+
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/trace_event.h"
diff --git a/net/socket/ssl_client_socket_openssl.cc b/net/socket/ssl_client_socket_openssl.cc
new file mode 100644
index 0000000..1ec5753
--- /dev/null
+++ b/net/socket/ssl_client_socket_openssl.cc
@@ -0,0 +1,522 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "net/socket/ssl_client_socket_openssl.h"
+
+#include "net/base/net_errors.h"
+#include "openssl/err.h"
+
+namespace net {
+
+#if 1
+#define GotoState(s) next_handshake_state_ = s
+#else
+#define GotoState(s) do { LOG(INFO) << (void *)this << " " << __FUNCTION__ << \
+ " jump to state " << s; \
+ next_handshake_state_ = s; } while (0)
+#endif
+
+
+bool SSLClientSocketOpenSSL::InitOpenSSL() {
+ if(ctx) {
+ return true;
+ }
+
+ SSL_load_error_strings();
+ if (!SSL_library_init())
+ return false;
+
+ const SSL_METHOD *pMethod = SSLv23_client_method();
+ ctx = SSL_CTX_new(pMethod);
+
+ if (!ctx) {
+ return false;
+ }
+
+ SSL_CTX_set_verify(ctx, /*SSL_VERIFY_PEER*/ SSL_VERIFY_NONE, NULL/*callback*/); //void
+
+ return true;
+}
+
+// Add some error checking ...
+bool SSLClientSocketOpenSSL::Init() {
+ if (!ctx) {
+ return false;
+ }
+
+ ssl = SSL_new(ctx);
+
+ bio_read = BIO_new(BIO_s_mem());
+ bio_write = BIO_new(BIO_s_mem());
+
+ write_buf_size = 1024; // Why does this not work? BIO_get_write_buf_size(bio_write, 1000);
+
+ if (!SSL_set_tlsext_host_name(ssl, hostname_.c_str()))
+ return false;
+
+ SSL_set_bio(ssl, bio_read, bio_write); // void
+
+ // Connect as client
+ SSL_set_connect_state(ssl); // void
+
+ return true;
+}
+
+SSL_CTX* SSLClientSocketOpenSSL::ctx = NULL;
+
+SSLClientSocketOpenSSL::SSLClientSocketOpenSSL(ClientSocketHandle* transport_socket,
+ const std::string& hostname,
+ const SSLConfig& ssl_config)
+ : transport_send_busy_(false),
+ transport_recv_busy_(false),
+ user_connect_callback_(NULL),
+ user_read_callback_(NULL),
+ user_write_callback_(NULL),
+ client_auth_cert_needed_(false),
+ transport_(transport_socket),
+ hostname_(hostname),
+ ssl_config_(ssl_config),
+ completed_handshake_(false),
+ net_log_(transport_socket->socket()->NetLog()) {
+ buffer_send_callback_ = new CompletionCallbackImpl<SSLClientSocketOpenSSL>(
+ this, &SSLClientSocketOpenSSL::BufferSendComplete);
+ buffer_recv_callback_ = new CompletionCallbackImpl<SSLClientSocketOpenSSL>(
+ this, &SSLClientSocketOpenSSL::BufferRecvComplete);
+}
+
+SSLClientSocketOpenSSL::~SSLClientSocketOpenSSL() {
+ delete buffer_send_callback_;
+ delete buffer_recv_callback_;
+
+ Disconnect();
+}
+
+
+// SSLClientSocket methods
+
+void SSLClientSocketOpenSSL::GetSSLInfo(SSLInfo* ssl_info) {
+}
+
+void SSLClientSocketOpenSSL::GetSSLCertRequestInfo(
+ SSLCertRequestInfo* cert_request_info) {
+}
+
+SSLClientSocket::NextProtoStatus
+SSLClientSocketOpenSSL::GetNextProto(std::string* proto) {
+ return kNextProtoUnsupported;
+}
+
+void SSLClientSocketOpenSSL::DoReadCallback(int rv) {
+ // Since Run may result in Read being called, clear |user_read_callback_|
+ // up front.
+ CompletionCallback* c = user_read_callback_;
+ user_read_callback_ = NULL;
+ user_read_buf_ = NULL;
+ user_read_buf_len_ = 0;
+ c->Run(rv);
+}
+
+void SSLClientSocketOpenSSL::DoWriteCallback(int rv) {
+ // Since Run may result in Write being called, clear |user_write_callback_|
+ // up front.
+ CompletionCallback* c = user_write_callback_;
+ user_write_callback_ = NULL;
+ user_write_buf_ = NULL;
+ user_write_buf_len_ = 0;
+ c->Run(rv);
+}
+
+// ClientSocket methods
+
+// Should make a proper return error
+// and call the callback with more info
+int SSLClientSocketOpenSSL::Connect(CompletionCallback* callback) {
+ if(!InitOpenSSL()) {
+ return -1; // Anything but OK signals error
+ }
+
+ // Set up new ssl object
+ if(!Init()) {
+ return -1;
+ }
+
+ // Handshake happens here
+ int err = SSL_connect(ssl);
+
+ GotoState(STATE_HANDSHAKE);
+ int rv = DoHandshakeLoop(net::OK);
+ if (rv == ERR_IO_PENDING) {
+ user_connect_callback_ = callback;
+ }
+
+ // (Optional) Tell loadlog we are starting and store a ref
+ return rv > OK ? OK : rv;
+}
+
+void SSLClientSocketOpenSSL::Disconnect() {
+ // Null all callbacks
+ // Delete all buffers
+ // Handshake not completed anymore
+ //verifier_.reset();
+ completed_handshake_ = false;
+ transport_->socket()->Disconnect();
+}
+
+int SSLClientSocketOpenSSL::DoHandshakeLoop(int last_io_result) {
+ bool network_moved;
+ int rv = last_io_result;
+ do {
+ // Default to STATE_NONE for next state.
+ // (This is a quirk carried over from the windows
+ // implementation. It makes reading the logs a bit harder.)
+ // State handlers can and often do call GotoState just
+ // to stay in the current state.
+ State state = next_handshake_state_;
+ GotoState(STATE_NONE);
+ switch (state) {
+ case STATE_NONE:
+ // we're just pumping data between the buffer and the network
+ break;
+ case STATE_HANDSHAKE:
+ rv = DoHandshake();
+ break;
+ case STATE_VERIFY_CERT:
+// DCHECK(rv == OK);
+// rv = DoVerifyCert(rv);
+// break;
+ case STATE_VERIFY_CERT_COMPLETE:
+// rv = DoVerifyCertComplete(rv);
+// break;
+ default:
+// rv = ERR_UNEXPECTED;
+// NOTREACHED() << "unexpected state";
+ break;
+ }
+
+ // To avoid getting an ERR_IO_PENDING here after handshake complete.
+ if (next_handshake_state_ == STATE_NONE)
+ break;
+
+ // Do the actual network I/O
+ network_moved = DoTransportIO();
+ } while ((rv != ERR_IO_PENDING || network_moved) &&
+ next_handshake_state_ != STATE_NONE);
+ return rv;
+}
+
+int SSLClientSocketOpenSSL::DoHandshake() {
+ int rv = SSL_do_handshake(ssl);
+
+ if (rv == 1) {
+ // SSL handshake is completed. Let's verify the certificate.
+ // For now we are done, certificates not implemented yet
+ // TODO: Implement certificates
+ rv = OK;
+ GotoState(STATE_NONE);
+ completed_handshake_ = true;
+ } else {
+ int ssl_error = SSL_get_error(ssl, rv);
+
+ // If not done, stay in this state
+ if (ssl_error == SSL_ERROR_WANT_READ) {
+ rv = ERR_IO_PENDING;
+ GotoState(STATE_HANDSHAKE);
+ } else if (ssl_error == SSL_ERROR_WANT_WRITE) {
+ rv = ERR_IO_PENDING;
+ GotoState(STATE_HANDSHAKE);
+ } else {
+ GotoState(STATE_HANDSHAKE);
+ }
+ }
+
+ return rv;
+}
+
+bool SSLClientSocketOpenSSL::DoTransportIO() {
+ bool network_moved = false;
+ int nsent = BufferSend();
+ int nreceived = BufferRecv();
+ network_moved = (nsent > 0 || nreceived >= 0);
+
+ return network_moved;
+}
+
+int SSLClientSocketOpenSSL::BufferSend(void) {
+ size_t data_pending = BIO_ctrl_pending(bio_write);
+ if (data_pending == 0) {
+ return NULL;
+ }
+
+ scoped_refptr<IOBuffer> send_buffer = new IOBuffer(data_pending);
+ int bytes_read = BIO_read(bio_write, send_buffer->data(), data_pending);
+
+ if (bytes_read > 0) {
+ int rv;
+ do {
+ rv = transport_->socket()->Write(send_buffer, data_pending, buffer_send_callback_);
+ if (rv == ERR_IO_PENDING) {
+ transport_send_busy_ = true;
+ break; // will get callback
+ } else if (rv < 0) {
+ // just resend and pray
+ //android_printLog(ANDROID_LOG_ERROR, "https", "transport->write returned %d", rv);
+ } else if (rv != bytes_read) { // TODO: what to do about the rest of data read from openssl?
+ //android_printLog(ANDROID_LOG_ERROR, "https", "Only sent %d out of %d bytes", rv, bytes_read);
+ }
+ } while (rv < ERR_IO_PENDING); // -1
+ return rv;
+ } else {
+ int err = SSL_get_error(ssl, bytes_read);
+ //android_printLog(ANDROID_LOG_DEBUG, "https", "SSL error in BufferSend: %d / %d (%d)", err, bytes_read, data_pending);
+ return 0;
+ }
+}
+
+void SSLClientSocketOpenSSL::BufferSendComplete(int result) {
+ transport_send_busy_ = false;
+ OnSendComplete(result);
+}
+
+int SSLClientSocketOpenSSL::BufferRecv(void) {
+ if (transport_recv_busy_)
+ return ERR_IO_PENDING;
+
+ int max_write = write_buf_size;
+// Why does this not work?
+// int max_write = BIO_ctrl_get_write_guarantee(bio_read);
+// int mw = BIO_ctrl_get_write_guarantee(bio_write);
+// android_printLog(ANDROID_LOG_DEBUG, "https", "BufferRecv can write at most %d", max_write);
+
+ int rv;
+ if (!max_write) {
+ rv = ERR_IO_PENDING;
+ } else {
+ recv_buffer_ = new IOBuffer(max_write);
+ rv = transport_->socket()->Read(recv_buffer_, max_write, buffer_recv_callback_);
+ if (rv == ERR_IO_PENDING) {
+ transport_recv_busy_ = true;
+ } else {
+ if (rv > 0) {
+ int ret = BIO_write(bio_read, recv_buffer_->data(), rv);
+ if (ret != rv) {
+ //android_printLog(ANDROID_LOG_ERROR, "https", "wrote less than capacity, should not happen (%d > %d : %d)", rv, ret, max_write);
+ }
+ }
+ recv_buffer_ = NULL;
+ }
+ }
+ return rv;
+}
+
+void SSLClientSocketOpenSSL::BufferRecvComplete(int result) {
+ if (result > 0) {
+ int ret = BIO_write(bio_read, recv_buffer_->data(), result);
+ if (ret != result) {
+ //android_printLog(ANDROID_LOG_ERROR, "https", "BIO_write returned: %d (not %d)", ret, result);
+ }
+ }
+ recv_buffer_ = NULL;
+ transport_recv_busy_ = false;
+ OnRecvComplete(result);
+}
+
+void SSLClientSocketOpenSSL::DoConnectCallback(int rv) {
+ CompletionCallback* c = user_connect_callback_;
+ user_connect_callback_ = NULL;
+ c->Run(rv > OK ? OK : rv);
+}
+
+void SSLClientSocketOpenSSL::OnHandshakeIOComplete(int result) {
+ int rv = DoHandshakeLoop(result);
+ if (rv != ERR_IO_PENDING) {
+ DoConnectCallback(rv);
+ }
+}
+
+void SSLClientSocketOpenSSL::OnSendComplete(int result) {
+ if (next_handshake_state_ != STATE_NONE) {
+ // In handshake phase.
+ OnHandshakeIOComplete(result);
+ return;
+ }
+
+ // OnSendComplete may need to call DoPayloadRead while the renegotiation
+ // handshake is in progress.
+ int rv_read = ERR_IO_PENDING;
+ int rv_write = ERR_IO_PENDING;
+ bool network_moved;
+ do {
+ if (user_read_buf_)
+ rv_read = DoPayloadRead();
+ if (user_write_buf_)
+ rv_write = DoPayloadWrite();
+ network_moved = DoTransportIO();
+ } while (rv_read == ERR_IO_PENDING &&
+ rv_write == ERR_IO_PENDING &&
+ network_moved);
+
+ if (user_read_buf_ && rv_read != ERR_IO_PENDING)
+ DoReadCallback(rv_read);
+ if (user_write_buf_ && rv_write != ERR_IO_PENDING)
+ DoWriteCallback(rv_write);
+}
+
+void SSLClientSocketOpenSSL::OnRecvComplete(int result) {
+ if (next_handshake_state_ != STATE_NONE) {
+ // In handshake phase.
+ OnHandshakeIOComplete(result);
+ return;
+ }
+
+ // Network layer received some data, check if client requested to read
+ // decrypted data.
+ if (!user_read_buf_) {
+ //android_printLog(ANDROID_LOG_ERROR, "https", "recv with no user_read_buf_");
+ return;
+ }
+
+ int rv = DoReadLoop(result);
+ if (rv != ERR_IO_PENDING)
+ DoReadCallback(rv);
+}
+
+bool SSLClientSocketOpenSSL::IsConnected() const {
+ bool ret = completed_handshake_ && transport_->socket()->IsConnected();
+ return ret;
+}
+
+bool SSLClientSocketOpenSSL::IsConnectedAndIdle() const {
+ bool ret = completed_handshake_ && transport_->socket()->IsConnectedAndIdle();
+ return ret;
+}
+
+int SSLClientSocketOpenSSL::GetPeerAddress(AddressList* addressList) const {
+ return transport_->socket()->GetPeerAddress(addressList);
+}
+
+const BoundNetLog& SSLClientSocketOpenSSL::NetLog() const {
+ return net_log_;
+}
+
+// Socket methods
+
+int SSLClientSocketOpenSSL::Read(IOBuffer* buf, int buf_len, CompletionCallback* callback) {
+ user_read_buf_ = buf;
+ user_read_buf_len_ = buf_len;
+
+ int rv = DoReadLoop(OK);
+
+ if (rv == ERR_IO_PENDING)
+ user_read_callback_ = callback;
+ else {
+ user_read_buf_ = NULL;
+ user_read_buf_len_ = 0;
+ }
+
+ return rv;
+}
+
+int SSLClientSocketOpenSSL::DoReadLoop(int result) {
+ if (result < 0)
+ return result;
+
+ bool network_moved;
+ int rv;
+ do {
+ rv = DoPayloadRead();
+ network_moved = DoTransportIO();
+ } while (rv == ERR_IO_PENDING && network_moved);
+
+ return rv;
+}
+
+int SSLClientSocketOpenSSL::Write(IOBuffer* buf, int buf_len, CompletionCallback* callback) {
+ user_write_buf_ = buf;
+ user_write_buf_len_ = buf_len;
+
+ int rv = DoWriteLoop(OK);
+
+ if (rv == ERR_IO_PENDING)
+ user_write_callback_ = callback;
+ else {
+ user_write_buf_ = NULL;
+ user_write_buf_len_ = 0;
+ }
+
+ return rv;
+}
+
+int SSLClientSocketOpenSSL::DoWriteLoop(int result) {
+ if (result < 0)
+ return result;
+
+ bool network_moved;
+ int rv;
+ do {
+ rv = DoPayloadWrite();
+ network_moved = DoTransportIO();
+ } while (rv == ERR_IO_PENDING && network_moved);
+
+ return rv;
+}
+
+bool SSLClientSocketOpenSSL::SetReceiveBufferSize(int32 size) {
+ return true;
+}
+
+bool SSLClientSocketOpenSSL::SetSendBufferSize(int32 size) {
+ return true;
+}
+
+
+int SSLClientSocketOpenSSL::DoPayloadRead() {
+ int rv = SSL_read(ssl, user_read_buf_->data(), user_read_buf_len_);
+ if (client_auth_cert_needed_) {
+ // We don't need to invalidate the non-client-authenticated SSL session
+ // because the server will renegotiate anyway.
+ return ERR_SSL_CLIENT_AUTH_CERT_NEEDED;
+ }
+
+ if (rv >= 0) {
+ return rv;
+ }
+
+ int err = SSL_get_error(ssl, rv);
+ if (err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE) {
+ // This will trigger another read/write after DoTransportIO
+ return ERR_IO_PENDING;
+ }
+
+ return rv; // return err instead?
+}
+
+int SSLClientSocketOpenSSL::DoPayloadWrite() {
+ int rv = SSL_write(ssl, user_write_buf_->data(), user_write_buf_len_);
+
+ if (rv >= 0) {
+ return rv;
+ }
+
+ int err = SSL_get_error(ssl, rv);
+ if (err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE) {
+ // This will trigger another read/write after DoTransportIO
+ return ERR_IO_PENDING;
+ }
+
+ return rv; // return err instead ?
+}
+
+} // namespace net
diff --git a/net/socket/ssl_client_socket_openssl.h b/net/socket/ssl_client_socket_openssl.h
new file mode 100644
index 0000000..3fc1ac3
--- /dev/null
+++ b/net/socket/ssl_client_socket_openssl.h
@@ -0,0 +1,141 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef NET_SOCKET_SSL_CLIENT_SOCKET_OPENSSL_H_
+#define NET_SOCKET_SSL_CLIENT_SOCKET_OPENSSL_H_
+
+#include "base/scoped_ptr.h"
+#include "net/base/io_buffer.h"
+#include "net/base/ssl_config_service.h"
+#include "net/socket/ssl_client_socket.h"
+#include "net/socket/client_socket_handle.h"
+
+#include "openssl/ssl.h"
+
+namespace net {
+
+class SSLCertRequestInfo;
+class SSLConfig;
+class SSLInfo;
+
+// An SSL client socket implemented with OpenSSL.
+class SSLClientSocketOpenSSL : public SSLClientSocket {
+ public:
+ // Takes ownership of the transport_socket, which may already be connected.
+ // The given hostname will be compared with the name(s) in the server's
+ // certificate during the SSL handshake. ssl_config specifies the SSL
+ // settings.
+ SSLClientSocketOpenSSL(ClientSocketHandle* transport_socket,
+ const std::string& hostname,
+ const SSLConfig& ssl_config);
+ ~SSLClientSocketOpenSSL();
+
+ // SSLClientSocket methods:
+ virtual void GetSSLInfo(SSLInfo* ssl_info);
+ virtual void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info);
+ virtual NextProtoStatus GetNextProto(std::string* proto);
+
+ // ClientSocket methods:
+ virtual int Connect(CompletionCallback* callback);
+ virtual void Disconnect();
+ virtual bool IsConnected() const;
+ virtual bool IsConnectedAndIdle() const;
+ virtual int GetPeerAddress(AddressList*) const;
+ virtual const BoundNetLog& NetLog() const;
+
+ // Socket methods:
+ virtual int Read(IOBuffer* buf, int buf_len, CompletionCallback* callback);
+ virtual int Write(IOBuffer* buf, int buf_len, CompletionCallback* callback);
+ virtual bool SetReceiveBufferSize(int32 size);
+ virtual bool SetSendBufferSize(int32 size);
+
+ private:
+ // Initializes OpenSSL SSL options. Returns a net error code.
+ bool InitializeSSLOptions();
+ bool InitOpenSSL();
+ bool Init();
+ void DoReadCallback(int result);
+ void DoWriteCallback(int result);
+
+ bool DoTransportIO();
+ int DoHandshake();
+ void DoConnectCallback(int result);
+
+ void OnHandshakeIOComplete(int result);
+ void OnSendComplete(int result);
+ void OnRecvComplete(int result);
+
+ int DoHandshakeLoop(int last_io_result);
+ int DoReadLoop(int result);
+ int DoWriteLoop(int result);
+ int DoPayloadRead();
+ int DoPayloadWrite();
+
+ int BufferSend(void);
+ int BufferRecv(void);
+ void BufferSendComplete(int result);
+ void BufferRecvComplete(int result);
+
+ CompletionCallbackImpl<SSLClientSocketOpenSSL> *buffer_send_callback_;
+ CompletionCallbackImpl<SSLClientSocketOpenSSL> *buffer_recv_callback_;
+ bool transport_send_busy_;
+ bool transport_recv_busy_;
+ scoped_refptr<IOBuffer> recv_buffer_;
+
+ CompletionCallback* user_connect_callback_;
+ CompletionCallback* user_read_callback_;
+ CompletionCallback* user_write_callback_;
+
+ // Used by Read function.
+ scoped_refptr<IOBuffer> user_read_buf_;
+ int user_read_buf_len_;
+
+ // Used by Write function.
+ scoped_refptr<IOBuffer> user_write_buf_;
+ int user_write_buf_len_;
+
+ // Stores client authentication information between ClientAuthHandler and
+ // GetSSLCertRequestInfo calls.
+ std::vector<scoped_refptr<X509Certificate> > client_certs_;
+ bool client_auth_cert_needed_;
+
+ // OpenSSL stuff
+ static SSL_CTX* ctx;
+ SSL* ssl;
+ BIO* bio_read;
+ BIO* bio_write;
+ size_t write_buf_size;
+
+ scoped_ptr<ClientSocketHandle> transport_;
+ std::string hostname_;
+ SSLConfig ssl_config_;
+
+ bool completed_handshake_;
+
+ enum State {
+ STATE_NONE,
+ STATE_HANDSHAKE,
+ STATE_VERIFY_CERT,
+ STATE_VERIFY_CERT_COMPLETE,
+ };
+ State next_handshake_state_;
+ BoundNetLog net_log_;
+};
+
+} // namespace net
+
+#endif // NET_SOCKET_SSL_CLIENT_SOCKET_OPENSSL_H_
+
diff --git a/net/socket/tcp_client_socket_pool.cc b/net/socket/tcp_client_socket_pool.cc
index 2caa3fb..730f40e 100644
--- a/net/socket/tcp_client_socket_pool.cc
+++ b/net/socket/tcp_client_socket_pool.cc
@@ -150,6 +150,7 @@ int TCPConnectJob::DoTCPConnect() {
int TCPConnectJob::DoTCPConnectComplete(int result) {
if (result == OK) {
+#ifndef ANDROID
DCHECK(connect_start_time_ != base::TimeTicks());
DCHECK(start_time_ != base::TimeTicks());
base::TimeTicks now = base::TimeTicks::Now();
@@ -167,6 +168,7 @@ int TCPConnectJob::DoTCPConnectComplete(int result) {
base::TimeDelta::FromMilliseconds(1),
base::TimeDelta::FromMinutes(10),
100);
+#endif
} else {
// Delete the socket on error.
set_socket(NULL);
diff --git a/net/url_request/url_request.h b/net/url_request/url_request.h
index 7256ec0..b238356 100644
--- a/net/url_request/url_request.h
+++ b/net/url_request/url_request.h
@@ -542,8 +542,8 @@ class URLRequest : public NonThreadSafe {
// Returns the priority level for this request.
net::RequestPriority priority() const { return priority_; }
void set_priority(net::RequestPriority priority) {
- DCHECK_GE(priority, net::HIGHEST);
- DCHECK_LE(priority, net::LOWEST);
+ //DCHECK_GE(priority, net::HIGHEST);
+ //DCHECK_LE(priority, net::LOWEST);
priority_ = priority;
}
diff --git a/net/url_request/url_request_job.cc b/net/url_request/url_request_job.cc
index 23a7d85..a31df82 100644
--- a/net/url_request/url_request_job.cc
+++ b/net/url_request/url_request_job.cc
@@ -737,6 +737,7 @@ void URLRequestJob::RecordPacketStats(StatisticSelector statistic) const {
base::TimeDelta duration = final_packet_time_ - request_time_snapshot_;
switch (statistic) {
+#ifndef ANDROID
case SDCH_DECODE: {
UMA_HISTOGRAM_CLIPPED_TIMES("Sdch3.Network_Decode_Latency_F_a", duration,
base::TimeDelta::FromMilliseconds(20),
@@ -853,6 +854,7 @@ void URLRequestJob::RecordPacketStats(StatisticSelector statistic) const {
base::TimeDelta::FromSeconds(10), 100);
return;
}
+#endif // ANDROID
default:
NOTREACHED();
return;
diff --git a/net/url_request/url_request_job_manager.cc b/net/url_request/url_request_job_manager.cc
index 0615280..5ea8563 100644
--- a/net/url_request/url_request_job_manager.cc
+++ b/net/url_request/url_request_job_manager.cc
@@ -31,9 +31,11 @@ static const SchemeToFactory kBuiltinFactories[] = {
{ "http", URLRequestHttpJob::Factory },
{ "https", URLRequestHttpJob::Factory },
{ "file", URLRequestFileJob::Factory },
+#ifndef ANDROID
{ "ftp", URLRequestFtpJob::Factory },
{ "about", URLRequestAboutJob::Factory },
{ "data", URLRequestDataJob::Factory },
+#endif
};
URLRequestJobManager::URLRequestJobManager() {