diff options
author | pinkerton@google.com <pinkerton@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-25 19:47:30 +0000 |
---|---|---|
committer | pinkerton@google.com <pinkerton@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-25 19:47:30 +0000 |
commit | 68bf915b57f9e781622c433f8795153cca8b5b9e (patch) | |
tree | 9951f7fa93ba72213f2057e82b13f84248f904b6 /net | |
parent | ec9a68914f38540671f2d1ea1b3d8e10e29e50c6 (diff) | |
download | chromium_src-68bf915b57f9e781622c433f8795153cca8b5b9e.zip chromium_src-68bf915b57f9e781622c433f8795153cca8b5b9e.tar.gz chromium_src-68bf915b57f9e781622c433f8795153cca8b5b9e.tar.bz2 |
add http layer and unit tests to mac build. stub out file uploading in upload_data_stream until we have a common file wrapper.
Review URL: http://codereview.chromium.org/4090
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2599 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/base/client_socket_factory.cc | 9 | ||||
-rw-r--r-- | net/base/upload_data_stream.cc | 16 | ||||
-rw-r--r-- | net/base/upload_data_stream.h | 4 | ||||
-rw-r--r-- | net/http/http_network_layer.cc | 9 | ||||
-rw-r--r-- | net/http/http_network_layer_unittest.cc | 7 | ||||
-rw-r--r-- | net/http/http_network_transaction.cc | 13 | ||||
-rw-r--r-- | net/http/http_network_transaction_unittest.cc | 8 | ||||
-rw-r--r-- | net/net.xcodeproj/project.pbxproj | 18 |
8 files changed, 60 insertions, 24 deletions
diff --git a/net/base/client_socket_factory.cc b/net/base/client_socket_factory.cc index 1701970..fb5c182 100644 --- a/net/base/client_socket_factory.cc +++ b/net/base/client_socket_factory.cc @@ -5,7 +5,10 @@ #include "net/base/client_socket_factory.h" #include "base/singleton.h" +#include "build/build_config.h" +#if defined(OS_WIN) #include "net/base/ssl_client_socket.h" +#endif #include "net/base/tcp_client_socket.h" namespace net { @@ -20,7 +23,13 @@ class DefaultClientSocketFactory : public ClientSocketFactory { virtual ClientSocket* CreateSSLClientSocket( ClientSocket* transport_socket, const std::string& hostname) { +#if defined(OS_WIN) return new SSLClientSocket(transport_socket, hostname); +#else + // TODO(pinkerton): turn on when we port SSL socket from win32 + NOTIMPLEMENTED(); + return NULL; +#endif } }; diff --git a/net/base/upload_data_stream.cc b/net/base/upload_data_stream.cc index 61e8b59..702aeca 100644 --- a/net/base/upload_data_stream.cc +++ b/net/base/upload_data_stream.cc @@ -10,15 +10,19 @@ namespace net { UploadDataStream::UploadDataStream(const UploadData* data) : data_(data), +#if defined(OS_WIN) next_element_handle_(INVALID_HANDLE_VALUE), +#endif total_size_(data->GetContentLength()) { Reset(); FillBuf(); } UploadDataStream::~UploadDataStream() { +#if defined(OS_WIN) if (next_element_handle_ != INVALID_HANDLE_VALUE) CloseHandle(next_element_handle_); +#endif } void UploadDataStream::DidConsume(size_t num_bytes) { @@ -34,10 +38,12 @@ void UploadDataStream::DidConsume(size_t num_bytes) { } void UploadDataStream::Reset() { +#if defined(OS_WIN) if (next_element_handle_ != INVALID_HANDLE_VALUE) { CloseHandle(next_element_handle_); next_element_handle_ = INVALID_HANDLE_VALUE; } +#endif buf_len_ = 0; next_element_ = data_->elements().begin(); next_element_offset_ = 0; @@ -70,6 +76,7 @@ void UploadDataStream::FillBuf() { } else { DCHECK((*next_element_).type() == UploadData::TYPE_FILE); +#if defined(OS_WIN) if (next_element_handle_ == INVALID_HANDLE_VALUE) { next_element_handle_ = CreateFile((*next_element_).file_path().c_str(), GENERIC_READ, @@ -112,15 +119,24 @@ void UploadDataStream::FillBuf() { if (!ok || bytes_read == 0) advance_to_next_element = true; +#elif defined(OS_POSIX) + // TODO(pinkerton): unify the file upload handling for all platforms once + // we have a cross-platform file representation. There shouldn't be any + // difference among them. + NOTIMPLEMENTED(); + advance_to_next_element = true; +#endif } if (advance_to_next_element) { ++next_element_; next_element_offset_ = 0; +#if defined(OS_WIN) if (next_element_handle_ != INVALID_HANDLE_VALUE) { CloseHandle(next_element_handle_); next_element_handle_ = INVALID_HANDLE_VALUE; } +#endif } } } diff --git a/net/base/upload_data_stream.h b/net/base/upload_data_stream.h index b8b9719..f31cb80 100644 --- a/net/base/upload_data_stream.h +++ b/net/base/upload_data_stream.h @@ -5,6 +5,7 @@ #ifndef NET_BASE_UPLOAD_DATA_STREAM_H_ #define NET_BASE_UPLOAD_DATA_STREAM_H_ +#include "build/build_config.h" #include "net/base/upload_data.h" namespace net { @@ -50,9 +51,12 @@ class UploadDataStream { // a TYPE_BYTES element. size_t next_element_offset_; +#if defined(OS_WIN) // A handle to the currently open file (or INVALID_HANDLE_VALUE) for // next_element_ if the next element is a TYPE_FILE element. + // TODO(pinkerton): when we get a cross-platform file class, replace this HANDLE next_element_handle_; +#endif // The number of bytes remaining to be read from the currently open file // if the next element is of TYPE_FILE. diff --git a/net/http/http_network_layer.cc b/net/http/http_network_layer.cc index 9b38867..9b2c468 100644 --- a/net/http/http_network_layer.cc +++ b/net/http/http_network_layer.cc @@ -7,9 +7,7 @@ #include "base/logging.h" #include "net/base/client_socket_factory.h" #include "net/http/http_network_session.h" -#if !defined(OS_MACOSX) #include "net/http/http_network_transaction.h" -#endif #include "net/proxy/proxy_resolver_fixed.h" #if defined(OS_WIN) #include "net/http/http_transaction_winhttp.h" @@ -68,15 +66,8 @@ HttpTransaction* HttpNetworkLayer::CreateTransaction() { if (suspended_) return NULL; -#if !defined(OS_MACOSX) return new HttpNetworkTransaction( session_, ClientSocketFactory::GetDefaultFactory()); -#else -// TODO(pinkerton): Stubbing out to get TestShell to link. We'll bring this -// back in once we get more of the net pipeline worked out. - NOTIMPLEMENTED(); - return NULL; -#endif } HttpCache* HttpNetworkLayer::GetCache() { diff --git a/net/http/http_network_layer_unittest.cc b/net/http/http_network_layer_unittest.cc index ec0e08c..7f99e54 100644 --- a/net/http/http_network_layer_unittest.cc +++ b/net/http/http_network_layer_unittest.cc @@ -2,15 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/platform_test.h" #include "net/base/scoped_host_mapper.h" #include "net/http/http_network_layer.h" #include "net/http/http_transaction_unittest.h" #include "net/proxy/proxy_service.h" #include "testing/gtest/include/gtest/gtest.h" -namespace { - -class HttpNetworkLayerTest : public testing::Test { +class HttpNetworkLayerTest : public PlatformTest { public: HttpNetworkLayerTest() { // TODO(darin): kill this exception once we have a way to test out the @@ -21,8 +20,6 @@ class HttpNetworkLayerTest : public testing::Test { net::ScopedHostMapper host_mapper_; }; -} // namespace - TEST_F(HttpNetworkLayerTest, CreateAndDestroy) { net::HttpNetworkLayer factory(NULL); diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc index 8c12261..7da6a63 100644 --- a/net/http/http_network_transaction.cc +++ b/net/http/http_network_transaction.cc @@ -4,12 +4,16 @@ #include "net/http/http_network_transaction.h" +#include "base/compiler_specific.h" #include "base/string_util.h" #include "base/trace_event.h" +#include "build/build_config.h" #include "net/base/client_socket_factory.h" #include "net/base/host_resolver.h" #include "net/base/load_flags.h" +#if defined(OS_WIN) #include "net/base/ssl_client_socket.h" +#endif #include "net/base/upload_data_stream.h" #include "net/http/http_chunked_decoder.h" #include "net/http/http_network_session.h" @@ -27,8 +31,9 @@ namespace net { HttpNetworkTransaction::HttpNetworkTransaction(HttpNetworkSession* session, ClientSocketFactory* csf) -#pragma warning(suppress: 4355) - : io_callback_(this, &HttpNetworkTransaction::OnIOComplete), +MSVC_SUPPRESS_WARNING(4355) + : ALLOW_THIS_IN_INITIALIZER_LIST( + io_callback_(this, &HttpNetworkTransaction::OnIOComplete)), user_callback_(NULL), session_(session), request_(NULL), @@ -786,11 +791,13 @@ int HttpNetworkTransaction::DidReadResponseHeaders() { } } +#if defined(OS_WIN) if (using_ssl_ && !establishing_tunnel_) { SSLClientSocket* ssl_socket = reinterpret_cast<SSLClientSocket*>(connection_.socket()); ssl_socket->GetSSLInfo(&response_.ssl_info); } +#endif return OK; } @@ -819,11 +826,13 @@ int HttpNetworkTransaction::HandleCertificateError(int error) { } } +#if defined(OS_WIN) if (error != OK) { SSLClientSocket* ssl_socket = reinterpret_cast<SSLClientSocket*>(connection_.socket()); ssl_socket->GetSSLInfo(&response_.ssl_info); } +#endif return error; } diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc index 2b54e09..a39399f 100644 --- a/net/http/http_network_transaction_unittest.cc +++ b/net/http/http_network_transaction_unittest.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 "base/compiler_specific.h" +#include "base/platform_test.h" #include "net/base/client_socket_factory.h" #include "net/base/test_completion_callback.h" #include "net/base/upload_data.h" @@ -12,7 +14,6 @@ //----------------------------------------------------------------------------- -namespace { struct MockConnect { bool async; @@ -45,9 +46,8 @@ int mock_sockets_index; class MockTCPClientSocket : public net::ClientSocket { public: MockTCPClientSocket(const net::AddressList& addresses) -#pragma warning(suppress:4355) : data_(mock_sockets[mock_sockets_index++]), - method_factory_(this), + ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), callback_(NULL), read_index_(0), read_offset_(0), @@ -218,8 +218,6 @@ SimpleGetHelperResult SimpleGetHelper(MockRead data_reads[]) { return out; } -} // namespace - //----------------------------------------------------------------------------- TEST_F(HttpNetworkTransactionTest, Basic) { diff --git a/net/net.xcodeproj/project.pbxproj b/net/net.xcodeproj/project.pbxproj index 3309aa3..9e142fd 100644 --- a/net/net.xcodeproj/project.pbxproj +++ b/net/net.xcodeproj/project.pbxproj @@ -140,6 +140,12 @@ E49DD3370E8933A2003C7A87 /* proxy_service.cc in Sources */ = {isa = PBXBuildFile; fileRef = E49DD3360E8933A2003C7A87 /* proxy_service.cc */; }; E49DD33C0E8933C0003C7A87 /* proxy_resolver_fixed.cc in Sources */ = {isa = PBXBuildFile; fileRef = E49DD33B0E8933C0003C7A87 /* proxy_resolver_fixed.cc */; }; E4AFA6430E5241B400201347 /* run_all_unittests.cc in Sources */ = {isa = PBXBuildFile; fileRef = E4AFA6420E5241B400201347 /* run_all_unittests.cc */; }; + E4CE9BC50E8BF92400D5378C /* http_network_transaction.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7BED33680E5A194700A747DB /* http_network_transaction.cc */; }; + E4CE9C070E8BFF0700D5378C /* upload_data_stream.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7BED32870E5A181C00A747DB /* upload_data_stream.cc */; }; + E4CE9C0D0E8BFFFA00D5378C /* client_socket_factory.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7BED32700E5A181C00A747DB /* client_socket_factory.cc */; }; + E4CE9C260E8C027900D5378C /* http_network_layer_unittest.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7BED335C0E5A194700A747DB /* http_network_layer_unittest.cc */; }; + E4CE9C2E0E8C02ED00D5378C /* http_transaction_unittest.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7BED334A0E5A194700A747DB /* http_transaction_unittest.cc */; }; + E4CE9C380E8C035C00D5378C /* http_network_transaction_unittest.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7BED33590E5A194700A747DB /* http_network_transaction_unittest.cc */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -598,6 +604,8 @@ 82113A1C0E8434EE00E3848F /* x509_certificate_unittest.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = x509_certificate_unittest.cc; sourceTree = "<group>"; }; 82113A270E84360200E3848F /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = "<group>"; }; 82113BBC0E892E5800E3848F /* x509_certificate.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = x509_certificate.cc; sourceTree = "<group>"; }; + DFEE18250E882E3600666107 /* stats_histogram.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = stats_histogram.cc; sourceTree = "<group>"; }; + DFEE18260E882E3600666107 /* stats_histogram.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = stats_histogram.h; sourceTree = "<group>"; }; E47E933E0E8924DC00CA613E /* tcp_client_socket_libevent.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = tcp_client_socket_libevent.cc; sourceTree = "<group>"; }; E49DD2E80E892F8C003C7A87 /* sdch_manager.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sdch_manager.cc; sourceTree = "<group>"; }; E49DD2E90E892F8C003C7A87 /* sdch_manager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sdch_manager.h; sourceTree = "<group>"; }; @@ -605,8 +613,6 @@ E49DD3360E8933A2003C7A87 /* proxy_service.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = proxy_service.cc; path = proxy/proxy_service.cc; sourceTree = "<group>"; }; E49DD33A0E8933C0003C7A87 /* proxy_resolver_fixed.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = proxy_resolver_fixed.h; path = proxy/proxy_resolver_fixed.h; sourceTree = "<group>"; }; E49DD33B0E8933C0003C7A87 /* proxy_resolver_fixed.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = proxy_resolver_fixed.cc; path = proxy/proxy_resolver_fixed.cc; sourceTree = "<group>"; }; - DFEE18250E882E3600666107 /* stats_histogram.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = stats_histogram.cc; sourceTree = "<group>"; }; - DFEE18260E882E3600666107 /* stats_histogram.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = stats_histogram.h; sourceTree = "<group>"; }; E4AFA6230E523E2900201347 /* net_unittests */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = net_unittests; sourceTree = BUILT_PRODUCTS_DIR; }; E4AFA62E0E5240A300201347 /* gtest.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = gtest.xcodeproj; path = testing/gtest.xcodeproj; sourceTree = "<group>"; }; E4AFA6420E5241B400201347 /* run_all_unittests.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = run_all_unittests.cc; sourceTree = "<group>"; }; @@ -1319,6 +1325,7 @@ 7B8504050E5B2DBD00730B43 /* cache_util_posix.cc in Sources */, 821F207B0E5CD342003C7E38 /* cert_status_cache.cc in Sources */, 7B8504080E5B2DD800730B43 /* client_socket_handle.cc in Sources */, + E4CE9C0D0E8BFFFA00D5378C /* client_socket_factory.cc in Sources */, 7B8504090E5B2DD800730B43 /* client_socket_pool.cc in Sources */, 7B8B5A430E5CD1FD002F9A97 /* cookie_monster.cc in Sources */, 7B85040C0E5B2DD800730B43 /* cookie_policy.cc in Sources */, @@ -1336,6 +1343,7 @@ 0482692A0E5B624D00A30786 /* http_cache.cc in Sources */, 7B85042B0E5B2E2A00730B43 /* http_chunked_decoder.cc in Sources */, E49DD3290E893336003C7A87 /* http_network_layer.cc in Sources */, + E4CE9BC50E8BF92400D5378C /* http_network_transaction.cc in Sources */, 821F21300E5CD746003C7E38 /* http_response_headers.cc in Sources */, 7B85042F0E5B2E4900730B43 /* http_util.cc in Sources */, 821F207F0E5CD3C6003C7E38 /* http_vary_data.cc in Sources */, @@ -1358,9 +1366,11 @@ 7B8B5B560E5CEADE002F9A97 /* registry_controlled_domain.cc in Sources */, E49DD2EA0E892F8C003C7A87 /* sdch_manager.cc in Sources */, 7B8504410E5B2E9600730B43 /* stats.cc in Sources */, + DFEE18270E882E3600666107 /* stats_histogram.cc in Sources */, E47E933F0E8924DC00CA613E /* tcp_client_socket_libevent.cc in Sources */, 7B8504450E5B2E9600730B43 /* trace.cc in Sources */, 821F23670E5E0D2F003C7E38 /* upload_data.cc in Sources */, + E4CE9C070E8BFF0700D5378C /* upload_data_stream.cc in Sources */, 821F23710E5E0F15003C7E38 /* url_request.cc in Sources */, 821F23C30E5E105E003C7E38 /* url_request_about_job.cc in Sources */, 7B85044A0E5B2E9600730B43 /* url_request_error_job.cc in Sources */, @@ -1373,7 +1383,6 @@ 821F20A50E5CD414003C7E38 /* url_request_view_cache_job.cc in Sources */, 82113BBD0E892E5800E3848F /* x509_certificate.cc in Sources */, 827E139D0E81611D00183614 /* x509_certificate_mac.cc in Sources */, - DFEE18270E882E3600666107 /* stats_histogram.cc in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1396,7 +1405,10 @@ 7BA0151F0E5A1B9200044150 /* gzip_filter_unittest.cc in Sources */, 7B82FF460E763620008F45CF /* host_resolver_unittest.cc in Sources */, 048268080E5B3B3200A30786 /* http_chunked_decoder_unittest.cc in Sources */, + E4CE9C260E8C027900D5378C /* http_network_layer_unittest.cc in Sources */, + E4CE9C380E8C035C00D5378C /* http_network_transaction_unittest.cc in Sources */, 821F21320E5CD756003C7E38 /* http_response_headers_unittest.cc in Sources */, + E4CE9C2E0E8C02ED00D5378C /* http_transaction_unittest.cc in Sources */, 821F21130E5CD662003C7E38 /* http_vary_data_unittest.cc in Sources */, 7BD8F7100E65DCF000034DE9 /* mapped_file_unittest.cc in Sources */, 7B4DF9AC0E5C906A004D7619 /* mime_sniffer_unittest.cc in Sources */, |