diff options
37 files changed, 1078 insertions, 1078 deletions
diff --git a/chrome/browser/browser_init.cc b/chrome/browser/browser_init.cc index 4353846..937cbc8f 100644 --- a/chrome/browser/browser_init.cc +++ b/chrome/browser/browser_init.cc @@ -885,10 +885,10 @@ bool BrowserInit::ProcessCmdLineImpl(const CommandLine& command_line, } } - if (command_line.HasSwitch(switches::kUseFlip)) { - std::string flip_mode = - command_line.GetSwitchValueASCII(switches::kUseFlip); - net::HttpNetworkLayer::EnableFlip(flip_mode); + if (command_line.HasSwitch(switches::kUseSpdy)) { + std::string spdy_mode = + command_line.GetSwitchValueASCII(switches::kUseSpdy); + net::HttpNetworkLayer::EnableSpdy(spdy_mode); } if (command_line.HasSwitch(switches::kExplicitlyAllowedPorts)) { diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc index 21cc36c..04ec0ed 100644 --- a/chrome/browser/browser_main.cc +++ b/chrome/browser/browser_main.cc @@ -721,7 +721,7 @@ int BrowserMain(const MainFunctionParams& parameters) { #if defined(OS_WIN) if (parsed_command_line.HasSwitch(switches::kUseNSSForSSL) || - parsed_command_line.HasSwitch(switches::kUseFlip)) { + parsed_command_line.HasSwitch(switches::kUseSpdy)) { net::ClientSocketFactory::SetSSLClientSocketFactory( net::SSLClientSocketNSSFactory); } diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index 2a879fd..5d76c4d 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -624,14 +624,14 @@ const char kTryChromeAgain[] = "try-chrome-again"; // Runs un-installation steps that were done by chrome first-run. const char kUninstall[] = "uninstall"; -// Use Flip for the transport protocol instead of HTTP. -// This is a temporary testing flag. -const char kUseFlip[] = "use-flip"; - // Use NSS instead of the system SSL library for SSL. // This is a temporary testing flag. const char kUseNSSForSSL[] = "use-nss-for-ssl"; +// Use Spdy for the transport protocol instead of HTTP. +// This is a temporary testing flag. +const char kUseSpdy[] = "use-spdy"; + // Force all requests to go to this server. This commandline is provided // for testing purposes only, and will likely be removed soon. It can also // hurt startup performance as it does a synchronous name resolution on the diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index e61a217..f7c86aa 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -181,8 +181,8 @@ extern const char kThumbnailStore[]; extern const char kTrustedPlugins[]; extern const char kTryChromeAgain[]; extern const char kUninstall[]; -extern const char kUseFlip[]; extern const char kUseNSSForSSL[]; +extern const char kUseSpdy[]; extern const char kFixedHost[]; extern const char kFixedHttpPort[]; extern const char kFixedHttpsPort[]; diff --git a/net/base/load_log_event_type_list.h b/net/base/load_log_event_type_list.h index 1a34625..e6b991e 100644 --- a/net/base/load_log_event_type_list.h +++ b/net/base/load_log_event_type_list.h @@ -166,39 +166,39 @@ EVENT_TYPE(HTTP_TRANSACTION_READ_BODY) EVENT_TYPE(HTTP_TRANSACTION_DRAIN_BODY_FOR_AUTH_RESTART) // ------------------------------------------------------------------------ -// FlipNetworkTransaction +// SpdyNetworkTransaction // ------------------------------------------------------------------------ -// Measures the time taken to get a flip stream. -EVENT_TYPE(FLIP_TRANSACTION_INIT_CONNECTION) +// Measures the time taken to get a spdy stream. +EVENT_TYPE(SPDY_TRANSACTION_INIT_CONNECTION) // Measures the time taken to send the request to the server. -EVENT_TYPE(FLIP_TRANSACTION_SEND_REQUEST) +EVENT_TYPE(SPDY_TRANSACTION_SEND_REQUEST) // Measures the time to read HTTP response headers from the server. -EVENT_TYPE(FLIP_TRANSACTION_READ_HEADERS) +EVENT_TYPE(SPDY_TRANSACTION_READ_HEADERS) // Measures the time to read the entity body from the server. -EVENT_TYPE(FLIP_TRANSACTION_READ_BODY) +EVENT_TYPE(SPDY_TRANSACTION_READ_BODY) // ------------------------------------------------------------------------ -// FlipStream +// SpdyStream // ------------------------------------------------------------------------ // Measures the time taken to send headers on a stream. -EVENT_TYPE(FLIP_STREAM_SEND_HEADERS) +EVENT_TYPE(SPDY_STREAM_SEND_HEADERS) // Measures the time taken to send the body (e.g. a POST) on a stream. -EVENT_TYPE(FLIP_STREAM_SEND_BODY) +EVENT_TYPE(SPDY_STREAM_SEND_BODY) // Measures the time taken to read headers on a stream. -EVENT_TYPE(FLIP_STREAM_READ_HEADERS) +EVENT_TYPE(SPDY_STREAM_READ_HEADERS) // Measures the time taken to read the body on a stream. -EVENT_TYPE(FLIP_STREAM_READ_BODY) +EVENT_TYPE(SPDY_STREAM_READ_BODY) // Logs that a stream attached to a pushed stream. -EVENT_TYPE(FLIP_STREAM_ADOPTED_PUSH_STREAM) +EVENT_TYPE(SPDY_STREAM_ADOPTED_PUSH_STREAM) // ------------------------------------------------------------------------ // HttpStreamParser diff --git a/net/base/net_error_list.h b/net/base/net_error_list.h index 6ea5457..ab777e6 100644 --- a/net/base/net_error_list.h +++ b/net/base/net_error_list.h @@ -296,14 +296,14 @@ NET_ERROR(ENCODING_CONVERSION_FAILED, -333) // The server sent an FTP directory listing in a format we do not understand. NET_ERROR(UNRECOGNIZED_FTP_DIRECTORY_LISTING_FORMAT, -334) -// Attempted use of an unknown FLIP stream id. -NET_ERROR(INVALID_FLIP_STREAM, -335) +// Attempted use of an unknown SPDY stream id. +NET_ERROR(INVALID_SPDY_STREAM, -335) // There are no supported proxies in the provided list. NET_ERROR(NO_SUPPORTED_PROXIES, -336) -// There is a FLIP protocol framing error. -NET_ERROR(FLIP_PROTOCOL_ERROR, -337) +// There is a SPDY protocol framing error. +NET_ERROR(SPDY_PROTOCOL_ERROR, -337) // Credentials could not be estalished during HTTP Authentication. NET_ERROR(INVALID_AUTH_CREDENTIALS, -338) diff --git a/net/http/http_cache.cc b/net/http/http_cache.cc index b6cff8e..d4e3d2b 100644 --- a/net/http/http_cache.cc +++ b/net/http/http_cache.cc @@ -810,8 +810,8 @@ void HttpCache::CloseCurrentConnections() { HttpNetworkSession* session = network->GetSession(); if (session) { session->tcp_socket_pool()->CloseIdleSockets(); - if (session->flip_session_pool()) - session->flip_session_pool()->CloseAllSessions(); + if (session->spdy_session_pool()) + session->spdy_session_pool()->CloseAllSessions(); session->ReplaceTCPSocketPool(); } } diff --git a/net/http/http_network_layer.cc b/net/http/http_network_layer.cc index 6e5df6a..089807c 100644 --- a/net/http/http_network_layer.cc +++ b/net/http/http_network_layer.cc @@ -40,7 +40,7 @@ HttpTransactionFactory* HttpNetworkLayer::CreateFactory( } //----------------------------------------------------------------------------- -bool HttpNetworkLayer::force_flip_ = false; +bool HttpNetworkLayer::force_spdy_ = false; HttpNetworkLayer::HttpNetworkLayer( ClientSocketFactory* socket_factory, @@ -54,7 +54,7 @@ HttpNetworkLayer::HttpNetworkLayer( proxy_service_(proxy_service), ssl_config_service_(ssl_config_service), session_(NULL), - flip_session_pool_(NULL), + spdy_session_pool_(NULL), suspended_(false) { DCHECK(proxy_service_); DCHECK(ssl_config_service_.get()); @@ -65,7 +65,7 @@ HttpNetworkLayer::HttpNetworkLayer(HttpNetworkSession* session) network_change_notifier_(NULL), ssl_config_service_(NULL), session_(session), - flip_session_pool_(session->flip_session_pool()), + spdy_session_pool_(session->spdy_session_pool()), suspended_(false) { DCHECK(session_.get()); } @@ -77,8 +77,8 @@ int HttpNetworkLayer::CreateTransaction(scoped_ptr<HttpTransaction>* trans) { if (suspended_) return ERR_NETWORK_IO_SUSPENDED; - if (force_flip_) - trans->reset(new FlipNetworkTransaction(GetSession())); + if (force_spdy_) + trans->reset(new SpdyNetworkTransaction(GetSession())); else trans->reset(new HttpNetworkTransaction(GetSession())); return OK; @@ -98,10 +98,10 @@ void HttpNetworkLayer::Suspend(bool suspend) { HttpNetworkSession* HttpNetworkLayer::GetSession() { if (!session_) { DCHECK(proxy_service_); - FlipSessionPool* flip_pool = new FlipSessionPool; + SpdySessionPool* spdy_pool = new SpdySessionPool; session_ = new HttpNetworkSession( network_change_notifier_, host_resolver_, proxy_service_, - socket_factory_, ssl_config_service_, flip_pool); + socket_factory_, ssl_config_service_, spdy_pool); // These were just temps for lazy-initializing HttpNetworkSession. network_change_notifier_ = NULL; host_resolver_ = NULL; @@ -112,33 +112,33 @@ HttpNetworkSession* HttpNetworkLayer::GetSession() { } // static -void HttpNetworkLayer::EnableFlip(const std::string& mode) { +void HttpNetworkLayer::EnableSpdy(const std::string& mode) { static const char kDisableSSL[] = "no-ssl"; static const char kDisableCompression[] = "no-compress"; static const char kEnableNPN[] = "npn"; - std::vector<std::string> flip_options; - SplitString(mode, ',', &flip_options); + std::vector<std::string> spdy_options; + SplitString(mode, ',', &spdy_options); - // Force flip mode (use FlipNetworkTransaction for all http requests). - force_flip_ = true; + // Force spdy mode (use SpdyNetworkTransaction for all http requests). + force_spdy_ = true; - for (std::vector<std::string>::iterator it = flip_options.begin(); - it != flip_options.end(); ++it) { + for (std::vector<std::string>::iterator it = spdy_options.begin(); + it != spdy_options.end(); ++it) { const std::string& option = *it; // Disable SSL if (option == kDisableSSL) { - FlipSession::SetSSLMode(false); + SpdySession::SetSSLMode(false); } else if (option == kDisableCompression) { - flip::FlipFramer::set_enable_compression_default(false); + spdy::SpdyFramer::set_enable_compression_default(false); } else if (option == kEnableNPN) { HttpNetworkTransaction::SetNextProtos("\007http1.1\004spdy"); - force_flip_ = false; - } else if (option.empty() && it == flip_options.begin()) { + force_spdy_ = false; + } else if (option.empty() && it == spdy_options.begin()) { continue; } else { - LOG(DFATAL) << "Unrecognized flip option: " << option; + LOG(DFATAL) << "Unrecognized spdy option: " << option; } } } diff --git a/net/http/http_network_layer.h b/net/http/http_network_layer.h index 38c10c7..3050298 100644 --- a/net/http/http_network_layer.h +++ b/net/http/http_network_layer.h @@ -14,12 +14,12 @@ namespace net { class ClientSocketFactory; -class FlipSessionPool; class HostResolver; class HttpNetworkSession; class NetworkChangeNotifier; class ProxyInfo; class ProxyService; +class SpdySessionPool; class SSLConfigService; class HttpNetworkLayer : public HttpTransactionFactory { @@ -56,13 +56,13 @@ class HttpNetworkLayer : public HttpTransactionFactory { virtual HttpNetworkSession* GetSession(); virtual void Suspend(bool suspend); - // Enable the flip protocol. - // Without calling this function, FLIP is disabled. The mode can be: + // Enable the spdy protocol. + // Without calling this function, SPDY is disabled. The mode can be: // "" : (default) SSL and compression are enabled. // "no-ssl" : disables SSL. // "no-compress" : disables compression. // "none" : disables both SSL and compression. - static void EnableFlip(const std::string& mode); + static void EnableSpdy(const std::string& mode); private: // The factory we will use to create network sockets. @@ -79,10 +79,10 @@ class HttpNetworkLayer : public HttpTransactionFactory { scoped_refptr<SSLConfigService> ssl_config_service_; scoped_refptr<HttpNetworkSession> session_; - scoped_refptr<FlipSessionPool> flip_session_pool_; + scoped_refptr<SpdySessionPool> spdy_session_pool_; bool suspended_; - static bool force_flip_; + static bool force_spdy_; }; } // namespace net diff --git a/net/http/http_network_session.cc b/net/http/http_network_session.cc index 40f8416..f63105c 100644 --- a/net/http/http_network_session.cc +++ b/net/http/http_network_session.cc @@ -25,7 +25,7 @@ HttpNetworkSession::HttpNetworkSession( ProxyService* proxy_service, ClientSocketFactory* client_socket_factory, SSLConfigService* ssl_config_service, - FlipSessionPool* flip_session_pool) + SpdySessionPool* spdy_session_pool) : network_change_notifier_(network_change_notifier), tcp_socket_pool_(new TCPClientSocketPool( max_sockets_, max_sockets_per_group_, @@ -34,7 +34,7 @@ HttpNetworkSession::HttpNetworkSession( host_resolver_(host_resolver), proxy_service_(proxy_service), ssl_config_service_(ssl_config_service), - flip_session_pool_(flip_session_pool) { + spdy_session_pool_(spdy_session_pool) { DCHECK(proxy_service); DCHECK(ssl_config_service); } diff --git a/net/http/http_network_session.h b/net/http/http_network_session.h index 32bcdee..5049b41 100644 --- a/net/http/http_network_session.h +++ b/net/http/http_network_session.h @@ -16,7 +16,7 @@ namespace net { class ClientSocketFactory; -class FlipSessionPool; +class SpdySessionPool; class NetworkChangeNotifier; // This class holds session objects used by HttpNetworkTransaction objects. @@ -28,7 +28,7 @@ class HttpNetworkSession : public base::RefCounted<HttpNetworkSession> { ProxyService* proxy_service, ClientSocketFactory* client_socket_factory, SSLConfigService* ssl_config_service, - FlipSessionPool* flip_session_pool); + SpdySessionPool* spdy_session_pool); HttpAuthCache* auth_cache() { return &auth_cache_; } SSLClientAuthCache* ssl_client_auth_cache() { @@ -42,8 +42,8 @@ class HttpNetworkSession : public base::RefCounted<HttpNetworkSession> { HostResolver* host_resolver() { return host_resolver_; } ProxyService* proxy_service() { return proxy_service_; } SSLConfigService* ssl_config_service() { return ssl_config_service_; } - const scoped_refptr<FlipSessionPool>& flip_session_pool() { - return flip_session_pool_; + const scoped_refptr<SpdySessionPool>& spdy_session_pool() { + return spdy_session_pool_; } // Replace the current socket pool with a new one. This effectively @@ -83,7 +83,7 @@ class HttpNetworkSession : public base::RefCounted<HttpNetworkSession> { scoped_refptr<HostResolver> host_resolver_; scoped_refptr<ProxyService> proxy_service_; scoped_refptr<SSLConfigService> ssl_config_service_; - scoped_refptr<FlipSessionPool> flip_session_pool_; + scoped_refptr<SpdySessionPool> spdy_session_pool_; }; } // namespace net diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc index 1ad8b6a..c7c5d35 100644 --- a/net/http/http_network_transaction.cc +++ b/net/http/http_network_transaction.cc @@ -516,40 +516,40 @@ int HttpNetworkTransaction::DoLoop(int result) { DCHECK_EQ(OK, rv); TRACE_EVENT_BEGIN("http.send_request", request_, request_->url.spec()); LoadLog::BeginEvent(load_log_, - LoadLog::TYPE_FLIP_TRANSACTION_SEND_REQUEST); + LoadLog::TYPE_SPDY_TRANSACTION_SEND_REQUEST); rv = DoSpdySendRequest(); break; case STATE_SPDY_SEND_REQUEST_COMPLETE: rv = DoSpdySendRequestComplete(rv); TRACE_EVENT_END("http.send_request", request_, request_->url.spec()); LoadLog::EndEvent(load_log_, - LoadLog::TYPE_FLIP_TRANSACTION_SEND_REQUEST); + LoadLog::TYPE_SPDY_TRANSACTION_SEND_REQUEST); break; case STATE_SPDY_READ_HEADERS: DCHECK_EQ(OK, rv); TRACE_EVENT_BEGIN("http.read_headers", request_, request_->url.spec()); LoadLog::BeginEvent(load_log_, - LoadLog::TYPE_FLIP_TRANSACTION_READ_HEADERS); + LoadLog::TYPE_SPDY_TRANSACTION_READ_HEADERS); rv = DoSpdyReadHeaders(); break; case STATE_SPDY_READ_HEADERS_COMPLETE: rv = DoSpdyReadHeadersComplete(rv); TRACE_EVENT_END("http.read_headers", request_, request_->url.spec()); LoadLog::EndEvent(load_log_, - LoadLog::TYPE_FLIP_TRANSACTION_READ_HEADERS); + LoadLog::TYPE_SPDY_TRANSACTION_READ_HEADERS); break; case STATE_SPDY_READ_BODY: DCHECK_EQ(OK, rv); TRACE_EVENT_BEGIN("http.read_body", request_, request_->url.spec()); LoadLog::BeginEvent(load_log_, - LoadLog::TYPE_FLIP_TRANSACTION_READ_BODY); + LoadLog::TYPE_SPDY_TRANSACTION_READ_BODY); rv = DoSpdyReadBody(); break; case STATE_SPDY_READ_BODY_COMPLETE: rv = DoSpdyReadBodyComplete(rv); TRACE_EVENT_END("http.read_body", request_, request_->url.spec()); LoadLog::EndEvent(load_log_, - LoadLog::TYPE_FLIP_TRANSACTION_READ_BODY); + LoadLog::TYPE_SPDY_TRANSACTION_READ_BODY); break; default: NOTREACHED() << "bad state"; @@ -660,9 +660,9 @@ int HttpNetworkTransaction::DoInitConnection() { resolve_info.set_allow_cached_response(false); } - // Check first if we have a flip session for this group. If so, then go + // Check first if we have a spdy session for this group. If so, then go // straight to using that. - if (session_->flip_session_pool()->HasSession(resolve_info)) + if (session_->spdy_session_pool()->HasSession(resolve_info)) return OK; int rv = connection_->Init(connection_group, resolve_info, request_->priority, @@ -679,7 +679,7 @@ int HttpNetworkTransaction::DoInitConnectionComplete(int result) { DCHECK_EQ(OK, result); - // If we don't have an initialized connection, that means we have a flip + // If we don't have an initialized connection, that means we have a spdy // connection waiting for us. if (!connection_->is_initialized()) { next_state_ = STATE_SPDY_SEND_REQUEST; @@ -1107,14 +1107,14 @@ int HttpNetworkTransaction::DoSpdySendRequest() { HostResolver::RequestInfo req_info(request_->url.HostNoBrackets(), request_->url.EffectiveIntPort()); req_info.set_priority(request_->priority); - const scoped_refptr<FlipSessionPool> spdy_pool = - session_->flip_session_pool(); - scoped_refptr<FlipSession> spdy_session; + const scoped_refptr<SpdySessionPool> spdy_pool = + session_->spdy_session_pool(); + scoped_refptr<SpdySession> spdy_session; if (spdy_pool->HasSession(req_info)) { spdy_session = spdy_pool->Get(req_info, session_); } else { - spdy_session = spdy_pool->GetFlipSessionFromSocket( + spdy_session = spdy_pool->GetSpdySessionFromSocket( req_info, session_, connection_.release()); } diff --git a/net/http/http_network_transaction.h b/net/http/http_network_transaction.h index 8a6d460..c7aec45 100644 --- a/net/http/http_network_transaction.h +++ b/net/http/http_network_transaction.h @@ -29,7 +29,7 @@ namespace net { class ClientSocketFactory; class ClientSocketHandle; -class FlipStream; +class SpdyStream; class HttpNetworkSession; class HttpStream; @@ -290,7 +290,7 @@ class HttpNetworkTransaction : public HttpTransaction { scoped_ptr<ClientSocketHandle> connection_; scoped_ptr<HttpStream> http_stream_; - scoped_refptr<FlipStream> spdy_stream_; + scoped_refptr<SpdyStream> spdy_stream_; bool reused_socket_; // True if we've validated the headers that the stream parser has returned. diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc index f3991ce..73b5082 100644 --- a/net/http/http_network_transaction_unittest.cc +++ b/net/http/http_network_transaction_unittest.cc @@ -42,20 +42,20 @@ class SessionDependencies { : host_resolver(new MockHostResolver), proxy_service(ProxyService::CreateNull()), ssl_config_service(new SSLConfigServiceDefaults), - flip_session_pool(new FlipSessionPool) {} + spdy_session_pool(new SpdySessionPool) {} // Custom proxy service dependency. explicit SessionDependencies(ProxyService* proxy_service) : host_resolver(new MockHostResolver), proxy_service(proxy_service), ssl_config_service(new SSLConfigServiceDefaults), - flip_session_pool(new FlipSessionPool) {} + spdy_session_pool(new SpdySessionPool) {} scoped_refptr<MockHostResolverBase> host_resolver; scoped_refptr<ProxyService> proxy_service; scoped_refptr<SSLConfigService> ssl_config_service; MockClientSocketFactory socket_factory; - scoped_refptr<FlipSessionPool> flip_session_pool; + scoped_refptr<SpdySessionPool> spdy_session_pool; }; ProxyService* CreateFixedProxyService(const std::string& proxy) { @@ -71,7 +71,7 @@ HttpNetworkSession* CreateSession(SessionDependencies* session_deps) { session_deps->proxy_service, &session_deps->socket_factory, session_deps->ssl_config_service, - session_deps->flip_session_pool); + session_deps->spdy_session_pool); } class HttpNetworkTransactionTest : public PlatformTest { diff --git a/net/spdy/spdy_bitmasks.h b/net/spdy/spdy_bitmasks.h index 076a24d..0a7351f 100644 --- a/net/spdy/spdy_bitmasks.h +++ b/net/spdy/spdy_bitmasks.h @@ -5,12 +5,12 @@ #ifndef NET_SPDY_SPDY_BITMASKS_H_ #define NET_SPDY_SPDY_BITMASKS_H_ -namespace flip { +namespace spdy { -// StreamId mask from the FlipHeader +// StreamId mask from the SpdyHeader const unsigned int kStreamIdMask = 0x7fffffff; -// Control flag mask from the FlipHeader +// Control flag mask from the SpdyHeader const unsigned int kControlFlagMask = 0x8000; // Priority mask from the SYN_FRAME @@ -19,6 +19,6 @@ const unsigned int kPriorityMask = 0xc0; // Mask the lower 24 bits. const unsigned int kLengthMask = 0xffffff; -} // flip +} // namespace spdy #endif // NET_SPDY_SPDY_BITMASKS_H_ diff --git a/net/spdy/spdy_frame_builder.cc b/net/spdy/spdy_frame_builder.cc index 7c6333d..5de0830 100644 --- a/net/spdy/spdy_frame_builder.cc +++ b/net/spdy/spdy_frame_builder.cc @@ -7,12 +7,12 @@ #include "net/spdy/spdy_frame_builder.h" #include "net/spdy/spdy_protocol.h" -namespace flip { +namespace spdy { -// We mark a read only FlipFrameBuilder with a special capacity_. +// We mark a read only SpdyFrameBuilder with a special capacity_. static const size_t kCapacityReadOnly = std::numeric_limits<size_t>::max(); -FlipFrameBuilder::FlipFrameBuilder() +SpdyFrameBuilder::SpdyFrameBuilder() : buffer_(NULL), capacity_(0), length_(0), @@ -20,19 +20,19 @@ FlipFrameBuilder::FlipFrameBuilder() Resize(kInitialPayload); } -FlipFrameBuilder::FlipFrameBuilder(const char* data, int data_len) +SpdyFrameBuilder::SpdyFrameBuilder(const char* data, int data_len) : buffer_(const_cast<char*>(data)), capacity_(kCapacityReadOnly), length_(data_len), variable_buffer_offset_(0) { } -FlipFrameBuilder::~FlipFrameBuilder() { +SpdyFrameBuilder::~SpdyFrameBuilder() { if (capacity_ != kCapacityReadOnly) delete[] buffer_; } -bool FlipFrameBuilder::ReadUInt16(void** iter, uint16* result) const { +bool SpdyFrameBuilder::ReadUInt16(void** iter, uint16* result) const { DCHECK(iter); if (!*iter) *iter = const_cast<char*>(buffer_); @@ -46,7 +46,7 @@ bool FlipFrameBuilder::ReadUInt16(void** iter, uint16* result) const { return true; } -bool FlipFrameBuilder::ReadUInt32(void** iter, uint32* result) const { +bool SpdyFrameBuilder::ReadUInt32(void** iter, uint32* result) const { DCHECK(iter); if (!*iter) *iter = const_cast<char*>(buffer_); @@ -60,7 +60,7 @@ bool FlipFrameBuilder::ReadUInt32(void** iter, uint32* result) const { return true; } -bool FlipFrameBuilder::ReadString(void** iter, std::string* result) const { +bool SpdyFrameBuilder::ReadString(void** iter, std::string* result) const { DCHECK(iter); uint16 len; @@ -77,7 +77,7 @@ bool FlipFrameBuilder::ReadString(void** iter, std::string* result) const { return true; } -bool FlipFrameBuilder::ReadBytes(void** iter, const char** data, +bool SpdyFrameBuilder::ReadBytes(void** iter, const char** data, uint16 length) const { DCHECK(iter); DCHECK(data); @@ -91,7 +91,7 @@ bool FlipFrameBuilder::ReadBytes(void** iter, const char** data, return true; } -bool FlipFrameBuilder::ReadData(void** iter, const char** data, +bool SpdyFrameBuilder::ReadData(void** iter, const char** data, uint16* length) const { DCHECK(iter); DCHECK(data); @@ -103,7 +103,7 @@ bool FlipFrameBuilder::ReadData(void** iter, const char** data, return ReadBytes(iter, data, *length); } -char* FlipFrameBuilder::BeginWrite(size_t length) { +char* SpdyFrameBuilder::BeginWrite(size_t length) { size_t offset = length_; size_t needed_size = length_ + length; if (needed_size > capacity_ && !Resize(std::max(capacity_ * 2, needed_size))) @@ -116,10 +116,10 @@ char* FlipFrameBuilder::BeginWrite(size_t length) { return buffer_ + offset; } -void FlipFrameBuilder::EndWrite(char* dest, int length) { +void SpdyFrameBuilder::EndWrite(char* dest, int length) { } -bool FlipFrameBuilder::WriteBytes(const void* data, uint16 data_len) { +bool SpdyFrameBuilder::WriteBytes(const void* data, uint16 data_len) { DCHECK(capacity_ != kCapacityReadOnly); char* dest = BeginWrite(data_len); @@ -133,7 +133,7 @@ bool FlipFrameBuilder::WriteBytes(const void* data, uint16 data_len) { return true; } -bool FlipFrameBuilder::WriteString(const std::string& value) { +bool SpdyFrameBuilder::WriteString(const std::string& value) { if (value.size() > 0xffff) return false; @@ -143,9 +143,9 @@ bool FlipFrameBuilder::WriteString(const std::string& value) { return WriteBytes(value.data(), static_cast<uint16>(value.size())); } -char* FlipFrameBuilder::BeginWriteData(uint16 length) { +char* SpdyFrameBuilder::BeginWriteData(uint16 length) { DCHECK_EQ(variable_buffer_offset_, 0U) << - "There can only be one variable buffer in a FlipFrameBuilder"; + "There can only be one variable buffer in a SpdyFrameBuilder"; if (!WriteUInt16(length)) return false; @@ -162,7 +162,7 @@ char* FlipFrameBuilder::BeginWriteData(uint16 length) { return data_ptr; } -bool FlipFrameBuilder::Resize(size_t new_capacity) { +bool SpdyFrameBuilder::Resize(size_t new_capacity) { if (new_capacity < capacity_) return true; @@ -178,4 +178,4 @@ bool FlipFrameBuilder::Resize(size_t new_capacity) { return true; } -} // namespace flip +} // namespace spdy diff --git a/net/spdy/spdy_frame_builder.h b/net/spdy/spdy_frame_builder.h index 240aae1f..5b70437 100644 --- a/net/spdy/spdy_frame_builder.h +++ b/net/spdy/spdy_frame_builder.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef NET_FLIP_FRAME_BUILDER_H_ -#define NET_FLIP_FRAME_BUILDER_H_ +#ifndef NET_SPDY_FRAME_BUILDER_H_ +#define NET_SPDY_FRAME_BUILDER_H_ #ifdef WIN32 #include <winsock2.h> // for htonl() functions @@ -16,44 +16,44 @@ #include "base/logging.h" #include "net/spdy/spdy_protocol.h" -namespace flip { +namespace spdy { // This class provides facilities for basic binary value packing and unpacking -// into Flip frames. +// into Spdy frames. // -// The FlipFrameBuilder supports appending primitive values (int, string, etc) -// to a frame instance. The FlipFrameBuilder grows its internal memory buffer +// The SpdyFrameBuilder supports appending primitive values (int, string, etc) +// to a frame instance. The SpdyFrameBuilder grows its internal memory buffer // dynamically to hold the sequence of primitive values. The internal memory -// buffer is exposed as the "data" of the FlipFrameBuilder. +// buffer is exposed as the "data" of the SpdyFrameBuilder. // -// When reading from a FlipFrameBuilder the consumer must know what value types -// to read and in what order to read them as the FlipFrameBuilder does not keep +// When reading from a SpdyFrameBuilder the consumer must know what value types +// to read and in what order to read them as the SpdyFrameBuilder does not keep // track of the type of data written to it. -class FlipFrameBuilder { +class SpdyFrameBuilder { public: - FlipFrameBuilder(); - ~FlipFrameBuilder(); + SpdyFrameBuilder(); + ~SpdyFrameBuilder(); - // Initializes a FlipFrameBuilder from a const block of data. The data is + // Initializes a SpdyFrameBuilder from a const block of data. The data is // not copied; instead the data is merely referenced by this - // FlipFrameBuilder. Only const methods should be used when initialized + // SpdyFrameBuilder. Only const methods should be used when initialized // this way. - FlipFrameBuilder(const char* data, int data_len); + SpdyFrameBuilder(const char* data, int data_len); - // Returns the size of the FlipFrameBuilder's data. + // Returns the size of the SpdyFrameBuilder's data. int length() const { return length_; } - // Takes the buffer from the FlipFrameBuilder. - FlipFrame* take() { - FlipFrame* rv = new FlipFrame(buffer_, true); + // Takes the buffer from the SpdyFrameBuilder. + SpdyFrame* take() { + SpdyFrame* rv = new SpdyFrame(buffer_, true); buffer_ = NULL; capacity_ = 0; length_ = 0; return rv; } - // Methods for reading the payload of the FlipFrameBuilder. To read from the - // start of the FlipFrameBuilder, initialize *iter to NULL. If successful, + // Methods for reading the payload of the SpdyFrameBuilder. To read from the + // start of the SpdyFrameBuilder, initialize *iter to NULL. If successful, // these methods return true. Otherwise, false is returned to indicate that // the result could not be extracted. bool ReadUInt16(void** iter, uint16* result) const; @@ -63,7 +63,7 @@ class FlipFrameBuilder { bool ReadData(void** iter, const char** data, uint16* length) const; // Methods for adding to the payload. These values are appended to the end - // of the FlipFrameBuilder payload. When reading values, you must read them + // of the SpdyFrameBuilder payload. When reading values, you must read them // in the order they were added. Note - binary integers are converted from // host to network form. bool WriteUInt16(uint16 value) { @@ -92,14 +92,14 @@ class FlipFrameBuilder { return true; } - // Allows the caller to write data directly into the FlipFrameBuilder. + // Allows the caller to write data directly into the SpdyFrameBuilder. // This saves a copy when the data is not already available in a buffer. // The caller must not write more than the length it declares it will. // Use ReadData to get the data. // Returns NULL on failure. // // The returned pointer will only be valid until the next write operation - // on this FlipFrameBuilder. + // on this SpdyFrameBuilder. char* BeginWriteData(uint16 length); // Returns true if the given iterator could point to data with the given @@ -157,7 +157,7 @@ class FlipFrameBuilder { size_t variable_buffer_offset_; // IF non-zero, then offset to a buffer. }; -} // namespace flip +} // namespace spdy -#endif // NET_FLIP_FRAME_BUILDER_H_ +#endif // NET_SPDY_FRAME_BUILDER_H_ diff --git a/net/spdy/spdy_framer.cc b/net/spdy/spdy_framer.cc index e78b42c..0a5c014 100644 --- a/net/spdy/spdy_framer.cc +++ b/net/spdy/spdy_framer.cc @@ -15,7 +15,7 @@ #include "third_party/zlib/zlib.h" #endif -namespace flip { +namespace spdy { // The initial size of the control frame buffer; this is used internally // as we parse through control frames. @@ -25,9 +25,9 @@ static const size_t kControlFrameBufferInitialSize = 32 * 1024; static const size_t kControlFrameBufferMaxSize = 64 * 1024; // By default is compression on or off. -bool FlipFramer::compression_default_ = true; +bool SpdyFramer::compression_default_ = true; -#ifdef DEBUG_FLIP_STATE_CHANGES +#ifdef DEBUG_SPDY_STATE_CHANGES #define CHANGE_STATE(newstate) \ { \ do { \ @@ -41,9 +41,9 @@ bool FlipFramer::compression_default_ = true; #define CHANGE_STATE(newstate) (state_ = newstate) #endif -FlipFramer::FlipFramer() - : state_(FLIP_RESET), - error_code_(FLIP_NO_ERROR), +SpdyFramer::SpdyFramer() + : state_(SPDY_RESET), + error_code_(SPDY_NO_ERROR), remaining_payload_(0), remaining_control_payload_(0), current_frame_buffer_(NULL), @@ -53,7 +53,7 @@ FlipFramer::FlipFramer() visitor_(NULL) { } -FlipFramer::~FlipFramer() { +SpdyFramer::~SpdyFramer() { if (compressor_.get()) { deflateEnd(compressor_.get()); } @@ -63,9 +63,9 @@ FlipFramer::~FlipFramer() { delete [] current_frame_buffer_; } -void FlipFramer::Reset() { - state_ = FLIP_RESET; - error_code_ = FLIP_NO_ERROR; +void SpdyFramer::Reset() { + state_ = SPDY_RESET; + error_code_ = SPDY_NO_ERROR; remaining_payload_ = 0; remaining_control_payload_ = 0; current_frame_len_ = 0; @@ -77,96 +77,96 @@ void FlipFramer::Reset() { } } -const char* FlipFramer::StateToString(int state) { +const char* SpdyFramer::StateToString(int state) { switch (state) { - case FLIP_ERROR: + case SPDY_ERROR: return "ERROR"; - case FLIP_DONE: + case SPDY_DONE: return "DONE"; - case FLIP_AUTO_RESET: + case SPDY_AUTO_RESET: return "AUTO_RESET"; - case FLIP_RESET: + case SPDY_RESET: return "RESET"; - case FLIP_READING_COMMON_HEADER: + case SPDY_READING_COMMON_HEADER: return "READING_COMMON_HEADER"; - case FLIP_INTERPRET_CONTROL_FRAME_COMMON_HEADER: + case SPDY_INTERPRET_CONTROL_FRAME_COMMON_HEADER: return "INTERPRET_CONTROL_FRAME_COMMON_HEADER"; - case FLIP_CONTROL_FRAME_PAYLOAD: + case SPDY_CONTROL_FRAME_PAYLOAD: return "CONTROL_FRAME_PAYLOAD"; - case FLIP_IGNORE_REMAINING_PAYLOAD: + case SPDY_IGNORE_REMAINING_PAYLOAD: return "IGNORE_REMAINING_PAYLOAD"; - case FLIP_FORWARD_STREAM_FRAME: + case SPDY_FORWARD_STREAM_FRAME: return "FORWARD_STREAM_FRAME"; } return "UNKNOWN_STATE"; } -size_t FlipFramer::BytesSafeToRead() const { +size_t SpdyFramer::BytesSafeToRead() const { switch (state_) { - case FLIP_ERROR: - case FLIP_DONE: - case FLIP_AUTO_RESET: - case FLIP_RESET: + case SPDY_ERROR: + case SPDY_DONE: + case SPDY_AUTO_RESET: + case SPDY_RESET: return 0; - case FLIP_READING_COMMON_HEADER: - DCHECK(current_frame_len_ < FlipFrame::size()); - return FlipFrame::size() - current_frame_len_; - case FLIP_INTERPRET_CONTROL_FRAME_COMMON_HEADER: + case SPDY_READING_COMMON_HEADER: + DCHECK(current_frame_len_ < SpdyFrame::size()); + return SpdyFrame::size() - current_frame_len_; + case SPDY_INTERPRET_CONTROL_FRAME_COMMON_HEADER: return 0; - case FLIP_CONTROL_FRAME_PAYLOAD: - case FLIP_IGNORE_REMAINING_PAYLOAD: - case FLIP_FORWARD_STREAM_FRAME: + case SPDY_CONTROL_FRAME_PAYLOAD: + case SPDY_IGNORE_REMAINING_PAYLOAD: + case SPDY_FORWARD_STREAM_FRAME: return remaining_payload_; } // We should never get to here. return 0; } -void FlipFramer::set_error(FlipError error) { +void SpdyFramer::set_error(SpdyError error) { DCHECK(visitor_); error_code_ = error; - CHANGE_STATE(FLIP_ERROR); + CHANGE_STATE(SPDY_ERROR); visitor_->OnError(this); } -const char* FlipFramer::ErrorCodeToString(int error_code) { +const char* SpdyFramer::ErrorCodeToString(int error_code) { switch (error_code) { - case FLIP_NO_ERROR: + case SPDY_NO_ERROR: return "NO_ERROR"; - case FLIP_UNKNOWN_CONTROL_TYPE: + case SPDY_UNKNOWN_CONTROL_TYPE: return "UNKNOWN_CONTROL_TYPE"; - case FLIP_INVALID_CONTROL_FRAME: + case SPDY_INVALID_CONTROL_FRAME: return "INVALID_CONTROL_FRAME"; - case FLIP_CONTROL_PAYLOAD_TOO_LARGE: + case SPDY_CONTROL_PAYLOAD_TOO_LARGE: return "CONTROL_PAYLOAD_TOO_LARGE"; - case FLIP_ZLIB_INIT_FAILURE: + case SPDY_ZLIB_INIT_FAILURE: return "ZLIB_INIT_FAILURE"; - case FLIP_UNSUPPORTED_VERSION: + case SPDY_UNSUPPORTED_VERSION: return "UNSUPPORTED_VERSION"; - case FLIP_DECOMPRESS_FAILURE: + case SPDY_DECOMPRESS_FAILURE: return "DECOMPRESS_FAILURE"; } return "UNKNOWN_STATE"; } -size_t FlipFramer::ProcessInput(const char* data, size_t len) { +size_t SpdyFramer::ProcessInput(const char* data, size_t len) { DCHECK(visitor_); DCHECK(data); size_t original_len = len; while (len != 0) { switch (state_) { - case FLIP_ERROR: - case FLIP_DONE: + case SPDY_ERROR: + case SPDY_DONE: goto bottom; - case FLIP_AUTO_RESET: - case FLIP_RESET: + case SPDY_AUTO_RESET: + case SPDY_RESET: Reset(); - CHANGE_STATE(FLIP_READING_COMMON_HEADER); + CHANGE_STATE(SPDY_READING_COMMON_HEADER); continue; - case FLIP_READING_COMMON_HEADER: { + case SPDY_READING_COMMON_HEADER: { int bytes_read = ProcessCommonHeader(data, len); len -= bytes_read; data += bytes_read; @@ -176,20 +176,20 @@ size_t FlipFramer::ProcessInput(const char* data, size_t len) { // Arguably, this case is not necessary, as no bytes are consumed here. // I felt it was a nice partitioning, however (which probably indicates // that it should be refactored into its own function!) - case FLIP_INTERPRET_CONTROL_FRAME_COMMON_HEADER: + case SPDY_INTERPRET_CONTROL_FRAME_COMMON_HEADER: ProcessControlFrameHeader(); continue; - case FLIP_CONTROL_FRAME_PAYLOAD: { + case SPDY_CONTROL_FRAME_PAYLOAD: { int bytes_read = ProcessControlFramePayload(data, len); len -= bytes_read; data += bytes_read; } // intentional fallthrough - case FLIP_IGNORE_REMAINING_PAYLOAD: + case SPDY_IGNORE_REMAINING_PAYLOAD: // control frame has too-large payload // intentional fallthrough - case FLIP_FORWARD_STREAM_FRAME: { + case SPDY_FORWARD_STREAM_FRAME: { int bytes_read = ProcessDataFramePayload(data, len); len -= bytes_read; data += bytes_read; @@ -203,17 +203,17 @@ size_t FlipFramer::ProcessInput(const char* data, size_t len) { return original_len - len; } -size_t FlipFramer::ProcessCommonHeader(const char* data, size_t len) { - // This should only be called when we're in the FLIP_READING_COMMON_HEADER +size_t SpdyFramer::ProcessCommonHeader(const char* data, size_t len) { + // This should only be called when we're in the SPDY_READING_COMMON_HEADER // state. - DCHECK(state_ == FLIP_READING_COMMON_HEADER); + DCHECK(state_ == SPDY_READING_COMMON_HEADER); int original_len = len; - FlipFrame current_frame(current_frame_buffer_, false); + SpdyFrame current_frame(current_frame_buffer_, false); do { - if (current_frame_len_ < FlipFrame::size()) { - size_t bytes_desired = FlipFrame::size() - current_frame_len_; + if (current_frame_len_ < SpdyFrame::size()) { + size_t bytes_desired = SpdyFrame::size() - current_frame_len_; size_t bytes_to_append = std::min(bytes_desired, len); char* header_buffer = current_frame_buffer_; memcpy(&header_buffer[current_frame_len_], data, bytes_to_append); @@ -221,14 +221,14 @@ size_t FlipFramer::ProcessCommonHeader(const char* data, size_t len) { data += bytes_to_append; len -= bytes_to_append; // Check for an empty data frame. - if (current_frame_len_ == FlipFrame::size() && + if (current_frame_len_ == SpdyFrame::size() && !current_frame.is_control_frame() && current_frame.length() == 0) { if (current_frame.flags() & CONTROL_FLAG_FIN) { - FlipDataFrame data_frame(current_frame_buffer_, false); + SpdyDataFrame data_frame(current_frame_buffer_, false); visitor_->OnStreamFrameData(data_frame.stream_id(), NULL, 0); } - CHANGE_STATE(FLIP_RESET); + CHANGE_STATE(SPDY_RESET); } break; } @@ -237,65 +237,65 @@ size_t FlipFramer::ProcessCommonHeader(const char* data, size_t len) { // This is just a sanity check for help debugging early frame errors. if (remaining_payload_ > 1000000u) { LOG(ERROR) << - "Unexpectedly large frame. Flip session is likely corrupt."; + "Unexpectedly large frame. Spdy session is likely corrupt."; } // if we're here, then we have the common header all received. if (!current_frame.is_control_frame()) - CHANGE_STATE(FLIP_FORWARD_STREAM_FRAME); + CHANGE_STATE(SPDY_FORWARD_STREAM_FRAME); else - CHANGE_STATE(FLIP_INTERPRET_CONTROL_FRAME_COMMON_HEADER); + CHANGE_STATE(SPDY_INTERPRET_CONTROL_FRAME_COMMON_HEADER); } while (false); return original_len - len; } -void FlipFramer::ProcessControlFrameHeader() { - DCHECK_EQ(FLIP_NO_ERROR, error_code_); - DCHECK_LE(FlipFrame::size(), current_frame_len_); - FlipControlFrame current_control_frame(current_frame_buffer_, false); +void SpdyFramer::ProcessControlFrameHeader() { + DCHECK_EQ(SPDY_NO_ERROR, error_code_); + DCHECK_LE(SpdyFrame::size(), current_frame_len_); + SpdyControlFrame current_control_frame(current_frame_buffer_, false); // Do some sanity checking on the control frame sizes. switch (current_control_frame.type()) { case SYN_STREAM: if (current_control_frame.length() < - FlipSynStreamControlFrame::size() - FlipControlFrame::size()) - set_error(FLIP_INVALID_CONTROL_FRAME); + SpdySynStreamControlFrame::size() - SpdyControlFrame::size()) + set_error(SPDY_INVALID_CONTROL_FRAME); break; case SYN_REPLY: if (current_control_frame.length() < - FlipSynReplyControlFrame::size() - FlipControlFrame::size()) - set_error(FLIP_INVALID_CONTROL_FRAME); + SpdySynReplyControlFrame::size() - SpdyControlFrame::size()) + set_error(SPDY_INVALID_CONTROL_FRAME); break; case FIN_STREAM: if (current_control_frame.length() != - FlipFinStreamControlFrame::size() - FlipFrame::size()) - set_error(FLIP_INVALID_CONTROL_FRAME); + SpdyFinStreamControlFrame::size() - SpdyFrame::size()) + set_error(SPDY_INVALID_CONTROL_FRAME); break; case NOOP: // NOOP. Swallow it. - CHANGE_STATE(FLIP_AUTO_RESET); + CHANGE_STATE(SPDY_AUTO_RESET); return; default: - set_error(FLIP_UNKNOWN_CONTROL_TYPE); + set_error(SPDY_UNKNOWN_CONTROL_TYPE); break; } // We only support version 1 of this protocol. - if (current_control_frame.version() != kFlipProtocolVersion) - set_error(FLIP_UNSUPPORTED_VERSION); + if (current_control_frame.version() != kSpdyProtocolVersion) + set_error(SPDY_UNSUPPORTED_VERSION); remaining_control_payload_ = current_control_frame.length(); if (remaining_control_payload_ > kControlFrameBufferMaxSize) - set_error(FLIP_CONTROL_PAYLOAD_TOO_LARGE); + set_error(SPDY_CONTROL_PAYLOAD_TOO_LARGE); if (error_code_) return; ExpandControlFrameBuffer(remaining_control_payload_); - CHANGE_STATE(FLIP_CONTROL_FRAME_PAYLOAD); + CHANGE_STATE(SPDY_CONTROL_FRAME_PAYLOAD); } -size_t FlipFramer::ProcessControlFramePayload(const char* data, size_t len) { +size_t SpdyFramer::ProcessControlFramePayload(const char* data, size_t len) { size_t original_len = len; do { if (remaining_control_payload_) { @@ -310,7 +310,7 @@ size_t FlipFramer::ProcessControlFramePayload(const char* data, size_t len) { if (remaining_control_payload_) break; } - FlipControlFrame control_frame(current_frame_buffer_, false); + SpdyControlFrame control_frame(current_frame_buffer_, false); visitor_->OnControl(&control_frame); // If this is a FIN, tell the caller. @@ -318,18 +318,18 @@ size_t FlipFramer::ProcessControlFramePayload(const char* data, size_t len) { control_frame.flags() & CONTROL_FLAG_FIN) visitor_->OnStreamFrameData(control_frame.stream_id(), NULL, 0); - CHANGE_STATE(FLIP_IGNORE_REMAINING_PAYLOAD); + CHANGE_STATE(SPDY_IGNORE_REMAINING_PAYLOAD); } while (false); return original_len - len; } -size_t FlipFramer::ProcessDataFramePayload(const char* data, size_t len) { +size_t SpdyFramer::ProcessDataFramePayload(const char* data, size_t len) { size_t original_len = len; - FlipDataFrame current_data_frame(current_frame_buffer_, false); + SpdyDataFrame current_data_frame(current_frame_buffer_, false); if (remaining_payload_) { size_t amount_to_forward = std::min(remaining_payload_, len); - if (amount_to_forward && state_ != FLIP_IGNORE_REMAINING_PAYLOAD) { + if (amount_to_forward && state_ != SPDY_IGNORE_REMAINING_PAYLOAD) { if (current_data_frame.flags() & DATA_FLAG_COMPRESSED) { // TODO(mbelshe): Assert that the decompressor is init'ed. if (!InitializeDecompressor()) @@ -346,7 +346,7 @@ size_t FlipFramer::ProcessDataFramePayload(const char* data, size_t len) { int rv = inflate(decompressor_.get(), Z_SYNC_FLUSH); if (rv != Z_OK) { - set_error(FLIP_DECOMPRESS_FAILURE); + set_error(SPDY_DECOMPRESS_FAILURE); return 0; } size_t decompressed_size = decompressed_max_size - @@ -376,39 +376,39 @@ size_t FlipFramer::ProcessDataFramePayload(const char* data, size_t len) { visitor_->OnStreamFrameData(current_data_frame.stream_id(), NULL, 0); } else { - CHANGE_STATE(FLIP_AUTO_RESET); + CHANGE_STATE(SPDY_AUTO_RESET); } return original_len - len; } -void FlipFramer::ExpandControlFrameBuffer(size_t size) { +void SpdyFramer::ExpandControlFrameBuffer(size_t size) { DCHECK(size < kControlFrameBufferMaxSize); if (size < current_frame_capacity_) return; - int alloc_size = size + FlipFrame::size(); + int alloc_size = size + SpdyFrame::size(); char* new_buffer = new char[alloc_size]; memcpy(new_buffer, current_frame_buffer_, current_frame_len_); current_frame_capacity_ = alloc_size; current_frame_buffer_ = new_buffer; } -bool FlipFramer::ParseHeaderBlock(const FlipFrame* frame, - FlipHeaderBlock* block) { - FlipControlFrame control_frame(frame->data(), false); +bool SpdyFramer::ParseHeaderBlock(const SpdyFrame* frame, + SpdyHeaderBlock* block) { + SpdyControlFrame control_frame(frame->data(), false); uint32 type = control_frame.type(); if (type != SYN_STREAM && type != SYN_REPLY) return false; // Find the header data within the control frame. - scoped_ptr<FlipFrame> decompressed_frame(DecompressFrame(frame)); + scoped_ptr<SpdyFrame> decompressed_frame(DecompressFrame(frame)); if (!decompressed_frame.get()) return false; - FlipSynStreamControlFrame syn_frame(decompressed_frame->data(), false); + SpdySynStreamControlFrame syn_frame(decompressed_frame->data(), false); const char *header_data = syn_frame.header_block(); int header_length = syn_frame.header_block_len(); - FlipFrameBuilder builder(header_data, header_length); + SpdyFrameBuilder builder(header_data, header_length); void* iter = NULL; uint16 num_headers; if (builder.ReadUInt16(&iter, &num_headers)) { @@ -430,65 +430,65 @@ bool FlipFramer::ParseHeaderBlock(const FlipFrame* frame, return false; } -FlipSynStreamControlFrame* FlipFramer::CreateSynStream( - FlipStreamId stream_id, int priority, FlipControlFlags flags, - bool compressed, FlipHeaderBlock* headers) { - FlipFrameBuilder frame; +SpdySynStreamControlFrame* SpdyFramer::CreateSynStream( + SpdyStreamId stream_id, int priority, SpdyControlFlags flags, + bool compressed, SpdyHeaderBlock* headers) { + SpdyFrameBuilder frame; - frame.WriteUInt16(kControlFlagMask | kFlipProtocolVersion); + frame.WriteUInt16(kControlFlagMask | kSpdyProtocolVersion); frame.WriteUInt16(SYN_STREAM); frame.WriteUInt32(0); // Placeholder for the length and flags frame.WriteUInt32(stream_id); frame.WriteUInt16(ntohs(priority) << 6); // Priority. frame.WriteUInt16(headers->size()); // Number of headers. - FlipHeaderBlock::iterator it; + SpdyHeaderBlock::iterator it; for (it = headers->begin(); it != headers->end(); ++it) { frame.WriteString(it->first); frame.WriteString(it->second); } // Write the length and flags. - size_t length = frame.length() - FlipFrame::size(); + size_t length = frame.length() - SpdyFrame::size(); DCHECK(length < static_cast<size_t>(kLengthMask)); FlagsAndLength flags_length; flags_length.length_ = htonl(static_cast<uint32>(length)); flags_length.flags_[0] = flags; frame.WriteBytesToOffset(4, &flags_length, sizeof(flags_length)); - scoped_ptr<FlipFrame> syn_frame(frame.take()); + scoped_ptr<SpdyFrame> syn_frame(frame.take()); if (compressed) { - return reinterpret_cast<FlipSynStreamControlFrame*>( + return reinterpret_cast<SpdySynStreamControlFrame*>( CompressFrame(syn_frame.get())); } - return reinterpret_cast<FlipSynStreamControlFrame*>(syn_frame.release()); + return reinterpret_cast<SpdySynStreamControlFrame*>(syn_frame.release()); } /* static */ -FlipFinStreamControlFrame* FlipFramer::CreateFinStream(FlipStreamId stream_id, +SpdyFinStreamControlFrame* SpdyFramer::CreateFinStream(SpdyStreamId stream_id, int status) { - FlipFrameBuilder frame; - frame.WriteUInt16(kControlFlagMask | kFlipProtocolVersion); + SpdyFrameBuilder frame; + frame.WriteUInt16(kControlFlagMask | kSpdyProtocolVersion); frame.WriteUInt16(FIN_STREAM); frame.WriteUInt32(8); frame.WriteUInt32(stream_id); frame.WriteUInt32(status); - return reinterpret_cast<FlipFinStreamControlFrame*>(frame.take()); + return reinterpret_cast<SpdyFinStreamControlFrame*>(frame.take()); } -FlipSynReplyControlFrame* FlipFramer::CreateSynReply(FlipStreamId stream_id, - FlipControlFlags flags, bool compressed, FlipHeaderBlock* headers) { +SpdySynReplyControlFrame* SpdyFramer::CreateSynReply(SpdyStreamId stream_id, + SpdyControlFlags flags, bool compressed, SpdyHeaderBlock* headers) { - FlipFrameBuilder frame; + SpdyFrameBuilder frame; - frame.WriteUInt16(kControlFlagMask | kFlipProtocolVersion); + frame.WriteUInt16(kControlFlagMask | kSpdyProtocolVersion); frame.WriteUInt16(SYN_REPLY); frame.WriteUInt32(0); // Placeholder for the length and flags. frame.WriteUInt32(stream_id); frame.WriteUInt16(0); // Unused frame.WriteUInt16(headers->size()); // Number of headers. - FlipHeaderBlock::iterator it; + SpdyHeaderBlock::iterator it; for (it = headers->begin(); it != headers->end(); ++it) { // TODO(mbelshe): Headers need to be sorted. frame.WriteString(it->first); @@ -496,25 +496,25 @@ FlipSynReplyControlFrame* FlipFramer::CreateSynReply(FlipStreamId stream_id, } // Write the length - size_t length = frame.length() - FlipFrame::size(); + size_t length = frame.length() - SpdyFrame::size(); DCHECK(length < static_cast<size_t>(kLengthMask)); FlagsAndLength flags_length; flags_length.length_ = htonl(static_cast<uint32>(length)); flags_length.flags_[0] = flags; frame.WriteBytesToOffset(4, &flags_length, sizeof(flags_length)); - scoped_ptr<FlipFrame> reply_frame(frame.take()); + scoped_ptr<SpdyFrame> reply_frame(frame.take()); if (compressed) { - return reinterpret_cast<FlipSynReplyControlFrame*>( + return reinterpret_cast<SpdySynReplyControlFrame*>( CompressFrame(reply_frame.get())); } - return reinterpret_cast<FlipSynReplyControlFrame*>(reply_frame.release()); + return reinterpret_cast<SpdySynReplyControlFrame*>(reply_frame.release()); } -FlipDataFrame* FlipFramer::CreateDataFrame(FlipStreamId stream_id, +SpdyDataFrame* SpdyFramer::CreateDataFrame(SpdyStreamId stream_id, const char* data, - uint32 len, FlipDataFlags flags) { - FlipFrameBuilder frame; + uint32 len, SpdyDataFlags flags) { + SpdyFrameBuilder frame; frame.WriteUInt32(stream_id); @@ -525,19 +525,19 @@ FlipDataFrame* FlipFramer::CreateDataFrame(FlipStreamId stream_id, frame.WriteBytes(&flags_length, sizeof(flags_length)); frame.WriteBytes(data, len); - scoped_ptr<FlipFrame> data_frame(frame.take()); + scoped_ptr<SpdyFrame> data_frame(frame.take()); if (flags & DATA_FLAG_COMPRESSED) - return reinterpret_cast<FlipDataFrame*>(CompressFrame(data_frame.get())); - return reinterpret_cast<FlipDataFrame*>(data_frame.release()); + return reinterpret_cast<SpdyDataFrame*>(CompressFrame(data_frame.get())); + return reinterpret_cast<SpdyDataFrame*>(data_frame.release()); } /* static */ -FlipControlFrame* FlipFramer::CreateNopFrame() { - FlipFrameBuilder frame; - frame.WriteUInt16(kControlFlagMask | kFlipProtocolVersion); +SpdyControlFrame* SpdyFramer::CreateNopFrame() { + SpdyFrameBuilder frame; + frame.WriteUInt16(kControlFlagMask | kSpdyProtocolVersion); frame.WriteUInt16(NOOP); frame.WriteUInt32(0); - return reinterpret_cast<FlipControlFrame*>(frame.take()); + return reinterpret_cast<SpdyControlFrame*>(frame.take()); } static const int kCompressorLevel = Z_DEFAULT_COMPRESSION; @@ -559,7 +559,7 @@ static const char dictionary[] = ".1statusversionurl"; static uLong dictionary_id = 0; -bool FlipFramer::InitializeCompressor() { +bool SpdyFramer::InitializeCompressor() { if (compressor_.get()) return true; // Already initialized. @@ -576,7 +576,7 @@ bool FlipFramer::InitializeCompressor() { return success == Z_OK; } -bool FlipFramer::InitializeDecompressor() { +bool SpdyFramer::InitializeDecompressor() { if (decompressor_.get()) return true; // Already initialized. @@ -598,19 +598,19 @@ bool FlipFramer::InitializeDecompressor() { return success == Z_OK; } -bool FlipFramer::GetFrameBoundaries(const FlipFrame* frame, +bool SpdyFramer::GetFrameBoundaries(const SpdyFrame* frame, int* payload_length, int* header_length, const char** payload) const { if (frame->is_control_frame()) { - const FlipControlFrame* control_frame = - reinterpret_cast<const FlipControlFrame*>(frame); + const SpdyControlFrame* control_frame = + reinterpret_cast<const SpdyControlFrame*>(frame); switch (control_frame->type()) { case SYN_STREAM: case SYN_REPLY: { - const FlipSynStreamControlFrame *syn_frame = - reinterpret_cast<const FlipSynStreamControlFrame*>(frame); + const SpdySynStreamControlFrame *syn_frame = + reinterpret_cast<const SpdySynStreamControlFrame*>(frame); *payload_length = syn_frame->header_block_len(); *header_length = syn_frame->size(); *payload = frame->data() + *header_length; @@ -621,23 +621,23 @@ bool FlipFramer::GetFrameBoundaries(const FlipFrame* frame, return false; // We can't compress this frame! } } else { - *header_length = FlipFrame::size(); + *header_length = SpdyFrame::size(); *payload_length = frame->length(); - *payload = frame->data() + FlipFrame::size(); + *payload = frame->data() + SpdyFrame::size(); } DCHECK(static_cast<size_t>(*header_length) <= - FlipFrame::size() + *payload_length); + SpdyFrame::size() + *payload_length); return true; } -FlipFrame* FlipFramer::CompressFrame(const FlipFrame* frame) { +SpdyFrame* SpdyFramer::CompressFrame(const SpdyFrame* frame) { int payload_length; int header_length; const char* payload; - static StatsCounter pre_compress_bytes("flip.PreCompressSize"); - static StatsCounter post_compress_bytes("flip.PostCompressSize"); + static StatsCounter pre_compress_bytes("spdy.PreCompressSize"); + static StatsCounter post_compress_bytes("spdy.PostCompressSize"); if (!enable_compression_) return DuplicateFrame(frame); @@ -653,8 +653,8 @@ FlipFrame* FlipFramer::CompressFrame(const FlipFrame* frame) { // Create an output frame. int compressed_max_size = deflateBound(compressor_.get(), payload_length); int new_frame_size = header_length + compressed_max_size; - FlipFrame* new_frame = new FlipFrame(new_frame_size); - memcpy(new_frame->data(), frame->data(), frame->length() + FlipFrame::size()); + SpdyFrame* new_frame = new SpdyFrame(new_frame_size); + memcpy(new_frame->data(), frame->data(), frame->length() + SpdyFrame::size()); compressor_->next_in = reinterpret_cast<Bytef*>(const_cast<char*>(payload)); compressor_->avail_in = payload_length; @@ -664,7 +664,7 @@ FlipFrame* FlipFramer::CompressFrame(const FlipFrame* frame) { // Data packets have a 'compressed flag if (!new_frame->is_control_frame()) { - FlipDataFrame* data_frame = reinterpret_cast<FlipDataFrame*>(new_frame); + SpdyDataFrame* data_frame = reinterpret_cast<SpdyDataFrame*>(new_frame); data_frame->set_flags(data_frame->flags() | DATA_FLAG_COMPRESSED); } @@ -676,7 +676,7 @@ 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()); + new_frame->set_length(header_length + compressed_size - SpdyFrame::size()); pre_compress_bytes.Add(payload_length); post_compress_bytes.Add(new_frame->length()); @@ -684,13 +684,13 @@ FlipFrame* FlipFramer::CompressFrame(const FlipFrame* frame) { return new_frame; } -FlipFrame* FlipFramer::DecompressFrame(const FlipFrame* frame) { +SpdyFrame* SpdyFramer::DecompressFrame(const SpdyFrame* frame) { int payload_length; int header_length; const char* payload; - static StatsCounter pre_decompress_bytes("flip.PreDeCompressSize"); - static StatsCounter post_decompress_bytes("flip.PostDeCompressSize"); + static StatsCounter pre_decompress_bytes("spdy.PreDeCompressSize"); + static StatsCounter post_decompress_bytes("spdy.PostDeCompressSize"); if (!enable_compression_) return DuplicateFrame(frame); @@ -699,8 +699,8 @@ FlipFrame* FlipFramer::DecompressFrame(const FlipFrame* frame) { return NULL; if (!frame->is_control_frame()) { - const FlipDataFrame* data_frame = - reinterpret_cast<const FlipDataFrame*>(frame); + const SpdyDataFrame* data_frame = + reinterpret_cast<const SpdyDataFrame*>(frame); if ((data_frame->flags() & DATA_FLAG_COMPRESSED) == 0) return DuplicateFrame(frame); } @@ -714,8 +714,8 @@ FlipFrame* FlipFramer::DecompressFrame(const FlipFrame* frame) { // the input data. int decompressed_max_size = kControlFrameBufferInitialSize; int new_frame_size = header_length + decompressed_max_size; - FlipFrame* new_frame = new FlipFrame(new_frame_size); - memcpy(new_frame->data(), frame->data(), frame->length() + FlipFrame::size()); + SpdyFrame* new_frame = new SpdyFrame(new_frame_size); + memcpy(new_frame->data(), frame->data(), frame->length() + SpdyFrame::size()); decompressor_->next_in = reinterpret_cast<Bytef*>(const_cast<char*>(payload)); decompressor_->avail_in = payload_length; @@ -740,12 +740,12 @@ FlipFrame* FlipFramer::DecompressFrame(const FlipFrame* frame) { // Unset the compressed flag for data frames. if (!new_frame->is_control_frame()) { - FlipDataFrame* data_frame = reinterpret_cast<FlipDataFrame*>(new_frame); + SpdyDataFrame* data_frame = reinterpret_cast<SpdyDataFrame*>(new_frame); data_frame->set_flags(data_frame->flags() & ~DATA_FLAG_COMPRESSED); } int decompressed_size = decompressed_max_size - decompressor_->avail_out; - new_frame->set_length(header_length + decompressed_size - FlipFrame::size()); + new_frame->set_length(header_length + decompressed_size - SpdyFrame::size()); pre_decompress_bytes.Add(frame->length()); post_decompress_bytes.Add(new_frame->length()); @@ -753,20 +753,20 @@ FlipFrame* FlipFramer::DecompressFrame(const FlipFrame* frame) { return new_frame; } -FlipFrame* FlipFramer::DuplicateFrame(const FlipFrame* frame) { - int size = FlipFrame::size() + frame->length(); - FlipFrame* new_frame = new FlipFrame(size); +SpdyFrame* SpdyFramer::DuplicateFrame(const SpdyFrame* frame) { + int size = SpdyFrame::size() + frame->length(); + SpdyFrame* new_frame = new SpdyFrame(size); memcpy(new_frame->data(), frame->data(), size); return new_frame; } -void FlipFramer::set_enable_compression(bool value) { +void SpdyFramer::set_enable_compression(bool value) { enable_compression_ = value; } -void FlipFramer::set_enable_compression_default(bool value) { +void SpdyFramer::set_enable_compression_default(bool value) { compression_default_ = value; } -} // namespace flip +} // namespace spdy diff --git a/net/spdy/spdy_framer.h b/net/spdy/spdy_framer.h index 668e1f3..c431f67 100644 --- a/net/spdy/spdy_framer.h +++ b/net/spdy/spdy_framer.h @@ -22,36 +22,36 @@ typedef struct z_stream_s z_stream; // Forward declaration for zlib. namespace net { -class FlipNetworkTransactionTest; class HttpNetworkLayer; +class SpdyNetworkTransactionTest; } -namespace flip { +namespace spdy { -class FlipFramer; -class FlipFramerTest; +class SpdyFramer; +class SpdyFramerTest; namespace test { -class TestFlipVisitor; -void FramerSetEnableCompressionHelper(FlipFramer* framer, bool compress); +class TestSpdyVisitor; +void FramerSetEnableCompressionHelper(SpdyFramer* framer, bool compress); } // namespace test // A datastructure for holding a set of headers from either a // SYN_STREAM or SYN_REPLY frame. -typedef std::map<std::string, std::string> FlipHeaderBlock; +typedef std::map<std::string, std::string> SpdyHeaderBlock; -// FlipFramerVisitorInterface is a set of callbacks for the FlipFramer. +// SpdyFramerVisitorInterface is a set of callbacks for the SpdyFramer. // Implement this interface to receive event callbacks as frames are // decoded from the framer. -class FlipFramerVisitorInterface { +class SpdyFramerVisitorInterface { public: - virtual ~FlipFramerVisitorInterface() {} + virtual ~SpdyFramerVisitorInterface() {} - // Called if an error is detected in the FlipFrame protocol. - virtual void OnError(FlipFramer* framer) = 0; + // Called if an error is detected in the SpdyFrame protocol. + virtual void OnError(SpdyFramer* framer) = 0; // Called when a Control Frame is received. - virtual void OnControl(const FlipControlFrame* frame) = 0; + virtual void OnControl(const SpdyControlFrame* frame) = 0; // Called when data is received. // |stream_id| The stream receiving data. @@ -59,48 +59,48 @@ class FlipFramerVisitorInterface { // |len| The length of the data buffer. // When the other side has finished sending data on this stream, // this method will be called with a zero-length buffer. - virtual void OnStreamFrameData(flip::FlipStreamId stream_id, + virtual void OnStreamFrameData(spdy::SpdyStreamId stream_id, const char* data, size_t len) = 0; }; -class FlipFramer { +class SpdyFramer { public: - // Flip states. + // SPDY states. // TODO(mbelshe): Can we move these into the implementation // and avoid exposing through the header. (Needed for test) - enum FlipState { - FLIP_ERROR, - FLIP_DONE, - FLIP_RESET, - FLIP_AUTO_RESET, - FLIP_READING_COMMON_HEADER, - FLIP_INTERPRET_CONTROL_FRAME_COMMON_HEADER, - FLIP_CONTROL_FRAME_PAYLOAD, - FLIP_IGNORE_REMAINING_PAYLOAD, - FLIP_FORWARD_STREAM_FRAME + enum SpdyState { + SPDY_ERROR, + SPDY_DONE, + SPDY_RESET, + SPDY_AUTO_RESET, + SPDY_READING_COMMON_HEADER, + SPDY_INTERPRET_CONTROL_FRAME_COMMON_HEADER, + SPDY_CONTROL_FRAME_PAYLOAD, + SPDY_IGNORE_REMAINING_PAYLOAD, + SPDY_FORWARD_STREAM_FRAME }; - // Flip error codes. - enum FlipError { - FLIP_NO_ERROR, - FLIP_UNKNOWN_CONTROL_TYPE, // Control frame is an unknown type. - FLIP_INVALID_CONTROL_FRAME, // Control frame is mal-formatted. - FLIP_CONTROL_PAYLOAD_TOO_LARGE, // Control frame payload was too large. - FLIP_ZLIB_INIT_FAILURE, // The Zlib library could not initialize. - FLIP_UNSUPPORTED_VERSION, // Control frame has unsupported version. - FLIP_DECOMPRESS_FAILURE, // There was an error decompressing. + // SPDY error codes. + enum SpdyError { + SPDY_NO_ERROR, + SPDY_UNKNOWN_CONTROL_TYPE, // Control frame is an unknown type. + SPDY_INVALID_CONTROL_FRAME, // Control frame is mal-formatted. + SPDY_CONTROL_PAYLOAD_TOO_LARGE, // Control frame payload was too large. + SPDY_ZLIB_INIT_FAILURE, // The Zlib library could not initialize. + SPDY_UNSUPPORTED_VERSION, // Control frame has unsupported version. + SPDY_DECOMPRESS_FAILURE, // There was an error decompressing. }; // Create a new Framer. - FlipFramer(); - virtual ~FlipFramer(); + SpdyFramer(); + virtual ~SpdyFramer(); // Set callbacks to be called from the framer. A visitor must be set, or // else the framer will likely crash. It is acceptable for the visitor // to do nothing. If this is called multiple times, only the last visitor // will be used. - void set_visitor(FlipFramerVisitorInterface* visitor) { + void set_visitor(SpdyFramerVisitorInterface* visitor) { visitor_ = visitor; } @@ -114,46 +114,46 @@ class FlipFramer { void Reset(); // Check the state of the framer. - FlipError error_code() const { return error_code_; } - FlipState state() const { return state_; } + SpdyError error_code() const { return error_code_; } + SpdyState state() const { return state_; } bool MessageFullyRead() { - return state_ == FLIP_DONE || state_ == FLIP_AUTO_RESET; + return state_ == SPDY_DONE || state_ == SPDY_AUTO_RESET; } - bool HasError() { return state_ == FLIP_ERROR; } + bool HasError() { return state_ == SPDY_ERROR; } // Further parsing utilities. - // Given a control frame, parse out a FlipHeaderBlock. Only + // Given a control frame, parse out a SpdyHeaderBlock. Only // valid for SYN_STREAM and SYN_REPLY frames. // Returns true if successfully parsed, false otherwise. - bool ParseHeaderBlock(const FlipFrame* frame, FlipHeaderBlock* block); + bool ParseHeaderBlock(const SpdyFrame* frame, SpdyHeaderBlock* block); - // Create a FlipSynStreamControlFrame. + // Create a SpdySynStreamControlFrame. // |stream_id| is the stream for this frame. // |priority| is the priority (0-3) for this frame. // |flags| is the flags to use with the data. // To mark this frame as the last frame, enable CONTROL_FLAG_FIN. // |compressed| specifies whether the frame should be compressed. // |headers| is the header block to include in the frame. - FlipSynStreamControlFrame* CreateSynStream(FlipStreamId stream_id, + SpdySynStreamControlFrame* CreateSynStream(SpdyStreamId stream_id, int priority, - FlipControlFlags flags, + SpdyControlFlags flags, bool compressed, - FlipHeaderBlock* headers); + SpdyHeaderBlock* headers); - static FlipFinStreamControlFrame* CreateFinStream(FlipStreamId stream_id, + static SpdyFinStreamControlFrame* CreateFinStream(SpdyStreamId stream_id, int status); - // Create a FlipSynReplyControlFrame. + // Create a SpdySynReplyControlFrame. // |stream_id| is the stream for this frame. // |flags| is the flags to use with the data. // To mark this frame as the last frame, enable CONTROL_FLAG_FIN. // |compressed| specifies whether the frame should be compressed. // |headers| is the header block to include in the frame. - FlipSynReplyControlFrame* CreateSynReply(FlipStreamId stream_id, - FlipControlFlags flags, + SpdySynReplyControlFrame* CreateSynReply(SpdyStreamId stream_id, + SpdyControlFlags flags, bool compressed, - FlipHeaderBlock* headers); + SpdyHeaderBlock* headers); // Create a data frame. // |stream_id| is the stream for this frame @@ -162,13 +162,13 @@ class FlipFramer { // |flags| is the flags to use with the data. // To create a compressed frame, enable DATA_FLAG_COMPRESSED. // To mark this frame as the last data frame, enable DATA_FLAG_FIN. - FlipDataFrame* CreateDataFrame(FlipStreamId stream_id, const char* data, - uint32 len, FlipDataFlags flags); + SpdyDataFrame* CreateDataFrame(SpdyStreamId stream_id, const char* data, + uint32 len, SpdyDataFlags flags); - static FlipControlFrame* CreateNopFrame(); + static SpdyControlFrame* CreateNopFrame(); // NOTES about frame compression. - // We want flip to compress headers across the entire session. As long as + // We want spdy to compress headers across the entire session. As long as // the session is over TCP, frames are sent serially. The client & server // can each compress frames in the same order and then compress them in that // order, and the remote can do the reverse. However, we ultimately want @@ -178,33 +178,33 @@ class FlipFramer { // not build its state in a serial (stream based) manner.... For now, we're // using zlib anyway. - // Compresses a FlipFrame. - // On success, returns a new FlipFrame with the payload compressed. - // Compression state is maintained as part of the FlipFramer. + // Compresses a SpdyFrame. + // On success, returns a new SpdyFrame with the payload compressed. + // Compression state is maintained as part of the SpdyFramer. // Returned frame must be freed with free(). // On failure, returns NULL. - FlipFrame* CompressFrame(const FlipFrame* frame); + SpdyFrame* CompressFrame(const SpdyFrame* frame); - // Decompresses a FlipFrame. - // On success, returns a new FlipFrame with the payload decompressed. - // Compression state is maintained as part of the FlipFramer. + // Decompresses a SpdyFrame. + // On success, returns a new SpdyFrame with the payload decompressed. + // Compression state is maintained as part of the SpdyFramer. // Returned frame must be freed with free(). // On failure, returns NULL. - FlipFrame* DecompressFrame(const FlipFrame* frame); + SpdyFrame* DecompressFrame(const SpdyFrame* frame); // Create a copy of a frame. - FlipFrame* DuplicateFrame(const FlipFrame* frame); + SpdyFrame* DuplicateFrame(const SpdyFrame* frame); // For debugging. static const char* StateToString(int state); static const char* ErrorCodeToString(int error_code); protected: - FRIEND_TEST(FlipFramerTest, HeaderBlockBarfsOnOutOfOrderHeaders); - friend class net::FlipNetworkTransactionTest; + FRIEND_TEST(SpdyFramerTest, HeaderBlockBarfsOnOutOfOrderHeaders); + friend class net::SpdyNetworkTransactionTest; friend class net::HttpNetworkLayer; // This is temporary for the server. - friend class test::TestFlipVisitor; - friend void test::FramerSetEnableCompressionHelper(FlipFramer* framer, + friend class test::TestSpdyVisitor; + friend void test::FramerSetEnableCompressionHelper(SpdyFramer* framer, bool compress); // For ease of testing we can tweak compression on/off. @@ -227,18 +227,18 @@ class FlipFramer { size_t BytesSafeToRead() const; // Set the error code and moves the framer into the error state. - void set_error(FlipError error); + void set_error(SpdyError error); // Expands the control frame buffer to accomodate a particular payload size. void ExpandControlFrameBuffer(size_t size); // Given a frame, breakdown the variable payload length, the static header // header length, and variable payload pointer. - bool GetFrameBoundaries(const FlipFrame* frame, int* payload_length, + bool GetFrameBoundaries(const SpdyFrame* frame, int* payload_length, int* header_length, const char** payload) const; - FlipState state_; - FlipError error_code_; + SpdyState state_; + SpdyError error_code_; size_t remaining_payload_; size_t remaining_control_payload_; @@ -249,12 +249,12 @@ class FlipFramer { bool enable_compression_; scoped_ptr<z_stream> compressor_; scoped_ptr<z_stream> decompressor_; - FlipFramerVisitorInterface* visitor_; + SpdyFramerVisitorInterface* visitor_; static bool compression_default_; }; -} // namespace flip +} // namespace spdy #endif // NET_SPDY_SPDY_FRAMER_H_ diff --git a/net/spdy/spdy_framer_test.cc b/net/spdy/spdy_framer_test.cc index 21f2e68..b4e09cb 100644 --- a/net/spdy/spdy_framer_test.cc +++ b/net/spdy/spdy_framer_test.cc @@ -11,17 +11,17 @@ #include "net/spdy/spdy_frame_builder.h" #include "testing/platform_test.h" -namespace flip { +namespace spdy { namespace test { -void FramerSetEnableCompressionHelper(FlipFramer* framer, bool compress) { +void FramerSetEnableCompressionHelper(SpdyFramer* framer, bool compress) { framer->set_enable_compression(compress); } -class TestFlipVisitor : public FlipFramerVisitorInterface { +class TestSpdyVisitor : public SpdyFramerVisitorInterface { public: - TestFlipVisitor() + TestSpdyVisitor() : error_count_(0), syn_frame_count_(0), syn_reply_frame_count_(0), @@ -31,11 +31,11 @@ class TestFlipVisitor : public FlipFramerVisitorInterface { zero_length_data_frame_count_(0) { } - void OnError(FlipFramer* f) { + void OnError(SpdyFramer* f) { error_count_++; } - void OnStreamFrameData(FlipStreamId stream_id, + void OnStreamFrameData(SpdyStreamId stream_id, const char* data, size_t len) { if (len == 0) @@ -51,8 +51,8 @@ class TestFlipVisitor : public FlipFramerVisitorInterface { std::cerr << "\", " << len << ")\n"; } - void OnControl(const FlipControlFrame* frame) { - FlipHeaderBlock headers; + void OnControl(const SpdyControlFrame* frame) { + SpdyHeaderBlock headers; bool parsed_headers = false; switch (frame->type()) { case SYN_STREAM: @@ -82,7 +82,7 @@ class TestFlipVisitor : public FlipFramerVisitorInterface { size_t input_remaining = size; const char* input_ptr = reinterpret_cast<const char*>(input); while (input_remaining > 0 && - framer_.error_code() == FlipFramer::FLIP_NO_ERROR) { + framer_.error_code() == SpdyFramer::SPDY_NO_ERROR) { // To make the tests more interesting, we feed random (amd small) chunks // into the framer. This simulates getting strange-sized reads from // the socket. @@ -92,12 +92,12 @@ class TestFlipVisitor : public FlipFramerVisitorInterface { size_t bytes_processed = framer_.ProcessInput(input_ptr, bytes_read); input_remaining -= bytes_processed; input_ptr += bytes_processed; - if (framer_.state() == FlipFramer::FLIP_DONE) + if (framer_.state() == SpdyFramer::SPDY_DONE) framer_.Reset(); } } - FlipFramer framer_; + SpdyFramer framer_; // Counters from the visitor callbacks. int error_count_; int syn_frame_count_; @@ -110,39 +110,39 @@ class TestFlipVisitor : public FlipFramerVisitorInterface { } // namespace test -} // namespace flip +} // namespace spdy -using flip::FlipFrame; -using flip::FlipFrameBuilder; -using flip::FlipFramer; -using flip::FlipHeaderBlock; -using flip::FlipSynStreamControlFrame; -using flip::kControlFlagMask; -using flip::CONTROL_FLAG_NONE; -using flip::SYN_STREAM; -using flip::test::FramerSetEnableCompressionHelper; -using flip::test::TestFlipVisitor; +using spdy::SpdyFrame; +using spdy::SpdyFrameBuilder; +using spdy::SpdyFramer; +using spdy::SpdyHeaderBlock; +using spdy::SpdySynStreamControlFrame; +using spdy::kControlFlagMask; +using spdy::CONTROL_FLAG_NONE; +using spdy::SYN_STREAM; +using spdy::test::FramerSetEnableCompressionHelper; +using spdy::test::TestSpdyVisitor; namespace { -class FlipFramerTest : public PlatformTest { +class SpdyFramerTest : public PlatformTest { public: virtual void TearDown() {} }; -// Test that we can encode and decode a FlipHeaderBlock. -TEST_F(FlipFramerTest, HeaderBlock) { - FlipHeaderBlock headers; +// Test that we can encode and decode a SpdyHeaderBlock. +TEST_F(SpdyFramerTest, HeaderBlock) { + SpdyHeaderBlock headers; headers["alpha"] = "beta"; headers["gamma"] = "charlie"; - FlipFramer framer; + SpdyFramer framer; // Encode the header block into a SynStream frame. - scoped_ptr<FlipSynStreamControlFrame> frame( + scoped_ptr<SpdySynStreamControlFrame> frame( framer.CreateSynStream(1, 1, CONTROL_FLAG_NONE, true, &headers)); EXPECT_TRUE(frame.get() != NULL); - FlipHeaderBlock new_headers; + SpdyHeaderBlock new_headers; framer.ParseHeaderBlock(frame.get(), &new_headers); EXPECT_EQ(headers.size(), new_headers.size()); @@ -150,8 +150,8 @@ TEST_F(FlipFramerTest, HeaderBlock) { EXPECT_EQ(headers["gamma"], new_headers["gamma"]); } -TEST_F(FlipFramerTest, OutOfOrderHeaders) { - FlipFrameBuilder frame; +TEST_F(SpdyFramerTest, OutOfOrderHeaders) { + SpdyFrameBuilder frame; frame.WriteUInt16(kControlFlagMask | 1); frame.WriteUInt16(SYN_STREAM); @@ -160,23 +160,23 @@ TEST_F(FlipFramerTest, OutOfOrderHeaders) { frame.WriteUInt16(0); // Priority. frame.WriteUInt16(2); // Number of headers. - FlipHeaderBlock::iterator it; + SpdyHeaderBlock::iterator it; frame.WriteString("gamma"); frame.WriteString("gamma"); frame.WriteString("alpha"); frame.WriteString("alpha"); // write the length - frame.WriteUInt32ToOffset(4, frame.length() - FlipFrame::size()); + frame.WriteUInt32ToOffset(4, frame.length() - SpdyFrame::size()); - FlipHeaderBlock new_headers; - scoped_ptr<FlipFrame> control_frame(frame.take()); - FlipFramer framer; + SpdyHeaderBlock new_headers; + scoped_ptr<SpdyFrame> control_frame(frame.take()); + SpdyFramer framer; FramerSetEnableCompressionHelper(&framer, false); EXPECT_TRUE(framer.ParseHeaderBlock(control_frame.get(), &new_headers)); } -TEST_F(FlipFramerTest, DuplicateHeader) { - FlipFrameBuilder frame; +TEST_F(SpdyFramerTest, DuplicateHeader) { + SpdyFrameBuilder frame; frame.WriteUInt16(kControlFlagMask | 1); frame.WriteUInt16(SYN_STREAM); @@ -185,24 +185,24 @@ TEST_F(FlipFramerTest, DuplicateHeader) { frame.WriteUInt16(0); // Priority. frame.WriteUInt16(2); // Number of headers. - FlipHeaderBlock::iterator it; + SpdyHeaderBlock::iterator it; frame.WriteString("name"); frame.WriteString("value1"); frame.WriteString("name"); frame.WriteString("value2"); // write the length - frame.WriteUInt32ToOffset(4, frame.length() - FlipFrame::size()); + frame.WriteUInt32ToOffset(4, frame.length() - SpdyFrame::size()); - FlipHeaderBlock new_headers; - scoped_ptr<FlipFrame> control_frame(frame.take()); - FlipFramer framer; + SpdyHeaderBlock new_headers; + scoped_ptr<SpdyFrame> control_frame(frame.take()); + SpdyFramer framer; FramerSetEnableCompressionHelper(&framer, false); // This should fail because duplicate headers are verboten by the spec. EXPECT_FALSE(framer.ParseHeaderBlock(control_frame.get(), &new_headers)); } -TEST_F(FlipFramerTest, MultiValueHeader) { - FlipFrameBuilder frame; +TEST_F(SpdyFramerTest, MultiValueHeader) { + SpdyFrameBuilder frame; frame.WriteUInt16(kControlFlagMask | 1); frame.WriteUInt16(SYN_STREAM); @@ -211,74 +211,74 @@ TEST_F(FlipFramerTest, MultiValueHeader) { frame.WriteUInt16(0); // Priority. frame.WriteUInt16(2); // Number of headers. - FlipHeaderBlock::iterator it; + SpdyHeaderBlock::iterator it; frame.WriteString("name"); std::string value("value1\0value2"); frame.WriteString(value); // write the length - frame.WriteUInt32ToOffset(4, frame.length() - FlipFrame::size()); + frame.WriteUInt32ToOffset(4, frame.length() - SpdyFrame::size()); - FlipHeaderBlock new_headers; - scoped_ptr<FlipFrame> control_frame(frame.take()); - FlipFramer framer; + SpdyHeaderBlock new_headers; + scoped_ptr<SpdyFrame> control_frame(frame.take()); + SpdyFramer framer; FramerSetEnableCompressionHelper(&framer, false); EXPECT_TRUE(framer.ParseHeaderBlock(control_frame.get(), &new_headers)); EXPECT_TRUE(new_headers.find("name") != new_headers.end()); EXPECT_EQ(value, new_headers.find("name")->second); } -TEST_F(FlipFramerTest, BasicCompression) { - FlipHeaderBlock headers; - headers["server"] = "FlipServer 1.0"; +TEST_F(SpdyFramerTest, BasicCompression) { + SpdyHeaderBlock headers; + headers["server"] = "SpdyServer 1.0"; headers["date"] = "Mon 12 Jan 2009 12:12:12 PST"; headers["status"] = "200"; headers["version"] = "HTTP/1.1"; headers["content-type"] = "text/html"; headers["content-length"] = "12"; - FlipFramer framer; + SpdyFramer framer; FramerSetEnableCompressionHelper(&framer, true); - scoped_ptr<FlipSynStreamControlFrame> + scoped_ptr<SpdySynStreamControlFrame> frame1(framer.CreateSynStream(1, 1, CONTROL_FLAG_NONE, true, &headers)); - scoped_ptr<FlipSynStreamControlFrame> + scoped_ptr<SpdySynStreamControlFrame> frame2(framer.CreateSynStream(1, 1, CONTROL_FLAG_NONE, true, &headers)); // Expect the second frame to be more compact than the first. EXPECT_LE(frame2->length(), frame1->length()); // Decompress the first frame - scoped_ptr<FlipFrame> frame3(framer.DecompressFrame(frame1.get())); + scoped_ptr<SpdyFrame> frame3(framer.DecompressFrame(frame1.get())); // Decompress the second frame - scoped_ptr<FlipFrame> frame4(framer.DecompressFrame(frame2.get())); + scoped_ptr<SpdyFrame> frame4(framer.DecompressFrame(frame2.get())); // Expect frames 3 & 4 to be the same. EXPECT_EQ(0, memcmp(frame3->data(), frame4->data(), - FlipFrame::size() + frame3->length())); + SpdyFrame::size() + frame3->length())); } -TEST_F(FlipFramerTest, DecompressUncompressedFrame) { - FlipHeaderBlock headers; - headers["server"] = "FlipServer 1.0"; +TEST_F(SpdyFramerTest, DecompressUncompressedFrame) { + SpdyHeaderBlock headers; + headers["server"] = "SpdyServer 1.0"; headers["date"] = "Mon 12 Jan 2009 12:12:12 PST"; headers["status"] = "200"; headers["version"] = "HTTP/1.1"; headers["content-type"] = "text/html"; headers["content-length"] = "12"; - FlipFramer framer; + SpdyFramer framer; FramerSetEnableCompressionHelper(&framer, true); - scoped_ptr<FlipSynStreamControlFrame> + scoped_ptr<SpdySynStreamControlFrame> frame1(framer.CreateSynStream(1, 1, CONTROL_FLAG_NONE, false, &headers)); // Decompress the frame - scoped_ptr<FlipFrame> frame2(framer.DecompressFrame(frame1.get())); + scoped_ptr<SpdyFrame> frame2(framer.DecompressFrame(frame1.get())); EXPECT_EQ(NULL, frame2.get()); } -TEST_F(FlipFramerTest, Basic) { +TEST_F(SpdyFramerTest, Basic) { const unsigned char input[] = { 0x80, 0x01, 0x00, 0x01, // SYN Stream #1 0x00, 0x00, 0x00, 0x10, @@ -321,7 +321,7 @@ TEST_F(FlipFramerTest, Basic) { 0x00, 0x00, 0x00, 0x00, }; - TestFlipVisitor visitor; + TestSpdyVisitor visitor; visitor.SimulateInFramer(input, sizeof(input)); EXPECT_EQ(0, visitor.error_count_); @@ -334,7 +334,7 @@ TEST_F(FlipFramerTest, Basic) { } // Test that the FIN flag on a data frame signifies EOF. -TEST_F(FlipFramerTest, FinOnDataFrame) { +TEST_F(SpdyFramerTest, FinOnDataFrame) { const unsigned char input[] = { 0x80, 0x01, 0x00, 0x01, // SYN Stream #1 0x00, 0x00, 0x00, 0x10, @@ -361,7 +361,7 @@ TEST_F(FlipFramerTest, FinOnDataFrame) { 0xde, 0xad, 0xbe, 0xef, }; - TestFlipVisitor visitor; + TestSpdyVisitor visitor; visitor.SimulateInFramer(input, sizeof(input)); EXPECT_EQ(0, visitor.error_count_); @@ -374,7 +374,7 @@ TEST_F(FlipFramerTest, FinOnDataFrame) { } // Test that the FIN flag on a SYN reply frame signifies EOF. -TEST_F(FlipFramerTest, FinOnSynReplyFrame) { +TEST_F(SpdyFramerTest, FinOnSynReplyFrame) { const unsigned char input[] = { 0x80, 0x01, 0x00, 0x01, // SYN Stream #1 0x00, 0x00, 0x00, 0x10, @@ -391,7 +391,7 @@ TEST_F(FlipFramerTest, FinOnSynReplyFrame) { 0x00, 0x02, 'b', 'b', }; - TestFlipVisitor visitor; + TestSpdyVisitor visitor; visitor.SimulateInFramer(input, sizeof(input)); EXPECT_EQ(0, visitor.error_count_); diff --git a/net/spdy/spdy_io_buffer.cc b/net/spdy/spdy_io_buffer.cc index d26e4c3..f7120c8 100644 --- a/net/spdy/spdy_io_buffer.cc +++ b/net/spdy/spdy_io_buffer.cc @@ -8,20 +8,20 @@ namespace net { // static -uint64 FlipIOBuffer::order_ = 0; +uint64 SpdyIOBuffer::order_ = 0; -FlipIOBuffer::FlipIOBuffer( - IOBuffer* buffer, int size, int priority, FlipStream* stream) +SpdyIOBuffer::SpdyIOBuffer( + IOBuffer* buffer, int size, int priority, SpdyStream* stream) : buffer_(new DrainableIOBuffer(buffer, size)), priority_(priority), position_(++order_), stream_(stream) {} -FlipIOBuffer::FlipIOBuffer() : priority_(0), position_(0), stream_(NULL) {} +SpdyIOBuffer::SpdyIOBuffer() : priority_(0), position_(0), stream_(NULL) {} -FlipIOBuffer::~FlipIOBuffer() {} +SpdyIOBuffer::~SpdyIOBuffer() {} -void FlipIOBuffer::release() { +void SpdyIOBuffer::release() { buffer_ = NULL; stream_ = NULL; } diff --git a/net/spdy/spdy_io_buffer.h b/net/spdy/spdy_io_buffer.h index 08e40bb..e34c7fe 100644 --- a/net/spdy/spdy_io_buffer.h +++ b/net/spdy/spdy_io_buffer.h @@ -10,13 +10,13 @@ namespace net { -class FlipStream; +class SpdyStream; -// A class for managing FLIP IO buffers. These buffers need to be prioritized -// so that the FlipSession sends them in the right order. Further, they need -// to track the FlipStream which they are associated with so that incremental +// A class for managing SPDY IO buffers. These buffers need to be prioritized +// so that the SpdySession sends them in the right order. Further, they need +// to track the SpdyStream which they are associated with so that incremental // completion of the IO can notify the appropriate stream of completion. -class FlipIOBuffer { +class SpdyIOBuffer { public: // Constructor // |buffer| is the actual data buffer. @@ -24,19 +24,19 @@ class FlipIOBuffer { // |priority| is the priority of this buffer. Lower numbers are higher // priority. // |stream| is a pointer to the stream which is managing this buffer. - FlipIOBuffer(IOBuffer* buffer, int size, int priority, FlipStream* stream); - FlipIOBuffer(); - ~FlipIOBuffer(); + SpdyIOBuffer(IOBuffer* buffer, int size, int priority, SpdyStream* stream); + SpdyIOBuffer(); + ~SpdyIOBuffer(); // Accessors. DrainableIOBuffer* buffer() const { return buffer_; } size_t size() const { return buffer_->size(); } void release(); int priority() const { return priority_; } - const scoped_refptr<FlipStream>& stream() const { return stream_; } + const scoped_refptr<SpdyStream>& stream() const { return stream_; } // Comparison operator to support sorting. - bool operator<(const FlipIOBuffer& other) const { + bool operator<(const SpdyIOBuffer& other) const { if (priority_ != other.priority_) return priority_ > other.priority_; return position_ > other.position_; @@ -46,7 +46,7 @@ class FlipIOBuffer { scoped_refptr<DrainableIOBuffer> buffer_; int priority_; uint64 position_; - scoped_refptr<FlipStream> stream_; + scoped_refptr<SpdyStream> stream_; static uint64 order_; // Maintains a FIFO order for equal priorities. }; diff --git a/net/spdy/spdy_network_transaction.cc b/net/spdy/spdy_network_transaction.cc index b578d38..76b3097 100644 --- a/net/spdy/spdy_network_transaction.cc +++ b/net/spdy/spdy_network_transaction.cc @@ -25,9 +25,9 @@ namespace net { //----------------------------------------------------------------------------- -FlipNetworkTransaction::FlipNetworkTransaction(HttpNetworkSession* session) +SpdyNetworkTransaction::SpdyNetworkTransaction(HttpNetworkSession* session) : ALLOW_THIS_IN_INITIALIZER_LIST( - io_callback_(this, &FlipNetworkTransaction::OnIOComplete)), + io_callback_(this, &SpdyNetworkTransaction::OnIOComplete)), user_callback_(NULL), user_buffer_len_(0), session_(session), @@ -36,19 +36,19 @@ FlipNetworkTransaction::FlipNetworkTransaction(HttpNetworkSession* session) stream_(NULL) { } -FlipNetworkTransaction::~FlipNetworkTransaction() { - LOG(INFO) << "FlipNetworkTransaction dead. " << this; +SpdyNetworkTransaction::~SpdyNetworkTransaction() { + LOG(INFO) << "SpdyNetworkTransaction dead. " << this; if (stream_.get()) stream_->Cancel(); } -int FlipNetworkTransaction::Start(const HttpRequestInfo* request_info, +int SpdyNetworkTransaction::Start(const HttpRequestInfo* request_info, CompletionCallback* callback, LoadLog* load_log) { CHECK(request_info); CHECK(callback); - SIMPLE_STATS_COUNTER("FlipNetworkTransaction.Count"); + SIMPLE_STATS_COUNTER("SpdyNetworkTransaction.Count"); load_log_ = load_log; request_ = request_info; @@ -61,21 +61,21 @@ int FlipNetworkTransaction::Start(const HttpRequestInfo* request_info, return rv; } -int FlipNetworkTransaction::RestartIgnoringLastError( +int SpdyNetworkTransaction::RestartIgnoringLastError( CompletionCallback* callback) { // TODO(mbelshe): implement me. NOTIMPLEMENTED(); return ERR_NOT_IMPLEMENTED; } -int FlipNetworkTransaction::RestartWithCertificate( +int SpdyNetworkTransaction::RestartWithCertificate( X509Certificate* client_cert, CompletionCallback* callback) { // TODO(mbelshe): implement me. NOTIMPLEMENTED(); return ERR_NOT_IMPLEMENTED; } -int FlipNetworkTransaction::RestartWithAuth( +int SpdyNetworkTransaction::RestartWithAuth( const std::wstring& username, const std::wstring& password, CompletionCallback* callback) { @@ -84,7 +84,7 @@ int FlipNetworkTransaction::RestartWithAuth( return 0; } -int FlipNetworkTransaction::Read(IOBuffer* buf, int buf_len, +int SpdyNetworkTransaction::Read(IOBuffer* buf, int buf_len, CompletionCallback* callback) { DCHECK(buf); DCHECK_GT(buf_len, 0); @@ -100,15 +100,15 @@ int FlipNetworkTransaction::Read(IOBuffer* buf, int buf_len, return rv; } -const HttpResponseInfo* FlipNetworkTransaction::GetResponseInfo() const { +const HttpResponseInfo* SpdyNetworkTransaction::GetResponseInfo() const { return (response_.headers || response_.ssl_info.cert) ? &response_ : NULL; } -LoadState FlipNetworkTransaction::GetLoadState() const { +LoadState SpdyNetworkTransaction::GetLoadState() const { switch (next_state_) { case STATE_INIT_CONNECTION_COMPLETE: - if (flip_.get()) - return flip_->GetLoadState(); + if (spdy_.get()) + return spdy_->GetLoadState(); return LOAD_STATE_CONNECTING; case STATE_SEND_REQUEST_COMPLETE: return LOAD_STATE_SENDING_REQUEST; @@ -121,14 +121,14 @@ LoadState FlipNetworkTransaction::GetLoadState() const { } } -uint64 FlipNetworkTransaction::GetUploadProgress() const { +uint64 SpdyNetworkTransaction::GetUploadProgress() const { if (!stream_.get()) return 0; return stream_->GetUploadProgress(); } -void FlipNetworkTransaction::DoCallback(int rv) { +void SpdyNetworkTransaction::DoCallback(int rv) { CHECK(rv != ERR_IO_PENDING); CHECK(user_callback_); @@ -138,13 +138,13 @@ void FlipNetworkTransaction::DoCallback(int rv) { c->Run(rv); } -void FlipNetworkTransaction::OnIOComplete(int result) { +void SpdyNetworkTransaction::OnIOComplete(int result) { int rv = DoLoop(result); if (rv != ERR_IO_PENDING) DoCallback(rv); } -int FlipNetworkTransaction::DoLoop(int result) { +int SpdyNetworkTransaction::DoLoop(int result) { DCHECK(next_state_ != STATE_NONE); DCHECK(request_); @@ -159,45 +159,45 @@ int FlipNetworkTransaction::DoLoop(int result) { case STATE_INIT_CONNECTION: DCHECK_EQ(OK, rv); LoadLog::BeginEvent(load_log_, - LoadLog::TYPE_FLIP_TRANSACTION_INIT_CONNECTION); + LoadLog::TYPE_SPDY_TRANSACTION_INIT_CONNECTION); rv = DoInitConnection(); break; case STATE_INIT_CONNECTION_COMPLETE: LoadLog::EndEvent(load_log_, - LoadLog::TYPE_FLIP_TRANSACTION_INIT_CONNECTION); + LoadLog::TYPE_SPDY_TRANSACTION_INIT_CONNECTION); rv = DoInitConnectionComplete(rv); break; case STATE_SEND_REQUEST: DCHECK_EQ(OK, rv); LoadLog::BeginEvent(load_log_, - LoadLog::TYPE_FLIP_TRANSACTION_SEND_REQUEST); + LoadLog::TYPE_SPDY_TRANSACTION_SEND_REQUEST); rv = DoSendRequest(); break; case STATE_SEND_REQUEST_COMPLETE: LoadLog::EndEvent(load_log_, - LoadLog::TYPE_FLIP_TRANSACTION_SEND_REQUEST); + LoadLog::TYPE_SPDY_TRANSACTION_SEND_REQUEST); rv = DoSendRequestComplete(rv); break; case STATE_READ_HEADERS: DCHECK_EQ(OK, rv); LoadLog::BeginEvent(load_log_, - LoadLog::TYPE_FLIP_TRANSACTION_READ_HEADERS); + LoadLog::TYPE_SPDY_TRANSACTION_READ_HEADERS); rv = DoReadHeaders(); break; case STATE_READ_HEADERS_COMPLETE: LoadLog::EndEvent(load_log_, - LoadLog::TYPE_FLIP_TRANSACTION_READ_HEADERS); + LoadLog::TYPE_SPDY_TRANSACTION_READ_HEADERS); rv = DoReadHeadersComplete(rv); break; case STATE_READ_BODY: DCHECK_EQ(OK, rv); LoadLog::BeginEvent(load_log_, - LoadLog::TYPE_FLIP_TRANSACTION_READ_BODY); + LoadLog::TYPE_SPDY_TRANSACTION_READ_BODY); rv = DoReadBody(); break; case STATE_READ_BODY_COMPLETE: LoadLog::EndEvent(load_log_, - LoadLog::TYPE_FLIP_TRANSACTION_READ_BODY); + LoadLog::TYPE_SPDY_TRANSACTION_READ_BODY); rv = DoReadBodyComplete(rv); break; case STATE_NONE: @@ -213,7 +213,7 @@ int FlipNetworkTransaction::DoLoop(int result) { return rv; } -int FlipNetworkTransaction::DoInitConnection() { +int SpdyNetworkTransaction::DoInitConnection() { next_state_ = STATE_INIT_CONNECTION_COMPLETE; std::string host = request_->url.HostNoBrackets(); @@ -221,26 +221,26 @@ int FlipNetworkTransaction::DoInitConnection() { // Use the fixed testing ports if they've been provided. This is useful for // debugging. - if (FlipSession::SSLMode()) { + if (SpdySession::SSLMode()) { if (session_->fixed_https_port() != 0) port = session_->fixed_https_port(); } else if (session_->fixed_http_port() != 0) { port = session_->fixed_http_port(); } - std::string connection_group = "flip."; + std::string connection_group = "spdy."; connection_group.append(host); HostResolver::RequestInfo resolve_info(host, port); - flip_ = session_->flip_session_pool()->Get(resolve_info, session_); - DCHECK(flip_); + spdy_ = session_->spdy_session_pool()->Get(resolve_info, session_); + DCHECK(spdy_); - return flip_->Connect( + return spdy_->Connect( connection_group, resolve_info, request_->priority, load_log_); } -int FlipNetworkTransaction::DoInitConnectionComplete(int result) { +int SpdyNetworkTransaction::DoInitConnectionComplete(int result) { if (result < 0) return result; @@ -248,18 +248,18 @@ int FlipNetworkTransaction::DoInitConnectionComplete(int result) { return OK; } -int FlipNetworkTransaction::DoSendRequest() { +int SpdyNetworkTransaction::DoSendRequest() { next_state_ = STATE_SEND_REQUEST_COMPLETE; CHECK(!stream_.get()); UploadDataStream* upload_data = request_->upload_data ? new UploadDataStream(request_->upload_data) : NULL; - stream_ = flip_->GetOrCreateStream(*request_, upload_data, load_log_.get()); - // Release the reference to |flip_| since we don't need it anymore. - flip_ = NULL; + stream_ = spdy_->GetOrCreateStream(*request_, upload_data, load_log_.get()); + // Release the reference to |spdy_| since we don't need it anymore. + spdy_ = NULL; return stream_->SendRequest(upload_data, &response_, &io_callback_); } -int FlipNetworkTransaction::DoSendRequestComplete(int result) { +int SpdyNetworkTransaction::DoSendRequestComplete(int result) { if (result < 0) return result; @@ -267,24 +267,24 @@ int FlipNetworkTransaction::DoSendRequestComplete(int result) { return OK; } -int FlipNetworkTransaction::DoReadHeaders() { +int SpdyNetworkTransaction::DoReadHeaders() { next_state_ = STATE_READ_HEADERS_COMPLETE; return stream_->ReadResponseHeaders(&io_callback_); } -int FlipNetworkTransaction::DoReadHeadersComplete(int result) { +int SpdyNetworkTransaction::DoReadHeadersComplete(int result) { // TODO(willchan): Flesh out the support for HTTP authentication here. return result; } -int FlipNetworkTransaction::DoReadBody() { +int SpdyNetworkTransaction::DoReadBody() { next_state_ = STATE_READ_BODY_COMPLETE; return stream_->ReadResponseBody( user_buffer_, user_buffer_len_, &io_callback_); } -int FlipNetworkTransaction::DoReadBodyComplete(int result) { +int SpdyNetworkTransaction::DoReadBodyComplete(int result) { user_buffer_ = NULL; user_buffer_len_ = 0; diff --git a/net/spdy/spdy_network_transaction.h b/net/spdy/spdy_network_transaction.h index 9379cfa..28251ab 100644 --- a/net/spdy/spdy_network_transaction.h +++ b/net/spdy/spdy_network_transaction.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef NET_FLIP_NETWORK_TRANSACTION_H_ -#define NET_FLIP_NETWORK_TRANSACTION_H_ +#ifndef NET_SPDY_NETWORK_TRANSACTION_H_ +#define NET_SPDY_NETWORK_TRANSACTION_H_ #include <string> #include <deque> @@ -20,19 +20,19 @@ namespace net { -class FlipSession; -class FlipStream; +class SpdySession; +class SpdyStream; class HttpNetworkSession; class HttpResponseInfo; class IOBuffer; class UploadDataStream; -// A FlipNetworkTransaction can be used to fetch HTTP conent. -// The FlipDelegate is the consumer of events from the FlipSession. -class FlipNetworkTransaction : public HttpTransaction { +// A SpdyNetworkTransaction can be used to fetch HTTP conent. +// The SpdyDelegate is the consumer of events from the SpdySession. +class SpdyNetworkTransaction : public HttpTransaction { public: - explicit FlipNetworkTransaction(HttpNetworkSession* session); - virtual ~FlipNetworkTransaction(); + explicit SpdyNetworkTransaction(HttpNetworkSession* session); + virtual ~SpdyNetworkTransaction(); // HttpTransaction methods: virtual int Start(const HttpRequestInfo* request_info, @@ -51,10 +51,10 @@ class FlipNetworkTransaction : public HttpTransaction { virtual uint64 GetUploadProgress() const; protected: - friend class FlipNetworkTransactionTest; + friend class SpdyNetworkTransactionTest; // Provide access to the session for testing. - FlipSession* GetFlipSession() { return flip_.get(); } + SpdySession* GetSpdySession() { return spdy_.get(); } private: enum State { @@ -90,12 +90,12 @@ class FlipNetworkTransaction : public HttpTransaction { scoped_refptr<LoadLog> load_log_; - scoped_refptr<FlipSession> flip_; + scoped_refptr<SpdySession> spdy_; - CompletionCallbackImpl<FlipNetworkTransaction> io_callback_; + CompletionCallbackImpl<SpdyNetworkTransaction> io_callback_; CompletionCallback* user_callback_; - // Used to pass onto the FlipStream + // Used to pass onto the SpdyStream scoped_refptr<IOBuffer> user_buffer_; int user_buffer_len_; @@ -110,11 +110,11 @@ class FlipNetworkTransaction : public HttpTransaction { // The next state in the state machine. State next_state_; - scoped_refptr<FlipStream> stream_; + scoped_refptr<SpdyStream> stream_; - DISALLOW_COPY_AND_ASSIGN(FlipNetworkTransaction); + DISALLOW_COPY_AND_ASSIGN(SpdyNetworkTransaction); }; } // namespace net -#endif // NET_HTTP_NETWORK_TRANSACTION_H_ +#endif // NET_SPDY_NETWORK_TRANSACTION_H_ diff --git a/net/spdy/spdy_network_transaction_unittest.cc b/net/spdy/spdy_network_transaction_unittest.cc index 0c879f7..340bd13 100644 --- a/net/spdy/spdy_network_transaction_unittest.cc +++ b/net/spdy/spdy_network_transaction_unittest.cc @@ -31,7 +31,7 @@ ProxyService* CreateNullProxyService() { } // Helper to manage the lifetimes of the dependencies for a -// FlipNetworkTransaction. +// SpdyNetworkTransaction. class SessionDependencies { public: // Default set of dependencies -- "null" proxy service. @@ -39,7 +39,7 @@ class SessionDependencies { : host_resolver(new MockHostResolver), proxy_service(CreateNullProxyService()), ssl_config_service(new SSLConfigServiceDefaults), - flip_session_pool(new FlipSessionPool) { + spdy_session_pool(new SpdySessionPool) { // Note: The CancelledTransaction test does cleanup by running all tasks // in the message loop (RunAllPending). Unfortunately, that doesn't clean // up tasks on the host resolver thread; and TCPConnectJob is currently @@ -54,13 +54,13 @@ class SessionDependencies { : host_resolver(new MockHostResolver), proxy_service(proxy_service), ssl_config_service(new SSLConfigServiceDefaults), - flip_session_pool(new FlipSessionPool) {} + spdy_session_pool(new SpdySessionPool) {} scoped_refptr<MockHostResolverBase> host_resolver; scoped_refptr<ProxyService> proxy_service; scoped_refptr<SSLConfigService> ssl_config_service; MockClientSocketFactory socket_factory; - scoped_refptr<FlipSessionPool> flip_session_pool; + scoped_refptr<SpdySessionPool> spdy_session_pool; }; ProxyService* CreateFixedProxyService(const std::string& proxy) { @@ -76,7 +76,7 @@ HttpNetworkSession* CreateSession(SessionDependencies* session_deps) { session_deps->proxy_service, &session_deps->socket_factory, session_deps->ssl_config_service, - session_deps->flip_session_pool); + session_deps->spdy_session_pool); } // Chop a frame into an array of MockWrites. @@ -260,7 +260,7 @@ class DelayedSocketData : public StaticSocketDataProvider, ScopedRunnableMethodFactory<DelayedSocketData> factory_; }; -class FlipNetworkTransactionTest : public PlatformTest { +class SpdyNetworkTransactionTest : public PlatformTest { protected: virtual void SetUp() { // By default, all tests turn off compression. @@ -283,7 +283,7 @@ class FlipNetworkTransactionTest : public PlatformTest { }; void EnableCompression(bool enabled) { - flip::FlipFramer::set_enable_compression_default(enabled); + spdy::SpdyFramer::set_enable_compression_default(enabled); } TransactionHelperResult TransactionHelper(const HttpRequestInfo& request, @@ -292,11 +292,11 @@ class FlipNetworkTransactionTest : public PlatformTest { TransactionHelperResult out; // We disable SSL for this test. - FlipSession::SetSSLMode(false); + SpdySession::SetSSLMode(false); SessionDependencies session_deps; - scoped_ptr<FlipNetworkTransaction> trans( - new FlipNetworkTransaction(CreateSession(&session_deps))); + scoped_ptr<SpdyNetworkTransaction> trans( + new SpdyNetworkTransaction(CreateSession(&session_deps))); session_deps.socket_factory.AddSocketDataProvider(data); @@ -333,15 +333,15 @@ class FlipNetworkTransactionTest : public PlatformTest { //----------------------------------------------------------------------------- -// Verify FlipNetworkTransaction constructor. -TEST_F(FlipNetworkTransactionTest, Constructor) { +// Verify SpdyNetworkTransaction constructor. +TEST_F(SpdyNetworkTransactionTest, Constructor) { SessionDependencies session_deps; scoped_refptr<HttpNetworkSession> session = CreateSession(&session_deps); - scoped_ptr<HttpTransaction> trans(new FlipNetworkTransaction(session)); + scoped_ptr<HttpTransaction> trans(new SpdyNetworkTransaction(session)); } -TEST_F(FlipNetworkTransactionTest, Get) { +TEST_F(SpdyNetworkTransactionTest, Get) { MockWrite writes[] = { MockWrite(true, reinterpret_cast<const char*>(kGetSyn), arraysize(kGetSyn)), @@ -369,7 +369,7 @@ TEST_F(FlipNetworkTransactionTest, Get) { } // Test that a simple POST works. -TEST_F(FlipNetworkTransactionTest, Post) { +TEST_F(SpdyNetworkTransactionTest, Post) { static const char upload[] = { "hello world" }; // Setup the request @@ -404,7 +404,7 @@ TEST_F(FlipNetworkTransactionTest, Post) { } // Test that a simple POST works. -TEST_F(FlipNetworkTransactionTest, EmptyPost) { +TEST_F(SpdyNetworkTransactionTest, EmptyPost) { static const unsigned char kEmptyPostSyn[] = { 0x80, 0x01, 0x00, 0x01, // header 0x01, 0x00, 0x00, 0x46, // flags, len @@ -451,7 +451,7 @@ static const unsigned char kEmptyPostSyn[] = { } // Test that the transaction doesn't crash when we don't have a reply. -TEST_F(FlipNetworkTransactionTest, ResponseWithoutSynReply) { +TEST_F(SpdyNetworkTransactionTest, ResponseWithoutSynReply) { MockRead reads[] = { MockRead(true, reinterpret_cast<const char*>(kPostBodyFrame), arraysize(kPostBodyFrame)), @@ -468,7 +468,7 @@ TEST_F(FlipNetworkTransactionTest, ResponseWithoutSynReply) { EXPECT_EQ(ERR_SYN_REPLY_NOT_RECEIVED, out.rv); } -TEST_F(FlipNetworkTransactionTest, CancelledTransaction) { +TEST_F(SpdyNetworkTransactionTest, CancelledTransaction) { MockWrite writes[] = { MockWrite(true, reinterpret_cast<const char*>(kGetSyn), arraysize(kGetSyn)), @@ -479,8 +479,8 @@ TEST_F(FlipNetworkTransactionTest, CancelledTransaction) { MockRead(true, reinterpret_cast<const char*>(kGetSynReply), arraysize(kGetSynReply)), // This following read isn't used by the test, except during the - // RunAllPending() call at the end since the FlipSession survives the - // FlipNetworkTransaction and still tries to continue Read()'ing. Any + // RunAllPending() call at the end since the SpdySession survives the + // SpdyNetworkTransaction and still tries to continue Read()'ing. Any // MockRead will do here. MockRead(true, 0, 0) // EOF }; @@ -491,11 +491,11 @@ TEST_F(FlipNetworkTransactionTest, CancelledTransaction) { request.load_flags = 0; // We disable SSL for this test. - FlipSession::SetSSLMode(false); + SpdySession::SetSSLMode(false); SessionDependencies session_deps; - scoped_ptr<FlipNetworkTransaction> trans( - new FlipNetworkTransaction(CreateSession(&session_deps))); + scoped_ptr<SpdyNetworkTransaction> trans( + new SpdyNetworkTransaction(CreateSession(&session_deps))); StaticSocketDataProvider data(reads, writes); session_deps.socket_factory.AddSocketDataProvider(&data); @@ -513,7 +513,7 @@ TEST_F(FlipNetworkTransactionTest, CancelledTransaction) { // Verify that various SynReply headers parse correctly through the // HTTP layer. -TEST_F(FlipNetworkTransactionTest, SynReplyHeaders) { +TEST_F(SpdyNetworkTransactionTest, SynReplyHeaders) { // This uses a multi-valued cookie header. static const unsigned char syn_reply1[] = { 0x80, 0x01, 0x00, 0x02, @@ -632,7 +632,7 @@ TEST_F(FlipNetworkTransactionTest, SynReplyHeaders) { } // Verify that we don't crash on invalid SynReply responses. -TEST_F(FlipNetworkTransactionTest, InvalidSynReply) { +TEST_F(SpdyNetworkTransactionTest, InvalidSynReply) { static const unsigned char kSynReplyMissingStatus[] = { 0x80, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x3f, @@ -693,7 +693,7 @@ TEST_F(FlipNetworkTransactionTest, InvalidSynReply) { } // Verify that we don't crash on some corrupt frames. -TEST_F(FlipNetworkTransactionTest, CorruptFrameSessionError) { +TEST_F(SpdyNetworkTransactionTest, CorruptFrameSessionError) { static const unsigned char kSynReplyMassiveLength[] = { 0x80, 0x01, 0x00, 0x02, 0x0f, 0x11, 0x11, 0x26, // This is the length field with a big number @@ -734,11 +734,11 @@ TEST_F(FlipNetworkTransactionTest, CorruptFrameSessionError) { scoped_refptr<DelayedSocketData> data( new DelayedSocketData(reads, 1, writes)); TransactionHelperResult out = TransactionHelper(request, data.get(), NULL); - EXPECT_EQ(ERR_FLIP_PROTOCOL_ERROR, out.rv); + EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, out.rv); } } -TEST_F(FlipNetworkTransactionTest, ServerPush) { +TEST_F(SpdyNetworkTransactionTest, ServerPush) { // Reply with the X-Associated-Content header. static const unsigned char syn_reply[] = { 0x80, 0x01, 0x00, 0x02, @@ -802,7 +802,7 @@ TEST_F(FlipNetworkTransactionTest, ServerPush) { }; // We disable SSL for this test. - FlipSession::SetSSLMode(false); + SpdySession::SetSSLMode(false); enum TestTypes { // Simulate that the server sends the first request, notifying the client @@ -810,7 +810,7 @@ TEST_F(FlipNetworkTransactionTest, ServerPush) { // request for the second stream before the push data arrives. PUSH_AFTER_REQUEST, // Simulate that the server is sending the pushed stream data before the - // client requests it. The FlipSession will buffer the response and then + // client requests it. The SpdySession will buffer the response and then // deliver the data when the client does make the request. PUSH_BEFORE_REQUEST, DONE @@ -826,7 +826,7 @@ TEST_F(FlipNetworkTransactionTest, ServerPush) { // Issue the first request { - FlipNetworkTransaction trans(session.get()); + SpdyNetworkTransaction trans(session.get()); // Issue the first request. HttpRequestInfo request; @@ -857,7 +857,7 @@ TEST_F(FlipNetworkTransactionTest, ServerPush) { // Issue a second request for the X-Associated-Content. { - FlipNetworkTransaction trans(session.get()); + SpdyNetworkTransaction trans(session.get()); HttpRequestInfo request; request.method = "GET"; @@ -896,7 +896,7 @@ TEST_F(FlipNetworkTransactionTest, ServerPush) { } // Test that we shutdown correctly on write errors. -TEST_F(FlipNetworkTransactionTest, WriteError) { +TEST_F(SpdyNetworkTransactionTest, WriteError) { MockWrite writes[] = { // We'll write 10 bytes successfully MockWrite(true, reinterpret_cast<const char*>(kGetSyn), 10), @@ -925,7 +925,7 @@ TEST_F(FlipNetworkTransactionTest, WriteError) { } // Test that partial writes work. -TEST_F(FlipNetworkTransactionTest, PartialWrite) { +TEST_F(SpdyNetworkTransactionTest, PartialWrite) { // Chop the SYN_STREAM frame into 5 chunks. const int kChunks = 5; scoped_array<MockWrite> writes(ChopFrame( @@ -951,7 +951,7 @@ TEST_F(FlipNetworkTransactionTest, PartialWrite) { EXPECT_EQ("hello!", out.response_data); } -TEST_F(FlipNetworkTransactionTest, DISABLED_ConnectFailure) { +TEST_F(SpdyNetworkTransactionTest, DISABLED_ConnectFailure) { MockConnect connects[] = { MockConnect(true, ERR_NAME_NOT_RESOLVED), MockConnect(false, ERR_NAME_NOT_RESOLVED), @@ -987,7 +987,7 @@ TEST_F(FlipNetworkTransactionTest, DISABLED_ConnectFailure) { // In this test, we enable compression, but get a uncompressed SynReply from // the server. Verify that teardown is all clean. -TEST_F(FlipNetworkTransactionTest, DecompressFailureOnSynReply) { +TEST_F(SpdyNetworkTransactionTest, DecompressFailureOnSynReply) { MockWrite writes[] = { MockWrite(true, reinterpret_cast<const char*>(kGetSynCompressed), arraysize(kGetSynCompressed)), @@ -1019,7 +1019,7 @@ TEST_F(FlipNetworkTransactionTest, DecompressFailureOnSynReply) { } // Test that the LoadLog contains good data for a simple GET request. -TEST_F(FlipNetworkTransactionTest, LoadLog) { +TEST_F(SpdyNetworkTransactionTest, LoadLog) { MockWrite writes[] = { MockWrite(true, reinterpret_cast<const char*>(kGetSyn), arraysize(kGetSyn)), @@ -1055,29 +1055,29 @@ TEST_F(FlipNetworkTransactionTest, LoadLog) { int pos = 0; // We know the first event at position 0. EXPECT_TRUE(net::LogContainsBeginEvent( - *log, 0, net::LoadLog::TYPE_FLIP_TRANSACTION_INIT_CONNECTION)); + *log, 0, net::LoadLog::TYPE_SPDY_TRANSACTION_INIT_CONNECTION)); // For the rest of the events, allow additional events in the middle, // but expect these to be logged in order. pos = net::ExpectLogContainsSomewhere(log, 0, - net::LoadLog::TYPE_FLIP_TRANSACTION_INIT_CONNECTION, + net::LoadLog::TYPE_SPDY_TRANSACTION_INIT_CONNECTION, net::LoadLog::PHASE_END); pos = net::ExpectLogContainsSomewhere(log, pos + 1, - net::LoadLog::TYPE_FLIP_TRANSACTION_SEND_REQUEST, + net::LoadLog::TYPE_SPDY_TRANSACTION_SEND_REQUEST, net::LoadLog::PHASE_BEGIN); pos = net::ExpectLogContainsSomewhere(log, pos + 1, - net::LoadLog::TYPE_FLIP_TRANSACTION_SEND_REQUEST, + net::LoadLog::TYPE_SPDY_TRANSACTION_SEND_REQUEST, net::LoadLog::PHASE_END); pos = net::ExpectLogContainsSomewhere(log, pos + 1, - net::LoadLog::TYPE_FLIP_TRANSACTION_READ_HEADERS, + net::LoadLog::TYPE_SPDY_TRANSACTION_READ_HEADERS, net::LoadLog::PHASE_BEGIN); pos = net::ExpectLogContainsSomewhere(log, pos + 1, - net::LoadLog::TYPE_FLIP_TRANSACTION_READ_HEADERS, + net::LoadLog::TYPE_SPDY_TRANSACTION_READ_HEADERS, net::LoadLog::PHASE_END); pos = net::ExpectLogContainsSomewhere(log, pos + 1, - net::LoadLog::TYPE_FLIP_TRANSACTION_READ_BODY, + net::LoadLog::TYPE_SPDY_TRANSACTION_READ_BODY, net::LoadLog::PHASE_BEGIN); pos = net::ExpectLogContainsSomewhere(log, pos + 1, - net::LoadLog::TYPE_FLIP_TRANSACTION_READ_BODY, + net::LoadLog::TYPE_SPDY_TRANSACTION_READ_BODY, net::LoadLog::PHASE_END); } diff --git a/net/spdy/spdy_protocol.h b/net/spdy/spdy_protocol.h index 455e5aa..988d08d 100644 --- a/net/spdy/spdy_protocol.h +++ b/net/spdy/spdy_protocol.h @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// This file contains some protocol structures for use with Flip. +// This file contains some protocol structures for use with Spdy. #ifndef NET_SPDY_SPDY_PROTOCOL_H_ #define NET_SPDY_SPDY_PROTOCOL_H_ @@ -79,17 +79,17 @@ // TODO(fenix): add ChangePriority support. -namespace flip { +namespace spdy { -// This implementation of Flip is version 1. -const int kFlipProtocolVersion = 1; +// This implementation of Spdy is version 1. +const int kSpdyProtocolVersion = 1; // Note: all protocol data structures are on-the-wire format. That means that // data is stored in network-normalized order. Readers must use the // accessors provided or call ntohX() functions. -// Types of Flip Control Frames. -enum FlipControlType { +// Types of Spdy Control Frames. +enum SpdyControlType { SYN_STREAM = 1, SYN_REPLY, FIN_STREAM, @@ -97,24 +97,24 @@ enum FlipControlType { }; // Flags on data packets -enum FlipDataFlags { +enum SpdyDataFlags { DATA_FLAG_NONE = 0, DATA_FLAG_FIN = 1, DATA_FLAG_COMPRESSED = 2 // TODO(mbelshe): remove me. }; // Flags on control packets -enum FlipControlFlags { +enum SpdyControlFlags { CONTROL_FLAG_NONE = 0, CONTROL_FLAG_FIN = 1 }; -// A FLIP stream id is a 31 bit entity. -typedef uint32 FlipStreamId; +// A Spdy stream id is a 31 bit entity. +typedef uint32 SpdyStreamId; -// FLIP Priorities. (there are only 2 bits) -#define FLIP_PRIORITY_LOWEST 3 -#define FLIP_PRIORITY_HIGHEST 0 +// Spdy Priorities. (there are only 2 bits) +#define SPDY_PRIORITY_LOWEST 3 +#define SPDY_PRIORITY_HIGHEST 0 // ------------------------------------------------------------------------- // These structures mirror the protocol structure definitions. @@ -130,71 +130,71 @@ union FlagsAndLength { uint32 length_; // 24 bits }; -// The basic FLIP Frame structure. -struct FlipFrameBlock { +// The basic Spdy Frame structure. +struct SpdyFrameBlock { union { struct { uint16 version_; uint16 type_; } control_; struct { - FlipStreamId stream_id_; + SpdyStreamId stream_id_; } data_; }; FlagsAndLength flags_length_; }; // A Control Frame structure. -struct FlipControlFrameBlock : FlipFrameBlock { - FlipStreamId stream_id_; +struct SpdyControlFrameBlock : SpdyFrameBlock { + SpdyStreamId stream_id_; }; // A SYN_STREAM Control Frame structure. -struct FlipSynStreamControlFrameBlock : FlipControlFrameBlock { +struct SpdySynStreamControlFrameBlock : SpdyControlFrameBlock { uint8 priority_; uint8 unused_; }; // A SYN_REPLY Control Frame structure. -struct FlipSynReplyControlFrameBlock : FlipControlFrameBlock { +struct SpdySynReplyControlFrameBlock : SpdyControlFrameBlock { uint16 unused_; }; // A FNI_STREAM Control Frame structure. -struct FlipFinStreamControlFrameBlock : FlipControlFrameBlock { +struct SpdyFinStreamControlFrameBlock : SpdyControlFrameBlock { uint32 status_; }; #pragma pack(pop) // ------------------------------------------------------------------------- -// Wrapper classes for various FLIP frames. +// Wrapper classes for various Spdy frames. -// All Flip Frame types derive from this FlipFrame class. -class FlipFrame { +// All Spdy Frame types derive from this SpdyFrame class. +class SpdyFrame { public: - // Create a FlipFrame for a given sized buffer. - explicit FlipFrame(size_t size) : frame_(NULL), owns_buffer_(true) { - DCHECK_GE(size, sizeof(struct FlipFrameBlock)); + // Create a SpdyFrame for a given sized buffer. + explicit SpdyFrame(size_t size) : frame_(NULL), owns_buffer_(true) { + DCHECK_GE(size, sizeof(struct SpdyFrameBlock)); char* buffer = new char[size]; memset(buffer, 0, size); - frame_ = reinterpret_cast<struct FlipFrameBlock*>(buffer); + frame_ = reinterpret_cast<struct SpdyFrameBlock*>(buffer); } - // Create a FlipFrame using a pre-created buffer. + // Create a SpdyFrame using a pre-created buffer. // If |owns_buffer| is true, this class takes ownership of the buffer // and will delete it on cleanup. The buffer must have been created using // new char[]. // If |owns_buffer| is false, the caller retains ownership of the buffer and // is responsible for making sure the buffer outlives this frame. In other // words, this class does NOT create a copy of the buffer. - FlipFrame(char* data, bool owns_buffer) - : frame_(reinterpret_cast<struct FlipFrameBlock*>(data)), + SpdyFrame(char* data, bool owns_buffer) + : frame_(reinterpret_cast<struct SpdyFrameBlock*>(data)), owns_buffer_(owns_buffer) { DCHECK(frame_); } - virtual ~FlipFrame() { + virtual ~SpdyFrame() { if (owns_buffer_) { char* buffer = reinterpret_cast<char*>(frame_); delete [] buffer; @@ -224,164 +224,164 @@ class FlipFrame { kControlFlagMask; } - // Returns the size of the FlipFrameBlock structure. - // Note: this is not the size of the FlipFrame class. - // Every FlipFrame* class has a static size() method for accessing + // Returns the size of the SpdyFrameBlock structure. + // Note: this is not the size of the SpdyFrame class. + // Every SpdyFrame* class has a static size() method for accessing // the size of the data structure which will be sent over the wire. - // Note: this is not the same as sizeof(FlipFrame). - static size_t size() { return sizeof(struct FlipFrameBlock); } + // Note: this is not the same as sizeof(SpdyFrame). + static size_t size() { return sizeof(struct SpdyFrameBlock); } protected: - FlipFrameBlock* frame_; + SpdyFrameBlock* frame_; private: bool owns_buffer_; - DISALLOW_COPY_AND_ASSIGN(FlipFrame); + DISALLOW_COPY_AND_ASSIGN(SpdyFrame); }; // A Data Frame. -class FlipDataFrame : public FlipFrame { +class SpdyDataFrame : public SpdyFrame { public: - FlipDataFrame() : FlipFrame(size()) {} - FlipDataFrame(char* data, bool owns_buffer) - : FlipFrame(data, owns_buffer) {} - virtual ~FlipDataFrame() {} + SpdyDataFrame() : SpdyFrame(size()) {} + SpdyDataFrame(char* data, bool owns_buffer) + : SpdyFrame(data, owns_buffer) {} + virtual ~SpdyDataFrame() {} - FlipStreamId stream_id() const { + SpdyStreamId stream_id() const { return ntohl(frame_->data_.stream_id_) & kStreamIdMask; } // Note that setting the stream id sets the control bit to false. // As stream id should always be set, this means the control bit // should always be set correctly. - void set_stream_id(FlipStreamId id) { + void set_stream_id(SpdyStreamId id) { DCHECK_EQ(0u, (id & ~kStreamIdMask)); frame_->data_.stream_id_ = htonl(id & kStreamIdMask); } - // Returns the size of the FlipFrameBlock structure. - // Note: this is not the size of the FlipDataFrame class. - static size_t size() { return FlipFrame::size(); } + // Returns the size of the SpdyFrameBlock structure. + // Note: this is not the size of the SpdyDataFrame class. + static size_t size() { return SpdyFrame::size(); } private: - DISALLOW_COPY_AND_ASSIGN(FlipDataFrame); + DISALLOW_COPY_AND_ASSIGN(SpdyDataFrame); }; // A Control Frame. -class FlipControlFrame : public FlipFrame { +class SpdyControlFrame : public SpdyFrame { public: - explicit FlipControlFrame(size_t size) : FlipFrame(size) {} - FlipControlFrame(char* data, bool owns_buffer) - : FlipFrame(data, owns_buffer) {} - virtual ~FlipControlFrame() {} + explicit SpdyControlFrame(size_t size) : SpdyFrame(size) {} + SpdyControlFrame(char* data, bool owns_buffer) + : SpdyFrame(data, owns_buffer) {} + virtual ~SpdyControlFrame() {} uint16 version() const { const int kVersionMask = 0x7fff; return ntohs(block()->control_.version_) & kVersionMask; } - FlipControlType type() const { + SpdyControlType type() const { uint16 type = ntohs(block()->control_.type_); DCHECK(type >= SYN_STREAM && type <= NOOP); - return static_cast<FlipControlType>(type); + return static_cast<SpdyControlType>(type); } - FlipStreamId stream_id() const { + SpdyStreamId stream_id() const { return ntohl(block()->stream_id_) & kStreamIdMask; } - void set_stream_id(FlipStreamId id) { + void set_stream_id(SpdyStreamId id) { block()->stream_id_ = htonl(id & kStreamIdMask); } - // Returns the size of the FlipControlFrameBlock structure. - // Note: this is not the size of the FlipControlFrame class. - static size_t size() { return sizeof(FlipControlFrameBlock); } + // Returns the size of the SpdyControlFrameBlock structure. + // Note: this is not the size of the SpdyControlFrame class. + static size_t size() { return sizeof(SpdyControlFrameBlock); } private: - struct FlipControlFrameBlock* block() const { - return static_cast<FlipControlFrameBlock*>(frame_); + struct SpdyControlFrameBlock* block() const { + return static_cast<SpdyControlFrameBlock*>(frame_); } - DISALLOW_COPY_AND_ASSIGN(FlipControlFrame); + DISALLOW_COPY_AND_ASSIGN(SpdyControlFrame); }; // A SYN_STREAM frame. -class FlipSynStreamControlFrame : public FlipControlFrame { +class SpdySynStreamControlFrame : public SpdyControlFrame { public: - FlipSynStreamControlFrame() : FlipControlFrame(size()) {} - FlipSynStreamControlFrame(char* data, bool owns_buffer) - : FlipControlFrame(data, owns_buffer) {} - virtual ~FlipSynStreamControlFrame() {} + SpdySynStreamControlFrame() : SpdyControlFrame(size()) {} + SpdySynStreamControlFrame(char* data, bool owns_buffer) + : SpdyControlFrame(data, owns_buffer) {} + virtual ~SpdySynStreamControlFrame() {} uint8 priority() const { return (block()->priority_ & kPriorityMask) >> 6; } // The number of bytes in the header block beyond the frame header length. int header_block_len() const { - return length() - (size() - FlipFrame::size()); + return length() - (size() - SpdyFrame::size()); } const char* header_block() const { return reinterpret_cast<const char*>(block()) + size(); } - // Returns the size of the FlipSynStreamControlFrameBlock structure. - // Note: this is not the size of the FlipSynStreamControlFrame class. - static size_t size() { return sizeof(FlipSynStreamControlFrameBlock); } + // Returns the size of the SpdySynStreamControlFrameBlock structure. + // Note: this is not the size of the SpdySynStreamControlFrame class. + static size_t size() { return sizeof(SpdySynStreamControlFrameBlock); } private: - struct FlipSynStreamControlFrameBlock* block() const { - return static_cast<FlipSynStreamControlFrameBlock*>(frame_); + struct SpdySynStreamControlFrameBlock* block() const { + return static_cast<SpdySynStreamControlFrameBlock*>(frame_); } - DISALLOW_COPY_AND_ASSIGN(FlipSynStreamControlFrame); + DISALLOW_COPY_AND_ASSIGN(SpdySynStreamControlFrame); }; // A SYN_REPLY frame. -class FlipSynReplyControlFrame : public FlipControlFrame { +class SpdySynReplyControlFrame : public SpdyControlFrame { public: - FlipSynReplyControlFrame() : FlipControlFrame(size()) {} - FlipSynReplyControlFrame(char* data, bool owns_buffer) - : FlipControlFrame(data, owns_buffer) {} - virtual ~FlipSynReplyControlFrame() {} + SpdySynReplyControlFrame() : SpdyControlFrame(size()) {} + SpdySynReplyControlFrame(char* data, bool owns_buffer) + : SpdyControlFrame(data, owns_buffer) {} + virtual ~SpdySynReplyControlFrame() {} int header_block_len() const { - return length() - (size() - FlipFrame::size()); + return length() - (size() - SpdyFrame::size()); } const char* header_block() const { return reinterpret_cast<const char*>(block()) + size(); } - // Returns the size of the FlipSynReplyControlFrameBlock structure. - // Note: this is not the size of the FlipSynReplyControlFrame class. - static size_t size() { return sizeof(FlipSynReplyControlFrameBlock); } + // Returns the size of the SpdySynReplyControlFrameBlock structure. + // Note: this is not the size of the SpdySynReplyControlFrame class. + static size_t size() { return sizeof(SpdySynReplyControlFrameBlock); } private: - struct FlipSynReplyControlFrameBlock* block() const { - return static_cast<FlipSynReplyControlFrameBlock*>(frame_); + struct SpdySynReplyControlFrameBlock* block() const { + return static_cast<SpdySynReplyControlFrameBlock*>(frame_); } - DISALLOW_COPY_AND_ASSIGN(FlipSynReplyControlFrame); + DISALLOW_COPY_AND_ASSIGN(SpdySynReplyControlFrame); }; // A FIN_STREAM frame. -class FlipFinStreamControlFrame : public FlipControlFrame { +class SpdyFinStreamControlFrame : public SpdyControlFrame { public: - FlipFinStreamControlFrame() : FlipControlFrame(size()) {} - FlipFinStreamControlFrame(char* data, bool owns_buffer) - : FlipControlFrame(data, owns_buffer) {} - virtual ~FlipFinStreamControlFrame() {} + SpdyFinStreamControlFrame() : SpdyControlFrame(size()) {} + SpdyFinStreamControlFrame(char* data, bool owns_buffer) + : SpdyControlFrame(data, owns_buffer) {} + virtual ~SpdyFinStreamControlFrame() {} uint32 status() const { return ntohl(block()->status_); } void set_status(uint32 status) { block()->status_ = htonl(status); } - // Returns the size of the FlipFinStreamControlFrameBlock structure. - // Note: this is not the size of the FlipFinStreamControlFrame class. - static size_t size() { return sizeof(FlipFinStreamControlFrameBlock); } + // Returns the size of the SpdyFinStreamControlFrameBlock structure. + // Note: this is not the size of the SpdyFinStreamControlFrame class. + static size_t size() { return sizeof(SpdyFinStreamControlFrameBlock); } private: - struct FlipFinStreamControlFrameBlock* block() const { - return static_cast<FlipFinStreamControlFrameBlock*>(frame_); + struct SpdyFinStreamControlFrameBlock* block() const { + return static_cast<SpdyFinStreamControlFrameBlock*>(frame_); } - DISALLOW_COPY_AND_ASSIGN(FlipFinStreamControlFrame); + DISALLOW_COPY_AND_ASSIGN(SpdyFinStreamControlFrame); }; -} // namespace flip +} // namespace spdy #endif // NET_SPDY_SPDY_PROTOCOL_H_ diff --git a/net/spdy/spdy_protocol_test.cc b/net/spdy/spdy_protocol_test.cc index d6e51e3..7d75113 100644 --- a/net/spdy/spdy_protocol_test.cc +++ b/net/spdy/spdy_protocol_test.cc @@ -9,34 +9,34 @@ #include "net/spdy/spdy_framer.h" #include "testing/platform_test.h" -using flip::FlipDataFrame; -using flip::FlipFrame; -using flip::FlipControlFrame; -using flip::FlipSynStreamControlFrame; -using flip::FlipSynReplyControlFrame; -using flip::FlipFinStreamControlFrame; -using flip::FlipFramer; -using flip::FlipHeaderBlock; -using flip::FlagsAndLength; -using flip::kLengthMask; -using flip::kStreamIdMask; -using flip::kFlipProtocolVersion; -using flip::SYN_STREAM; -using flip::SYN_REPLY; -using flip::FIN_STREAM; -using flip::CONTROL_FLAG_FIN; -using flip::CONTROL_FLAG_NONE; +using spdy::SpdyDataFrame; +using spdy::SpdyFrame; +using spdy::SpdyControlFrame; +using spdy::SpdySynStreamControlFrame; +using spdy::SpdySynReplyControlFrame; +using spdy::SpdyFinStreamControlFrame; +using spdy::SpdyFramer; +using spdy::SpdyHeaderBlock; +using spdy::FlagsAndLength; +using spdy::kLengthMask; +using spdy::kStreamIdMask; +using spdy::kSpdyProtocolVersion; +using spdy::SYN_STREAM; +using spdy::SYN_REPLY; +using spdy::FIN_STREAM; +using spdy::CONTROL_FLAG_FIN; +using spdy::CONTROL_FLAG_NONE; namespace { // Test our protocol constants -TEST(FlipProtocolTest, ProtocolConstants) { - EXPECT_EQ(8u, FlipFrame::size()); - EXPECT_EQ(8u, FlipDataFrame::size()); - EXPECT_EQ(12u, FlipControlFrame::size()); - EXPECT_EQ(14u, FlipSynStreamControlFrame::size()); - EXPECT_EQ(14u, FlipSynReplyControlFrame::size()); - EXPECT_EQ(16u, FlipFinStreamControlFrame::size()); +TEST(SpdyProtocolTest, ProtocolConstants) { + EXPECT_EQ(8u, SpdyFrame::size()); + EXPECT_EQ(8u, SpdyDataFrame::size()); + EXPECT_EQ(12u, SpdyControlFrame::size()); + EXPECT_EQ(14u, SpdySynStreamControlFrame::size()); + EXPECT_EQ(14u, SpdySynReplyControlFrame::size()); + EXPECT_EQ(16u, SpdyFinStreamControlFrame::size()); EXPECT_EQ(4u, sizeof(FlagsAndLength)); EXPECT_EQ(1, SYN_STREAM); EXPECT_EQ(2, SYN_REPLY); @@ -44,8 +44,8 @@ TEST(FlipProtocolTest, ProtocolConstants) { } // Test some of the protocol helper functions -TEST(FlipProtocolTest, FrameStructs) { - FlipFrame frame(FlipFrame::size()); +TEST(SpdyProtocolTest, FrameStructs) { + SpdyFrame frame(SpdyFrame::size()); frame.set_length(12345); frame.set_flags(10); EXPECT_EQ(12345u, frame.length()); @@ -59,19 +59,19 @@ TEST(FlipProtocolTest, FrameStructs) { EXPECT_EQ(false, frame.is_control_frame()); } -TEST(FlipProtocolTest, DataFrameStructs) { - FlipDataFrame data_frame; +TEST(SpdyProtocolTest, DataFrameStructs) { + SpdyDataFrame data_frame; data_frame.set_stream_id(12345); EXPECT_EQ(12345u, data_frame.stream_id()); } -TEST(FlipProtocolTest, ControlFrameStructs) { - FlipFramer framer; - FlipHeaderBlock headers; +TEST(SpdyProtocolTest, ControlFrameStructs) { + SpdyFramer framer; + SpdyHeaderBlock headers; - scoped_ptr<FlipSynStreamControlFrame> syn_frame( + scoped_ptr<SpdySynStreamControlFrame> syn_frame( framer.CreateSynStream(123, 2, CONTROL_FLAG_FIN, false, &headers)); - EXPECT_EQ(kFlipProtocolVersion, syn_frame->version()); + EXPECT_EQ(kSpdyProtocolVersion, syn_frame->version()); EXPECT_EQ(true, syn_frame->is_control_frame()); EXPECT_EQ(SYN_STREAM, syn_frame->type()); EXPECT_EQ(123u, syn_frame->stream_id()); @@ -79,18 +79,18 @@ TEST(FlipProtocolTest, ControlFrameStructs) { EXPECT_EQ(2, syn_frame->header_block_len()); EXPECT_EQ(1u, syn_frame->flags()); - scoped_ptr<FlipSynReplyControlFrame> syn_reply( + scoped_ptr<SpdySynReplyControlFrame> syn_reply( framer.CreateSynReply(123, CONTROL_FLAG_NONE, false, &headers)); - EXPECT_EQ(kFlipProtocolVersion, syn_reply->version()); + EXPECT_EQ(kSpdyProtocolVersion, syn_reply->version()); EXPECT_EQ(true, syn_reply->is_control_frame()); EXPECT_EQ(SYN_REPLY, syn_reply->type()); EXPECT_EQ(123u, syn_reply->stream_id()); EXPECT_EQ(2, syn_reply->header_block_len()); EXPECT_EQ(0, syn_reply->flags()); - scoped_ptr<FlipFinStreamControlFrame> fin_frame( + scoped_ptr<SpdyFinStreamControlFrame> fin_frame( framer.CreateFinStream(123, 444)); - EXPECT_EQ(kFlipProtocolVersion, fin_frame->version()); + EXPECT_EQ(kSpdyProtocolVersion, fin_frame->version()); EXPECT_EQ(true, fin_frame->is_control_frame()); EXPECT_EQ(FIN_STREAM, fin_frame->type()); EXPECT_EQ(123u, fin_frame->stream_id()); @@ -100,8 +100,8 @@ TEST(FlipProtocolTest, ControlFrameStructs) { EXPECT_EQ(0, fin_frame->flags()); } -TEST(FlipProtocolTest, TestDataFrame) { - FlipDataFrame frame; +TEST(SpdyProtocolTest, TestDataFrame) { + SpdyDataFrame frame; // Set the stream ID to various values. frame.set_stream_id(0); @@ -113,7 +113,7 @@ TEST(FlipProtocolTest, TestDataFrame) { // Set length to various values. Make sure that when you set_length(x), // length() == x. Also make sure the flags are unaltered. - memset(frame.data(), '1', FlipDataFrame::size()); + memset(frame.data(), '1', SpdyDataFrame::size()); int8 flags = frame.flags(); frame.set_length(0); EXPECT_EQ(0u, frame.length()); @@ -127,7 +127,7 @@ TEST(FlipProtocolTest, TestDataFrame) { // Set flags to various values. Make sure that when you set_flags(x), // flags() == x. Also make sure the length is unaltered. - memset(frame.data(), '1', FlipDataFrame::size()); + memset(frame.data(), '1', SpdyDataFrame::size()); uint32 length = frame.length(); frame.set_flags(0); EXPECT_EQ(0u, frame.flags()); @@ -145,8 +145,8 @@ TEST(FlipProtocolTest, TestDataFrame) { // Make sure that overflows both die in debug mode, and do not cause problems // in opt mode. Note: Chrome doesn't die on DCHECK failures, so the // EXPECT_DEBUG_DEATH doesn't work. -TEST(FlipProtocolDeathTest, TestDataFrame) { - FlipDataFrame frame; +TEST(SpdyProtocolDeathTest, TestDataFrame) { + SpdyDataFrame frame; frame.set_stream_id(0); #ifndef WIN32 @@ -161,9 +161,9 @@ TEST(FlipProtocolDeathTest, TestDataFrame) { EXPECT_EQ(0, frame.flags()); } -TEST(FlipProtocolDeathTest, TestFlipControlFrame) { - FlipControlFrame frame(FlipControlFrame::size()); - memset(frame.data(), '1', FlipControlFrame::size()); +TEST(SpdyProtocolDeathTest, TestSpdyControlFrame) { + SpdyControlFrame frame(SpdyControlFrame::size()); + memset(frame.data(), '1', SpdyControlFrame::size()); // Set the stream ID to various values. frame.set_stream_id(0); diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc index 4a837c5..63ee561 100644 --- a/net/spdy/spdy_session.cc +++ b/net/spdy/spdy_session.cc @@ -31,13 +31,13 @@ namespace { // Diagnostics function to dump the headers of a request. // TODO(mbelshe): Remove this function. -void DumpFlipHeaders(const flip::FlipHeaderBlock& headers) { +void DumpSpdyHeaders(const spdy::SpdyHeaderBlock& headers) { // Because this function gets called on every request, // take extra care to optimize it away if logging is turned off. if (logging::LOG_INFO < logging::GetMinLogLevel()) return; - flip::FlipHeaderBlock::const_iterator it = headers.begin(); + spdy::SpdyHeaderBlock::const_iterator it = headers.begin(); while (it != headers.end()) { std::string val = (*it).second; std::string::size_type pos = 0; @@ -62,21 +62,21 @@ const int kReadBufferSize = 2 * 1024; const int kReadBufferSize = 8 * 1024; #endif -// Convert a FlipHeaderBlock into an HttpResponseInfo. -// |headers| input parameter with the FlipHeaderBlock. +// Convert a SpdyHeaderBlock into an HttpResponseInfo. +// |headers| input parameter with the SpdyHeaderBlock. // |info| output parameter for the HttpResponseInfo. // Returns true if successfully converted. False if there was a failure -// or if the FlipHeaderBlock was invalid. -bool FlipHeadersToHttpResponse(const flip::FlipHeaderBlock& headers, +// or if the SpdyHeaderBlock was invalid. +bool SpdyHeadersToHttpResponse(const spdy::SpdyHeaderBlock& headers, HttpResponseInfo* response) { std::string version; std::string status; // The "status" and "version" headers are required. - flip::FlipHeaderBlock::const_iterator it; + spdy::SpdyHeaderBlock::const_iterator it; it = headers.find("status"); if (it == headers.end()) { - LOG(ERROR) << "FlipHeaderBlock without status header."; + LOG(ERROR) << "SpdyHeaderBlock without status header."; return false; } status = it->second; @@ -84,7 +84,7 @@ bool FlipHeadersToHttpResponse(const flip::FlipHeaderBlock& headers, // Grab the version. If not provided by the server, it = headers.find("version"); if (it == headers.end()) { - LOG(ERROR) << "FlipHeaderBlock without version header."; + LOG(ERROR) << "SpdyHeaderBlock without version header."; return false; } version = it->second; @@ -125,10 +125,10 @@ bool FlipHeadersToHttpResponse(const flip::FlipHeaderBlock& headers, return true; } -// Create a FlipHeaderBlock for a Flip SYN_STREAM Frame from +// Create a SpdyHeaderBlock for a Spdy SYN_STREAM Frame from // a HttpRequestInfo block. -void CreateFlipHeadersFromHttpRequest( - const HttpRequestInfo& info, flip::FlipHeaderBlock* headers) { +void CreateSpdyHeadersFromHttpRequest( + const HttpRequestInfo& info, spdy::SpdyHeaderBlock* headers) { static const char kHttpProtocolVersion[] = "HTTP/1.1"; HttpUtil::HeadersIterator it(info.extra_headers.begin(), @@ -168,7 +168,7 @@ void CreateFlipHeadersFromHttpRequest( void AdjustSocketBufferSizes(ClientSocket* socket) { // Adjust socket buffer sizes. - // FLIP uses one socket, and we want a really big buffer. + // SPDY uses one socket, and we want a really big buffer. // This greatly helps on links with packet loss - we can even // outperform Vista's dynamic window sizing algorithm. // TODO(mbelshe): more study. @@ -180,17 +180,17 @@ void AdjustSocketBufferSizes(ClientSocket* socket) { } // namespace // static -bool FlipSession::use_ssl_ = true; +bool SpdySession::use_ssl_ = true; -FlipSession::FlipSession(const std::string& host, HttpNetworkSession* session) +SpdySession::SpdySession(const std::string& host, HttpNetworkSession* session) : ALLOW_THIS_IN_INITIALIZER_LIST( - connect_callback_(this, &FlipSession::OnTCPConnect)), + connect_callback_(this, &SpdySession::OnTCPConnect)), ALLOW_THIS_IN_INITIALIZER_LIST( - ssl_connect_callback_(this, &FlipSession::OnSSLConnect)), + ssl_connect_callback_(this, &SpdySession::OnSSLConnect)), ALLOW_THIS_IN_INITIALIZER_LIST( - read_callback_(this, &FlipSession::OnReadComplete)), + read_callback_(this, &SpdySession::OnReadComplete)), ALLOW_THIS_IN_INITIALIZER_LIST( - write_callback_(this, &FlipSession::OnWriteComplete)), + write_callback_(this, &SpdySession::OnWriteComplete)), domain_(host), session_(session), connection_(new ClientSocketHandle), @@ -208,7 +208,7 @@ FlipSession::FlipSession(const std::string& host, HttpNetworkSession* session) streams_abandoned_count_(0) { // TODO(mbelshe): consider randomization of the stream_hi_water_mark. - flip_framer_.set_visitor(this); + spdy_framer_.set_visitor(this); session_->ssl_config_service()->GetSSLConfig(&ssl_config_); @@ -224,17 +224,17 @@ FlipSession::FlipSession(const std::string& host, HttpNetworkSession* session) ssl_config_.next_protos = "\007http1.1\004spdy"; } -FlipSession::~FlipSession() { +SpdySession::~SpdySession() { // Cleanup all the streams. CloseAllStreams(net::ERR_ABORTED); if (connection_->is_initialized()) { - // With Flip we can't recycle sockets. + // With Spdy we can't recycle sockets. connection_->socket()->Disconnect(); } // TODO(willchan): Don't hardcode port 80 here. - DCHECK(!session_->flip_session_pool()->HasSession( + DCHECK(!session_->spdy_session_pool()->HasSession( HostResolver::RequestInfo(domain_, 80))); // Record per-session histograms here. @@ -252,9 +252,9 @@ FlipSession::~FlipSession() { 0, 300, 50); } -void FlipSession::InitializeWithSocket(ClientSocketHandle* connection) { - static StatsCounter flip_sessions("flip.sessions"); - flip_sessions.Increment(); +void SpdySession::InitializeWithSocket(ClientSocketHandle* connection) { + static StatsCounter spdy_sessions("spdy.sessions"); + spdy_sessions.Increment(); AdjustSocketBufferSizes(connection->socket()); @@ -267,11 +267,11 @@ void FlipSession::InitializeWithSocket(ClientSocketHandle* connection) { ReadSocket(); } -net::Error FlipSession::Connect(const std::string& group_name, +net::Error SpdySession::Connect(const std::string& group_name, const HostResolver::RequestInfo& host, RequestPriority priority, LoadLog* load_log) { - DCHECK(priority >= FLIP_PRIORITY_HIGHEST && priority <= FLIP_PRIORITY_LOWEST); + DCHECK(priority >= SPDY_PRIORITY_HIGHEST && priority <= SPDY_PRIORITY_LOWEST); // If the connect process is started, let the caller continue. if (state_ > IDLE) @@ -279,8 +279,8 @@ net::Error FlipSession::Connect(const std::string& group_name, state_ = CONNECTING; - static StatsCounter flip_sessions("flip.sessions"); - flip_sessions.Increment(); + static StatsCounter spdy_sessions("spdy.sessions"); + spdy_sessions.Increment(); int rv = connection_->Init(group_name, host, priority, &connect_callback_, session_->tcp_socket_pool(), load_log); @@ -293,14 +293,14 @@ net::Error FlipSession::Connect(const std::string& group_name, return static_cast<net::Error>(rv); } -scoped_refptr<FlipStream> FlipSession::GetOrCreateStream( +scoped_refptr<SpdyStream> SpdySession::GetOrCreateStream( const HttpRequestInfo& request, const UploadDataStream* upload_data, LoadLog* log) { const GURL& url = request.url; const std::string& path = url.PathForRequest(); - scoped_refptr<FlipStream> stream; + scoped_refptr<SpdyStream> stream; // Check if we have a push stream for this path. if (request.method == "GET") { @@ -319,17 +319,17 @@ scoped_refptr<FlipStream> FlipSession::GetOrCreateStream( DCHECK(!it->second); // Server will assign a stream id when the push stream arrives. Use 0 for // now. - LoadLog::AddEvent(log, LoadLog::TYPE_FLIP_STREAM_ADOPTED_PUSH_STREAM); - FlipStream* stream = new FlipStream(this, 0, true, log); + LoadLog::AddEvent(log, LoadLog::TYPE_SPDY_STREAM_ADOPTED_PUSH_STREAM); + SpdyStream* stream = new SpdyStream(this, 0, true, log); stream->set_path(path); it->second = stream; return it->second; } - const flip::FlipStreamId stream_id = GetNewStreamId(); + const spdy::SpdyStreamId stream_id = GetNewStreamId(); // If we still don't have a stream, activate one now. - stream = new FlipStream(this, stream_id, false, log); + stream = new SpdyStream(this, stream_id, false, log); stream->set_priority(request.priority); stream->set_path(path); ActivateStream(stream); @@ -337,37 +337,37 @@ scoped_refptr<FlipStream> FlipSession::GetOrCreateStream( UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdyPriorityCount", static_cast<int>(request.priority), 0, 10, 11); - LOG(INFO) << "FlipStream: Creating stream " << stream_id << " for " << url; + LOG(INFO) << "SpdyStream: Creating stream " << stream_id << " for " << url; // TODO(mbelshe): Optimize memory allocations - DCHECK(request.priority >= FLIP_PRIORITY_HIGHEST && - request.priority <= FLIP_PRIORITY_LOWEST); + DCHECK(request.priority >= SPDY_PRIORITY_HIGHEST && + request.priority <= SPDY_PRIORITY_LOWEST); - // Convert from HttpRequestHeaders to Flip Headers. - flip::FlipHeaderBlock headers; - CreateFlipHeadersFromHttpRequest(request, &headers); + // Convert from HttpRequestHeaders to Spdy Headers. + spdy::SpdyHeaderBlock headers; + CreateSpdyHeadersFromHttpRequest(request, &headers); - flip::FlipControlFlags flags = flip::CONTROL_FLAG_NONE; + spdy::SpdyControlFlags flags = spdy::CONTROL_FLAG_NONE; if (!request.upload_data || !upload_data->size()) - flags = flip::CONTROL_FLAG_FIN; + flags = spdy::CONTROL_FLAG_FIN; // Create a SYN_STREAM packet and add to the output queue. - scoped_ptr<flip::FlipSynStreamControlFrame> syn_frame( - flip_framer_.CreateSynStream(stream_id, request.priority, flags, false, + scoped_ptr<spdy::SpdySynStreamControlFrame> syn_frame( + spdy_framer_.CreateSynStream(stream_id, request.priority, flags, false, &headers)); - int length = flip::FlipFrame::size() + syn_frame->length(); + int length = spdy::SpdyFrame::size() + syn_frame->length(); IOBuffer* buffer = new IOBuffer(length); memcpy(buffer->data(), syn_frame->data(), length); - queue_.push(FlipIOBuffer(buffer, length, request.priority, stream)); + queue_.push(SpdyIOBuffer(buffer, length, request.priority, stream)); - static StatsCounter flip_requests("flip.requests"); - flip_requests.Increment(); + static StatsCounter spdy_requests("spdy.requests"); + spdy_requests.Increment(); LOG(INFO) << "FETCHING: " << request.url.spec(); streams_initiated_count_++; - LOG(INFO) << "FLIP SYN_STREAM HEADERS ----------------------------------"; - DumpFlipHeaders(headers); + LOG(INFO) << "SPDY SYN_STREAM HEADERS ----------------------------------"; + DumpSpdyHeaders(headers); // Schedule to write to the socket after we've made it back // to the message loop so that we can aggregate multiple @@ -380,7 +380,7 @@ scoped_refptr<FlipStream> FlipSession::GetOrCreateStream( return stream; } -int FlipSession::WriteStreamData(flip::FlipStreamId stream_id, +int SpdySession::WriteStreamData(spdy::SpdyStreamId stream_id, net::IOBuffer* data, int len) { LOG(INFO) << "Writing Stream Data for stream " << stream_id << " (" << len << " bytes)"; @@ -389,32 +389,32 @@ int FlipSession::WriteStreamData(flip::FlipStreamId stream_id, // Chop the world into 2-packet chunks. This is somewhat arbitrary, but // is reasonably small and ensures that we elicit ACKs quickly from TCP // (because TCP tries to only ACK every other packet). - const int kMaxFlipFrameChunkSize = (2 * kMss) - flip::FlipFrame::size(); + const int kMaxSpdyFrameChunkSize = (2 * kMss) - spdy::SpdyFrame::size(); // Find our stream DCHECK(IsStreamActive(stream_id)); - scoped_refptr<FlipStream> stream = active_streams_[stream_id]; + scoped_refptr<SpdyStream> stream = active_streams_[stream_id]; CHECK(stream->stream_id() == stream_id); if (!stream) - return ERR_INVALID_FLIP_STREAM; + return ERR_INVALID_SPDY_STREAM; // TODO(mbelshe): Setting of the FIN is assuming that the caller will pass // all data to write in a single chunk. Is this always true? // Set the flags on the upload. - flip::FlipDataFlags flags = flip::DATA_FLAG_FIN; - if (len > kMaxFlipFrameChunkSize) { - len = kMaxFlipFrameChunkSize; - flags = flip::DATA_FLAG_NONE; + spdy::SpdyDataFlags flags = spdy::DATA_FLAG_FIN; + if (len > kMaxSpdyFrameChunkSize) { + len = kMaxSpdyFrameChunkSize; + flags = spdy::DATA_FLAG_NONE; } // TODO(mbelshe): reduce memory copies here. - scoped_ptr<flip::FlipDataFrame> frame( - flip_framer_.CreateDataFrame(stream_id, data->data(), len, flags)); - int length = flip::FlipFrame::size() + frame->length(); + scoped_ptr<spdy::SpdyDataFrame> frame( + spdy_framer_.CreateDataFrame(stream_id, data->data(), len, flags)); + int length = spdy::SpdyFrame::size() + frame->length(); IOBufferWithSize* buffer = new IOBufferWithSize(length); memcpy(buffer->data(), frame->data(), length); - queue_.push(FlipIOBuffer(buffer, length, stream->priority(), stream)); + queue_.push(SpdyIOBuffer(buffer, length, stream->priority(), stream)); // Whenever we queue onto the socket we need to ensure that we will write to // it later. @@ -423,7 +423,7 @@ int FlipSession::WriteStreamData(flip::FlipStreamId stream_id, return ERR_IO_PENDING; } -bool FlipSession::CancelStream(flip::FlipStreamId stream_id) { +bool SpdySession::CancelStream(spdy::SpdyStreamId stream_id) { LOG(INFO) << "Cancelling stream " << stream_id; if (!IsStreamActive(stream_id)) return false; @@ -434,18 +434,18 @@ bool FlipSession::CancelStream(flip::FlipStreamId stream_id) { // TODO(mbelshe): Write a method for tearing down a stream // that cleans it out of the active list, the pending list, // etc. - scoped_refptr<FlipStream> stream = active_streams_[stream_id]; + scoped_refptr<SpdyStream> stream = active_streams_[stream_id]; DeactivateStream(stream_id); return true; } -bool FlipSession::IsStreamActive(flip::FlipStreamId stream_id) const { +bool SpdySession::IsStreamActive(spdy::SpdyStreamId stream_id) const { return ContainsKey(active_streams_, stream_id); } -LoadState FlipSession::GetLoadState() const { +LoadState SpdySession::GetLoadState() const { // NOTE: The application only queries the LoadState via the - // FlipNetworkTransaction, and details are only needed when + // SpdyNetworkTransaction, and details are only needed when // we're in the process of connecting. // If we're connecting, defer to the connection to give us the actual @@ -458,8 +458,8 @@ LoadState FlipSession::GetLoadState() const { return LOAD_STATE_IDLE; } -void FlipSession::OnTCPConnect(int result) { - LOG(INFO) << "Flip socket connected (result=" << result << ")"; +void SpdySession::OnTCPConnect(int result) { + LOG(INFO) << "Spdy socket connected (result=" << result << ")"; // We shouldn't be coming through this path if we didn't just open a fresh // socket (or have an error trying to do so). @@ -484,7 +484,7 @@ void FlipSession::OnTCPConnect(int result) { socket, "" /* request_->url.HostNoBrackets() */ , ssl_config_); connection_->set_socket(socket); is_secure_ = true; - // TODO(willchan): Plumb LoadLog into FLIP code. + // TODO(willchan): Plumb LoadLog into SPDY code. int status = connection_->socket()->Connect(&ssl_connect_callback_, NULL); if (status != ERR_IO_PENDING) OnSSLConnect(status); @@ -499,7 +499,7 @@ void FlipSession::OnTCPConnect(int result) { } } -void FlipSession::OnSSLConnect(int result) { +void SpdySession::OnSSLConnect(int result) { // TODO(mbelshe): We need to replicate the functionality of // HttpNetworkTransaction::DoSSLConnectComplete here, where it calls // HandleCertificateError() and such. @@ -520,12 +520,12 @@ void FlipSession::OnSSLConnect(int result) { } } -void FlipSession::OnReadComplete(int bytes_read) { +void SpdySession::OnReadComplete(int bytes_read) { // Parse a frame. For now this code requires that the frame fit into our // buffer (32KB). // TODO(mbelshe): support arbitrarily large frames! - LOG(INFO) << "Flip socket read: " << bytes_read << " bytes"; + LOG(INFO) << "Spdy socket read: " << bytes_read << " bytes"; read_pending_ = false; @@ -538,34 +538,34 @@ void FlipSession::OnReadComplete(int bytes_read) { return; } - // The FlipFramer will use callbacks onto |this| as it parses frames. + // The SpdyFramer will use callbacks onto |this| as it parses frames. // When errors occur, those callbacks can lead to teardown of all references // to |this|, so maintain a reference to self during this call for safe // cleanup. - scoped_refptr<FlipSession> self(this); + scoped_refptr<SpdySession> self(this); char *data = read_buffer_->data(); while (bytes_read && - flip_framer_.error_code() == flip::FlipFramer::FLIP_NO_ERROR) { - uint32 bytes_processed = flip_framer_.ProcessInput(data, bytes_read); + spdy_framer_.error_code() == spdy::SpdyFramer::SPDY_NO_ERROR) { + uint32 bytes_processed = spdy_framer_.ProcessInput(data, bytes_read); bytes_read -= bytes_processed; data += bytes_processed; - if (flip_framer_.state() == flip::FlipFramer::FLIP_DONE) - flip_framer_.Reset(); + if (spdy_framer_.state() == spdy::SpdyFramer::SPDY_DONE) + spdy_framer_.Reset(); } if (state_ != CLOSED) ReadSocket(); } -void FlipSession::OnWriteComplete(int result) { +void SpdySession::OnWriteComplete(int result) { DCHECK(write_pending_); DCHECK(in_flight_write_.size()); DCHECK(result != 0); // This shouldn't happen for write. write_pending_ = false; - LOG(INFO) << "Flip write complete (result=" << result << ") for stream: " + LOG(INFO) << "Spdy write complete (result=" << result << ") for stream: " << in_flight_write_.stream()->stream_id(); if (result >= 0) { @@ -577,7 +577,7 @@ void FlipSession::OnWriteComplete(int result) { // We only notify the stream when we've fully written the pending frame. if (!in_flight_write_.buffer()->BytesRemaining()) { - scoped_refptr<FlipStream> stream = in_flight_write_.stream(); + scoped_refptr<SpdyStream> stream = in_flight_write_.stream(); DCHECK(stream.get()); // Report the number of bytes written to the caller, but exclude the @@ -585,8 +585,8 @@ void FlipSession::OnWriteComplete(int result) { // bytes written is the compressed size, not the original size. if (result > 0) { result = in_flight_write_.buffer()->size(); - DCHECK_GT(result, static_cast<int>(flip::FlipFrame::size())); - result -= static_cast<int>(flip::FlipFrame::size()); + DCHECK_GT(result, static_cast<int>(spdy::SpdyFrame::size())); + result -= static_cast<int>(spdy::SpdyFrame::size()); } // It is possible that the stream was cancelled while we were writing @@ -610,7 +610,7 @@ void FlipSession::OnWriteComplete(int result) { } } -void FlipSession::ReadSocket() { +void SpdySession::ReadSocket() { if (read_pending_) return; @@ -640,21 +640,21 @@ void FlipSession::ReadSocket() { // callbacks. read_pending_ = true; MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( - this, &FlipSession::OnReadComplete, bytes_read)); + this, &SpdySession::OnReadComplete, bytes_read)); break; } } -void FlipSession::WriteSocketLater() { +void SpdySession::WriteSocketLater() { if (delayed_write_pending_) return; delayed_write_pending_ = true; MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( - this, &FlipSession::WriteSocket)); + this, &SpdySession::WriteSocket)); } -void FlipSession::WriteSocket() { +void SpdySession::WriteSocket() { // This function should only be called via WriteSocketLater. DCHECK(delayed_write_pending_); delayed_write_pending_ = false; @@ -672,18 +672,18 @@ void FlipSession::WriteSocket() { // returns error (or ERR_IO_PENDING). while (in_flight_write_.buffer() || queue_.size()) { if (!in_flight_write_.buffer()) { - // Grab the next FlipFrame to send. - FlipIOBuffer next_buffer = queue_.top(); + // Grab the next SpdyFrame to send. + SpdyIOBuffer next_buffer = queue_.top(); queue_.pop(); // We've deferred compression until just before we write it to the socket, // which is now. At this time, we don't compress our data frames. - flip::FlipFrame uncompressed_frame(next_buffer.buffer()->data(), false); + spdy::SpdyFrame uncompressed_frame(next_buffer.buffer()->data(), false); size_t size; if (uncompressed_frame.is_control_frame()) { - scoped_ptr<flip::FlipFrame> compressed_frame( - flip_framer_.CompressFrame(&uncompressed_frame)); - size = compressed_frame->length() + flip::FlipFrame::size(); + scoped_ptr<spdy::SpdyFrame> compressed_frame( + spdy_framer_.CompressFrame(&uncompressed_frame)); + size = compressed_frame->length() + spdy::SpdyFrame::size(); DCHECK(size > 0); @@ -692,9 +692,9 @@ void FlipSession::WriteSocket() { memcpy(buffer->data(), compressed_frame->data(), size); // Attempt to send the frame. - in_flight_write_ = FlipIOBuffer(buffer, size, 0, next_buffer.stream()); + in_flight_write_ = SpdyIOBuffer(buffer, size, 0, next_buffer.stream()); } else { - size = uncompressed_frame.length() + flip::FlipFrame::size(); + size = uncompressed_frame.length() + spdy::SpdyFrame::size(); in_flight_write_ = next_buffer; } } else { @@ -717,18 +717,18 @@ void FlipSession::WriteSocket() { } } -void FlipSession::CloseAllStreams(net::Error code) { - LOG(INFO) << "Closing all FLIP Streams"; +void SpdySession::CloseAllStreams(net::Error code) { + LOG(INFO) << "Closing all SPDY Streams"; - static StatsCounter abandoned_streams("flip.abandoned_streams"); - static StatsCounter abandoned_push_streams("flip.abandoned_push_streams"); + static StatsCounter abandoned_streams("spdy.abandoned_streams"); + static StatsCounter abandoned_push_streams("spdy.abandoned_push_streams"); if (active_streams_.size()) { abandoned_streams.Add(active_streams_.size()); // Create a copy of the list, since aborting streams can invalidate // our list. - FlipStream** list = new FlipStream*[active_streams_.size()]; + SpdyStream** list = new SpdyStream*[active_streams_.size()]; ActiveStreamMap::const_iterator it; int index = 0; for (it = active_streams_.begin(); it != active_streams_.end(); ++it) @@ -754,7 +754,7 @@ void FlipSession::CloseAllStreams(net::Error code) { } } -int FlipSession::GetNewStreamId() { +int SpdySession::GetNewStreamId() { int id = stream_hi_water_mark_; stream_hi_water_mark_ += 2; if (stream_hi_water_mark_ > 0x7fff) @@ -762,9 +762,9 @@ int FlipSession::GetNewStreamId() { return id; } -void FlipSession::CloseSessionOnError(net::Error err) { +void SpdySession::CloseSessionOnError(net::Error err) { DCHECK_LT(err, OK); - LOG(INFO) << "Flip::CloseSessionOnError(" << err << ")"; + LOG(INFO) << "spdy::CloseSessionOnError(" << err << ")"; // Don't close twice. This can occur because we can have both // a read and a write outstanding, and each can complete with @@ -773,24 +773,24 @@ void FlipSession::CloseSessionOnError(net::Error err) { state_ = CLOSED; error_ = err; CloseAllStreams(err); - session_->flip_session_pool()->Remove(this); + session_->spdy_session_pool()->Remove(this); } } -void FlipSession::ActivateStream(FlipStream* stream) { - const flip::FlipStreamId id = stream->stream_id(); +void SpdySession::ActivateStream(SpdyStream* stream) { + const spdy::SpdyStreamId id = stream->stream_id(); DCHECK(!IsStreamActive(id)); active_streams_[id] = stream; } -void FlipSession::DeactivateStream(flip::FlipStreamId id) { +void SpdySession::DeactivateStream(spdy::SpdyStreamId id) { DCHECK(IsStreamActive(id)); // Verify it is not on the pushed_streams_ list. ActiveStreamList::iterator it; for (it = pushed_streams_.begin(); it != pushed_streams_.end(); ++it) { - scoped_refptr<FlipStream> curr = *it; + scoped_refptr<SpdyStream> curr = *it; if (id == curr->stream_id()) { pushed_streams_.erase(it); break; @@ -800,12 +800,12 @@ void FlipSession::DeactivateStream(flip::FlipStreamId id) { active_streams_.erase(id); } -scoped_refptr<FlipStream> FlipSession::GetPushStream(const std::string& path) { - static StatsCounter used_push_streams("flip.claimed_push_streams"); +scoped_refptr<SpdyStream> SpdySession::GetPushStream(const std::string& path) { + static StatsCounter used_push_streams("spdy.claimed_push_streams"); LOG(INFO) << "Looking for push stream: " << path; - scoped_refptr<FlipStream> stream; + scoped_refptr<SpdyStream> stream; // We just walk a linear list here. ActiveStreamList::iterator it; @@ -823,7 +823,7 @@ scoped_refptr<FlipStream> FlipSession::GetPushStream(const std::string& path) { return stream; } -void FlipSession::GetSSLInfo(SSLInfo* ssl_info) { +void SpdySession::GetSSLInfo(SSLInfo* ssl_info) { if (is_secure_) { SSLClientSocket* ssl_socket = reinterpret_cast<SSLClientSocket*>(connection_->socket()); @@ -831,15 +831,15 @@ void FlipSession::GetSSLInfo(SSLInfo* ssl_info) { } } -void FlipSession::OnError(flip::FlipFramer* framer) { - LOG(ERROR) << "FlipSession error: " << framer->error_code(); - CloseSessionOnError(net::ERR_FLIP_PROTOCOL_ERROR); +void SpdySession::OnError(spdy::SpdyFramer* framer) { + LOG(ERROR) << "SpdySession error: " << framer->error_code(); + CloseSessionOnError(net::ERR_SPDY_PROTOCOL_ERROR); } -void FlipSession::OnStreamFrameData(flip::FlipStreamId stream_id, +void SpdySession::OnStreamFrameData(spdy::SpdyStreamId stream_id, const char* data, size_t len) { - LOG(INFO) << "Flip data for stream " << stream_id << ", " << len << " bytes"; + LOG(INFO) << "Spdy data for stream " << stream_id << ", " << len << " bytes"; bool valid_stream = IsStreamActive(stream_id); if (!valid_stream) { // NOTE: it may just be that the stream was cancelled. @@ -847,16 +847,16 @@ void FlipSession::OnStreamFrameData(flip::FlipStreamId stream_id, return; } - scoped_refptr<FlipStream> stream = active_streams_[stream_id]; + scoped_refptr<SpdyStream> stream = active_streams_[stream_id]; bool success = stream->OnDataReceived(data, len); // |len| == 0 implies a closed stream. if (!success || !len) DeactivateStream(stream_id); } -void FlipSession::OnSyn(const flip::FlipSynStreamControlFrame* frame, - const flip::FlipHeaderBlock* headers) { - flip::FlipStreamId stream_id = frame->stream_id(); +void SpdySession::OnSyn(const spdy::SpdySynStreamControlFrame* frame, + const spdy::SpdyHeaderBlock* headers) { + spdy::SpdyStreamId stream_id = frame->stream_id(); // Server-initiated streams should have even sequence numbers. if ((stream_id & 0x1) != 0) { @@ -871,10 +871,10 @@ void FlipSession::OnSyn(const flip::FlipSynStreamControlFrame* frame, streams_pushed_count_++; - LOG(INFO) << "FlipSession: Syn received for stream: " << stream_id; + LOG(INFO) << "SpdySession: Syn received for stream: " << stream_id; - LOG(INFO) << "FLIP SYN RESPONSE HEADERS -----------------------"; - DumpFlipHeaders(*headers); + LOG(INFO) << "SPDY SYN RESPONSE HEADERS -----------------------"; + DumpSpdyHeaders(*headers); // TODO(mbelshe): DCHECK that this is a GET method? @@ -888,7 +888,7 @@ void FlipSession::OnSyn(const flip::FlipSynStreamControlFrame* frame, return; } - scoped_refptr<FlipStream> stream; + scoped_refptr<SpdyStream> stream; // Check if we already have a delegate awaiting this stream. PendingStreamMap::iterator it; @@ -904,15 +904,15 @@ void FlipSession::OnSyn(const flip::FlipSynStreamControlFrame* frame, stream->set_stream_id(stream_id); } else { // TODO(mbelshe): can we figure out how to use a LoadLog here? - stream = new FlipStream(this, stream_id, true, NULL); + stream = new SpdyStream(this, stream_id, true, NULL); // A new HttpResponseInfo object needs to be generated so the call to // OnResponseReceived below has something to fill in. - // When a FlipNetworkTransaction is created for this resource, the + // When a SpdyNetworkTransaction is created for this resource, the // response_info is copied over and this version is destroyed. // // TODO(cbentzel): Minimize allocations and copies of HttpResponseInfo - // object. Should it just be part of FlipStream? + // object. Should it just be part of SpdyStream? HttpResponseInfo* response_info = new HttpResponseInfo(); stream->set_response_info_pointer(response_info); } @@ -926,9 +926,9 @@ void FlipSession::OnSyn(const flip::FlipSynStreamControlFrame* frame, // TODO(mbelshe): For now we convert from our nice hash map back // to a string of headers; this is because the HttpResponseInfo - // is a bit rigid for its http (non-flip) design. + // is a bit rigid for its http (non-spdy) design. HttpResponseInfo response; - if (FlipHeadersToHttpResponse(*headers, &response)) { + if (SpdyHeadersToHttpResponse(*headers, &response)) { GetSSLInfo(&response.ssl_info); stream->OnResponseReceived(response); } else { @@ -939,14 +939,14 @@ void FlipSession::OnSyn(const flip::FlipSynStreamControlFrame* frame, LOG(INFO) << "Got pushed stream for " << stream->path(); - static StatsCounter push_requests("flip.pushed_streams"); + static StatsCounter push_requests("spdy.pushed_streams"); push_requests.Increment(); } -void FlipSession::OnSynReply(const flip::FlipSynReplyControlFrame* frame, - const flip::FlipHeaderBlock* headers) { +void SpdySession::OnSynReply(const spdy::SpdySynReplyControlFrame* frame, + const spdy::SpdyHeaderBlock* headers) { DCHECK(headers); - flip::FlipStreamId stream_id = frame->stream_id(); + spdy::SpdyStreamId stream_id = frame->stream_id(); bool valid_stream = IsStreamActive(stream_id); if (!valid_stream) { // NOTE: it may just be that the stream was cancelled. @@ -954,13 +954,13 @@ void FlipSession::OnSynReply(const flip::FlipSynReplyControlFrame* frame, return; } - LOG(INFO) << "FLIP SYN_REPLY RESPONSE HEADERS for stream: " << stream_id; - DumpFlipHeaders(*headers); + LOG(INFO) << "SPDY SYN_REPLY RESPONSE HEADERS for stream: " << stream_id; + DumpSpdyHeaders(*headers); // We record content declared as being pushed so that we don't // request a duplicate stream which is already scheduled to be // sent to us. - flip::FlipHeaderBlock::const_iterator it; + spdy::SpdyHeaderBlock::const_iterator it; it = headers->find("X-Associated-Content"); if (it != headers->end()) { const std::string& content = it->second; @@ -985,11 +985,11 @@ void FlipSession::OnSynReply(const flip::FlipSynReplyControlFrame* frame, } while (start < content.length()); } - scoped_refptr<FlipStream> stream = active_streams_[stream_id]; + scoped_refptr<SpdyStream> stream = active_streams_[stream_id]; CHECK(stream->stream_id() == stream_id); CHECK(!stream->cancelled()); HttpResponseInfo response; - if (FlipHeadersToHttpResponse(*headers, &response)) { + if (SpdyHeadersToHttpResponse(*headers, &response)) { GetSSLInfo(&response.ssl_info); stream->OnResponseReceived(response); } else { @@ -998,54 +998,54 @@ void FlipSession::OnSynReply(const flip::FlipSynReplyControlFrame* frame, } } -void FlipSession::OnControl(const flip::FlipControlFrame* frame) { - flip::FlipHeaderBlock headers; +void SpdySession::OnControl(const spdy::SpdyControlFrame* frame) { + spdy::SpdyHeaderBlock headers; uint32 type = frame->type(); - if (type == flip::SYN_STREAM || type == flip::SYN_REPLY) { - if (!flip_framer_.ParseHeaderBlock(frame, &headers)) { - LOG(WARNING) << "Could not parse Flip Control Frame Header"; + if (type == spdy::SYN_STREAM || type == spdy::SYN_REPLY) { + if (!spdy_framer_.ParseHeaderBlock(frame, &headers)) { + LOG(WARNING) << "Could not parse Spdy Control Frame Header"; // TODO(mbelshe): Error the session? return; } } switch (type) { - case flip::SYN_STREAM: - LOG(INFO) << "Flip SynStream for stream " << frame->stream_id(); - OnSyn(reinterpret_cast<const flip::FlipSynStreamControlFrame*>(frame), + case spdy::SYN_STREAM: + LOG(INFO) << "Spdy SynStream for stream " << frame->stream_id(); + OnSyn(reinterpret_cast<const spdy::SpdySynStreamControlFrame*>(frame), &headers); break; - case flip::SYN_REPLY: - LOG(INFO) << "Flip SynReply for stream " << frame->stream_id(); + case spdy::SYN_REPLY: + LOG(INFO) << "Spdy SynReply for stream " << frame->stream_id(); OnSynReply( - reinterpret_cast<const flip::FlipSynReplyControlFrame*>(frame), + reinterpret_cast<const spdy::SpdySynReplyControlFrame*>(frame), &headers); break; - case flip::FIN_STREAM: - LOG(INFO) << "Flip Fin for stream " << frame->stream_id(); - OnFin(reinterpret_cast<const flip::FlipFinStreamControlFrame*>(frame)); + case spdy::FIN_STREAM: + LOG(INFO) << "Spdy Fin for stream " << frame->stream_id(); + OnFin(reinterpret_cast<const spdy::SpdyFinStreamControlFrame*>(frame)); break; default: DCHECK(false); // Error! } } -void FlipSession::OnFin(const flip::FlipFinStreamControlFrame* frame) { - flip::FlipStreamId stream_id = frame->stream_id(); +void SpdySession::OnFin(const spdy::SpdyFinStreamControlFrame* frame) { + spdy::SpdyStreamId stream_id = frame->stream_id(); bool valid_stream = IsStreamActive(stream_id); if (!valid_stream) { // NOTE: it may just be that the stream was cancelled. LOG(WARNING) << "Received FIN for invalid stream" << stream_id; return; } - scoped_refptr<FlipStream> stream = active_streams_[stream_id]; + scoped_refptr<SpdyStream> stream = active_streams_[stream_id]; CHECK(stream->stream_id() == stream_id); CHECK(!stream->cancelled()); if (frame->status() == 0) { stream->OnDataReceived(NULL, 0); } else { - LOG(ERROR) << "Flip stream closed: " << frame->status(); - // TODO(mbelshe): Map from Flip-protocol errors to something sensical. + LOG(ERROR) << "Spdy stream closed: " << frame->status(); + // TODO(mbelshe): Map from Spdy-protocol errors to something sensical. // For now, it doesn't matter much - it is a protocol error. stream->OnClose(ERR_FAILED); } diff --git a/net/spdy/spdy_session.h b/net/spdy/spdy_session.h index e91753d..66c8a3c 100644 --- a/net/spdy/spdy_session.h +++ b/net/spdy/spdy_session.h @@ -28,23 +28,23 @@ namespace net { -class FlipStream; +class SpdyStream; class HttpNetworkSession; class HttpRequestInfo; class HttpResponseInfo; class LoadLog; class SSLInfo; -class FlipSession : public base::RefCounted<FlipSession>, - public flip::FlipFramerVisitorInterface { +class SpdySession : public base::RefCounted<SpdySession>, + public spdy::SpdyFramerVisitorInterface { public: - // Get the domain for this FlipSession. + // Get the domain for this SpdySession. const std::string& domain() const { return domain_; } - // Connect the FLIP Socket. + // Connect the Spdy Socket. // Returns net::Error::OK on success. // Note that this call does not wait for the connect to complete. Callers can - // immediately start using the FlipSession while it connects. + // immediately start using the SpdySession while it connects. net::Error Connect(const std::string& group_name, const HostResolver::RequestInfo& host, RequestPriority priority, @@ -56,19 +56,19 @@ class FlipSession : public base::RefCounted<FlipSession>, // might also not have initiated the stream yet, but indicated it will via // X-Associated-Content. // Returns the new or existing stream. Never returns NULL. - scoped_refptr<FlipStream> GetOrCreateStream(const HttpRequestInfo& request, + scoped_refptr<SpdyStream> GetOrCreateStream(const HttpRequestInfo& request, const UploadDataStream* upload_data, LoadLog* log); // Write a data frame to the stream. // Used to create and queue a data frame for the given stream. - int WriteStreamData(flip::FlipStreamId stream_id, net::IOBuffer* data, + int WriteStreamData(spdy::SpdyStreamId stream_id, net::IOBuffer* data, int len); // Cancel a stream. - bool CancelStream(flip::FlipStreamId stream_id); + bool CancelStream(spdy::SpdyStreamId stream_id); // Check if a stream is active. - bool IsStreamActive(flip::FlipStreamId stream_id) const; + bool IsStreamActive(spdy::SpdyStreamId stream_id) const; // The LoadState is used for informing the user of the current network // status, such as "resolving host", "connecting", etc. @@ -79,7 +79,7 @@ class FlipSession : public base::RefCounted<FlipSession>, static bool SSLMode() { return use_ssl_; } protected: - friend class FlipSessionPool; + friend class SpdySessionPool; enum State { IDLE, @@ -89,41 +89,41 @@ class FlipSession : public base::RefCounted<FlipSession>, }; // Provide access to the framer for testing. - flip::FlipFramer* GetFramer() { return &flip_framer_; } + spdy::SpdyFramer* GetFramer() { return &spdy_framer_; } - // Create a new FlipSession. + // Create a new SpdySession. // |host| is the hostname that this session connects to. - FlipSession(const std::string& host, HttpNetworkSession* session); + SpdySession(const std::string& host, HttpNetworkSession* session); // Closes all open streams. Used as part of shutdown. void CloseAllStreams(net::Error code); private: - friend class base::RefCounted<FlipSession>; + friend class base::RefCounted<SpdySession>; - typedef std::map<int, scoped_refptr<FlipStream> > ActiveStreamMap; - typedef std::list<scoped_refptr<FlipStream> > ActiveStreamList; - typedef std::map<std::string, scoped_refptr<FlipStream> > PendingStreamMap; - typedef std::priority_queue<FlipIOBuffer> OutputQueue; + typedef std::map<int, scoped_refptr<SpdyStream> > ActiveStreamMap; + typedef std::list<scoped_refptr<SpdyStream> > ActiveStreamList; + typedef std::map<std::string, scoped_refptr<SpdyStream> > PendingStreamMap; + typedef std::priority_queue<SpdyIOBuffer> OutputQueue; - virtual ~FlipSession(); + virtual ~SpdySession(); - // Used by FlipSessionPool to initialize with a pre-existing socket. + // Used by SpdySessionPool to initialize with a pre-existing socket. void InitializeWithSocket(ClientSocketHandle* connection); - // FlipFramerVisitorInterface - virtual void OnError(flip::FlipFramer*); - virtual void OnStreamFrameData(flip::FlipStreamId stream_id, + // SpdyFramerVisitorInterface + virtual void OnError(spdy::SpdyFramer*); + virtual void OnStreamFrameData(spdy::SpdyStreamId stream_id, const char* data, size_t len); - virtual void OnControl(const flip::FlipControlFrame* frame); + virtual void OnControl(const spdy::SpdyControlFrame* frame); // Control frame handlers. - void OnSyn(const flip::FlipSynStreamControlFrame* frame, - const flip::FlipHeaderBlock* headers); - void OnSynReply(const flip::FlipSynReplyControlFrame* frame, - const flip::FlipHeaderBlock* headers); - void OnFin(const flip::FlipFinStreamControlFrame* frame); + void OnSyn(const spdy::SpdySynStreamControlFrame* frame, + const spdy::SpdyHeaderBlock* headers); + void OnSynReply(const spdy::SpdySynReplyControlFrame* frame, + const spdy::SpdyHeaderBlock* headers); + void OnFin(const spdy::SpdyFinStreamControlFrame* frame); // IO Callbacks void OnTCPConnect(int result); @@ -148,21 +148,21 @@ class FlipSession : public base::RefCounted<FlipSession>, void CloseSessionOnError(net::Error err); // Track active streams in the active stream list. - void ActivateStream(FlipStream* stream); - void DeactivateStream(flip::FlipStreamId id); + void ActivateStream(SpdyStream* stream); + void DeactivateStream(spdy::SpdyStreamId id); // Check if we have a pending pushed-stream for this url // Returns the stream if found (and returns it from the pending // list), returns NULL otherwise. - scoped_refptr<FlipStream> GetPushStream(const std::string& url); + scoped_refptr<SpdyStream> GetPushStream(const std::string& url); void GetSSLInfo(SSLInfo* ssl_info); - // Callbacks for the Flip session. - CompletionCallbackImpl<FlipSession> connect_callback_; - CompletionCallbackImpl<FlipSession> ssl_connect_callback_; - CompletionCallbackImpl<FlipSession> read_callback_; - CompletionCallbackImpl<FlipSession> write_callback_; + // Callbacks for the Spdy session. + CompletionCallbackImpl<SpdySession> connect_callback_; + CompletionCallbackImpl<SpdySession> ssl_connect_callback_; + CompletionCallbackImpl<SpdySession> read_callback_; + CompletionCallbackImpl<SpdySession> write_callback_; // The domain this session is connected to. std::string domain_; @@ -185,7 +185,7 @@ class FlipSession : public base::RefCounted<FlipSession>, // one list, but not the other. // Map from stream id to all active streams. Streams are active in the sense - // that they have a consumer (typically FlipNetworkTransaction and regardless + // that they have a consumer (typically SpdyNetworkTransaction and regardless // of whether or not there is currently any ongoing IO [might be waiting for // the server to start pushing the stream]) or there are still network events // incoming even though the consumer has already gone away (cancellation). @@ -206,16 +206,16 @@ class FlipSession : public base::RefCounted<FlipSession>, // The packet we are currently sending. bool write_pending_; // Will be true when a write is in progress. - FlipIOBuffer in_flight_write_; // This is the write buffer in progress. + SpdyIOBuffer in_flight_write_; // This is the write buffer in progress. // Flag if we have a pending message scheduled for WriteSocket. bool delayed_write_pending_; - // Flag if we're using an SSL connection for this FlipSession. + // Flag if we're using an SSL connection for this SpdySession. bool is_secure_; - // Flip Frame state. - flip::FlipFramer flip_framer_; + // Spdy Frame state. + spdy::SpdyFramer spdy_framer_; // If an error has occurred on the session, the session is effectively // dead. Record this error here. When no error has occurred, |error_| will diff --git a/net/spdy/spdy_session_pool.cc b/net/spdy/spdy_session_pool.cc index 13d9942..67625fc 100644 --- a/net/spdy/spdy_session_pool.cc +++ b/net/spdy/spdy_session_pool.cc @@ -12,19 +12,19 @@ namespace net { // The maximum number of sessions to open to a single domain. static const size_t kMaxSessionsPerDomain = 1; -FlipSessionPool::FlipSessionPool() {} -FlipSessionPool::~FlipSessionPool() { +SpdySessionPool::SpdySessionPool() {} +SpdySessionPool::~SpdySessionPool() { CloseAllSessions(); } -scoped_refptr<FlipSession> FlipSessionPool::Get( +scoped_refptr<SpdySession> SpdySessionPool::Get( const HostResolver::RequestInfo& info, HttpNetworkSession* session) { const std::string& domain = info.hostname(); - scoped_refptr<FlipSession> flip_session; - FlipSessionList* list = GetSessionList(domain); + scoped_refptr<SpdySession> spdy_session; + SpdySessionList* list = GetSessionList(domain); if (list) { if (list->size() >= kMaxSessionsPerDomain) { - flip_session = list->front(); + spdy_session = list->front(); list->pop_front(); } } else { @@ -32,70 +32,70 @@ scoped_refptr<FlipSession> FlipSessionPool::Get( } DCHECK(list); - if (!flip_session) - flip_session = new FlipSession(domain, session); + if (!spdy_session) + spdy_session = new SpdySession(domain, session); - DCHECK(flip_session); - list->push_back(flip_session); + DCHECK(spdy_session); + list->push_back(spdy_session); DCHECK(list->size() <= kMaxSessionsPerDomain); - return flip_session; + return spdy_session; } -scoped_refptr<FlipSession> FlipSessionPool::GetFlipSessionFromSocket( +scoped_refptr<SpdySession> SpdySessionPool::GetSpdySessionFromSocket( const HostResolver::RequestInfo& info, HttpNetworkSession* session, ClientSocketHandle* connection) { const std::string& domain = info.hostname(); - FlipSessionList* list = GetSessionList(domain); + SpdySessionList* list = GetSessionList(domain); if (!list) list = AddSessionList(domain); DCHECK(list->empty()); - scoped_refptr<FlipSession> flip_session(new FlipSession(domain, session)); - flip_session->InitializeWithSocket(connection); - list->push_back(flip_session); - return flip_session; + scoped_refptr<SpdySession> spdy_session(new SpdySession(domain, session)); + spdy_session->InitializeWithSocket(connection); + list->push_back(spdy_session); + return spdy_session; } -bool FlipSessionPool::HasSession(const HostResolver::RequestInfo& info) const { +bool SpdySessionPool::HasSession(const HostResolver::RequestInfo& info) const { const std::string& domain = info.hostname(); if (GetSessionList(domain)) return true; return false; } -void FlipSessionPool::Remove(const scoped_refptr<FlipSession>& session) { +void SpdySessionPool::Remove(const scoped_refptr<SpdySession>& session) { std::string domain = session->domain(); - FlipSessionList* list = GetSessionList(domain); + SpdySessionList* list = GetSessionList(domain); CHECK(list); list->remove(session); if (list->empty()) RemoveSessionList(domain); } -FlipSessionPool::FlipSessionList* - FlipSessionPool::AddSessionList(const std::string& domain) { +SpdySessionPool::SpdySessionList* + SpdySessionPool::AddSessionList(const std::string& domain) { DCHECK(sessions_.find(domain) == sessions_.end()); - return sessions_[domain] = new FlipSessionList(); + return sessions_[domain] = new SpdySessionList(); } -FlipSessionPool::FlipSessionList* - FlipSessionPool::GetSessionList(const std::string& domain) { - FlipSessionsMap::iterator it = sessions_.find(domain); +SpdySessionPool::SpdySessionList* + SpdySessionPool::GetSessionList(const std::string& domain) { + SpdySessionsMap::iterator it = sessions_.find(domain); if (it == sessions_.end()) return NULL; return it->second; } -const FlipSessionPool::FlipSessionList* - FlipSessionPool::GetSessionList(const std::string& domain) const { - FlipSessionsMap::const_iterator it = sessions_.find(domain); +const SpdySessionPool::SpdySessionList* + SpdySessionPool::GetSessionList(const std::string& domain) const { + SpdySessionsMap::const_iterator it = sessions_.find(domain); if (it == sessions_.end()) return NULL; return it->second; } -void FlipSessionPool::RemoveSessionList(const std::string& domain) { - FlipSessionList* list = GetSessionList(domain); +void SpdySessionPool::RemoveSessionList(const std::string& domain) { + SpdySessionList* list = GetSessionList(domain); if (list) { delete list; sessions_.erase(domain); @@ -104,13 +104,13 @@ void FlipSessionPool::RemoveSessionList(const std::string& domain) { } } -void FlipSessionPool::CloseAllSessions() { +void SpdySessionPool::CloseAllSessions() { while (sessions_.size()) { - FlipSessionList* list = sessions_.begin()->second; + SpdySessionList* list = sessions_.begin()->second; DCHECK(list); sessions_.erase(sessions_.begin()->first); while (list->size()) { - scoped_refptr<FlipSession> session = list->front(); + scoped_refptr<SpdySession> session = list->front(); list->pop_front(); session->CloseAllStreams(net::ERR_ABORTED); } diff --git a/net/spdy/spdy_session_pool.h b/net/spdy/spdy_session_pool.h index 98d78dd..108f3e7 100644 --- a/net/spdy/spdy_session_pool.h +++ b/net/spdy/spdy_session_pool.h @@ -16,25 +16,25 @@ namespace net { class ClientSocketHandle; -class FlipSession; class HttpNetworkSession; +class SpdySession; -// This is a very simple pool for open FlipSessions. +// This is a very simple pool for open SpdySessions. // TODO(mbelshe): Make this production ready. -class FlipSessionPool : public base::RefCounted<FlipSessionPool> { +class SpdySessionPool : public base::RefCounted<SpdySessionPool> { public: - FlipSessionPool(); + SpdySessionPool(); - // Either returns an existing FlipSession or creates a new FlipSession for + // Either returns an existing SpdySession or creates a new SpdySession for // use. - scoped_refptr<FlipSession> Get( + scoped_refptr<SpdySession> Get( const HostResolver::RequestInfo& info, HttpNetworkSession* session); - // Builds a FlipSession from an existing socket. Users should try calling - // Get() first to use an existing FlipSession so we don't get multiple - // FlipSessions per domain. Note that ownership of |connection| is - // transferred from the caller to the FlipSession. - scoped_refptr<FlipSession> GetFlipSessionFromSocket( + // Builds a SpdySession from an existing socket. Users should try calling + // Get() first to use an existing SpdySession so we don't get multiple + // SpdySessions per domain. Note that ownership of |connection| is + // transferred from the caller to the SpdySession. + scoped_refptr<SpdySession> GetSpdySessionFromSocket( const HostResolver::RequestInfo& info, HttpNetworkSession* session, ClientSocketHandle* connection); @@ -43,32 +43,32 @@ class FlipSessionPool : public base::RefCounted<FlipSessionPool> { // should be creating a new session. bool HasSession(const HostResolver::RequestInfo& info) const; - // Close all Flip Sessions; used for debugging. + // Close all Spdy Sessions; used for debugging. void CloseAllSessions(); private: - friend class base::RefCounted<FlipSessionPool>; - friend class FlipSession; // Needed for Remove(). - friend class FlipSessionPoolPeer; // For testing. + friend class base::RefCounted<SpdySessionPool>; + friend class SpdySession; // Needed for Remove(). + friend class SpdySessionPoolPeer; // For testing. - typedef std::list<scoped_refptr<FlipSession> > FlipSessionList; - typedef std::map<std::string, FlipSessionList*> FlipSessionsMap; + typedef std::list<scoped_refptr<SpdySession> > SpdySessionList; + typedef std::map<std::string, SpdySessionList*> SpdySessionsMap; - virtual ~FlipSessionPool(); + virtual ~SpdySessionPool(); - // Removes a FlipSession from the FlipSessionPool. - void Remove(const scoped_refptr<FlipSession>& session); + // Removes a SpdySession from the SpdySessionPool. + void Remove(const scoped_refptr<SpdySession>& session); // Helper functions for manipulating the lists. - FlipSessionList* AddSessionList(const std::string& domain); - FlipSessionList* GetSessionList(const std::string& domain); - const FlipSessionList* GetSessionList(const std::string& domain) const; + SpdySessionList* AddSessionList(const std::string& domain); + SpdySessionList* GetSessionList(const std::string& domain); + const SpdySessionList* GetSessionList(const std::string& domain) const; void RemoveSessionList(const std::string& domain); // This is our weak session pool - one session per domain. - FlipSessionsMap sessions_; + SpdySessionsMap sessions_; - DISALLOW_COPY_AND_ASSIGN(FlipSessionPool); + DISALLOW_COPY_AND_ASSIGN(SpdySessionPool); }; } // namespace net diff --git a/net/spdy/spdy_session_unittest.cc b/net/spdy/spdy_session_unittest.cc index 57d6c2d..5392363 100644 --- a/net/spdy/spdy_session_unittest.cc +++ b/net/spdy/spdy_session_unittest.cc @@ -12,18 +12,18 @@ namespace net { -class FlipSessionTest : public PlatformTest { +class SpdySessionTest : public PlatformTest { public: }; -// Test the FlipIOBuffer class. -TEST_F(FlipSessionTest, FlipIOBuffer) { - std::priority_queue<FlipIOBuffer> queue_; +// Test the SpdyIOBuffer class. +TEST_F(SpdySessionTest, SpdyIOBuffer) { + std::priority_queue<SpdyIOBuffer> queue_; const size_t kQueueSize = 100; // Insert 100 items; pri 100 to 1. for (size_t index = 0; index < kQueueSize; ++index) { - FlipIOBuffer buffer(new IOBuffer(), 0, kQueueSize - index, NULL); + SpdyIOBuffer buffer(new IOBuffer(), 0, kQueueSize - index, NULL); queue_.push(buffer); } @@ -32,14 +32,14 @@ TEST_F(FlipSessionTest, FlipIOBuffer) { IOBufferWithSize* buffers[kNumDuplicates]; for (size_t index = 0; index < kNumDuplicates; ++index) { buffers[index] = new IOBufferWithSize(index+1); - queue_.push(FlipIOBuffer(buffers[index], buffers[index]->size(), 0, NULL)); + queue_.push(SpdyIOBuffer(buffers[index], buffers[index]->size(), 0, NULL)); } EXPECT_EQ(kQueueSize + kNumDuplicates, queue_.size()); // Verify the P0 items come out in FIFO order. for (size_t index = 0; index < kNumDuplicates; ++index) { - FlipIOBuffer buffer = queue_.top(); + SpdyIOBuffer buffer = queue_.top(); EXPECT_EQ(0, buffer.priority()); EXPECT_EQ(index + 1, buffer.size()); queue_.pop(); @@ -47,7 +47,7 @@ TEST_F(FlipSessionTest, FlipIOBuffer) { int priority = 1; while (queue_.size()) { - FlipIOBuffer buffer = queue_.top(); + SpdyIOBuffer buffer = queue_.top(); EXPECT_EQ(priority++, buffer.priority()); queue_.pop(); } diff --git a/net/spdy/spdy_stream.cc b/net/spdy/spdy_stream.cc index 78d263d..9625040 100644 --- a/net/spdy/spdy_stream.cc +++ b/net/spdy/spdy_stream.cc @@ -11,7 +11,7 @@ namespace net { -FlipStream::FlipStream(FlipSession* session, flip::FlipStreamId stream_id, +SpdyStream::SpdyStream(SpdySession* session, spdy::SpdyStreamId stream_id, bool pushed, LoadLog* log) : stream_id_(stream_id), priority_(0), @@ -33,8 +33,8 @@ FlipStream::FlipStream(FlipSession* session, flip::FlipStreamId stream_id, recv_bytes_(0), histograms_recorded_(false) {} -FlipStream::~FlipStream() { - DLOG(INFO) << "Deleting FlipStream for stream " << stream_id_; +SpdyStream::~SpdyStream() { + DLOG(INFO) << "Deleting SpdyStream for stream " << stream_id_; // TODO(willchan): We're still calling CancelStream() too many times, because // inactive pending/pushed streams will still have stream_id_ set. @@ -45,19 +45,19 @@ FlipStream::~FlipStream() { } } -uint64 FlipStream::GetUploadProgress() const { +uint64 SpdyStream::GetUploadProgress() const { if (!request_body_stream_.get()) return 0; return request_body_stream_->position(); } -const HttpResponseInfo* FlipStream::GetResponseInfo() const { +const HttpResponseInfo* SpdyStream::GetResponseInfo() const { return response_; } -int FlipStream::ReadResponseHeaders(CompletionCallback* callback) { - // Note: The FlipStream may have already received the response headers, so +int SpdyStream::ReadResponseHeaders(CompletionCallback* callback) { + // Note: The SpdyStream may have already received the response headers, so // this call may complete synchronously. CHECK(callback); CHECK(io_state_ == STATE_NONE); @@ -73,7 +73,7 @@ int FlipStream::ReadResponseHeaders(CompletionCallback* callback) { return ERR_IO_PENDING; } -int FlipStream::ReadResponseBody( +int SpdyStream::ReadResponseBody( IOBuffer* buf, int buf_len, CompletionCallback* callback) { DCHECK_EQ(io_state_, STATE_NONE); CHECK(buf); @@ -118,7 +118,7 @@ int FlipStream::ReadResponseBody( return ERR_IO_PENDING; } -int FlipStream::SendRequest(UploadDataStream* upload_data, +int SpdyStream::SendRequest(UploadDataStream* upload_data, HttpResponseInfo* response, CompletionCallback* callback) { CHECK(callback); @@ -158,14 +158,14 @@ int FlipStream::SendRequest(UploadDataStream* upload_data, return result; } -void FlipStream::Cancel() { +void SpdyStream::Cancel() { cancelled_ = true; user_callback_ = NULL; session_->CancelStream(stream_id_); } -void FlipStream::OnResponseReceived(const HttpResponseInfo& response) { +void SpdyStream::OnResponseReceived(const HttpResponseInfo& response) { metrics_.StartStream(); CHECK(!response_->headers); @@ -179,7 +179,7 @@ void FlipStream::OnResponseReceived(const HttpResponseInfo& response) { CHECK(pushed_); io_state_ = STATE_READ_HEADERS; } else if (io_state_ == STATE_READ_HEADERS_COMPLETE) { - // This FlipStream could be in this state in both true and false pushed_ + // This SpdyStream could be in this state in both true and false pushed_ // conditions. // The false pushed_ condition (client request) will always go through // this state. @@ -196,9 +196,9 @@ void FlipStream::OnResponseReceived(const HttpResponseInfo& response) { DoCallback(rv); } -bool FlipStream::OnDataReceived(const char* data, int length) { +bool SpdyStream::OnDataReceived(const char* data, int length) { DCHECK_GE(length, 0); - LOG(INFO) << "FlipStream: Data (" << length << " bytes) received for " + LOG(INFO) << "SpdyStream: Data (" << length << " bytes) received for " << stream_id_; // If we don't have a response, then the SYN_REPLY did not come through. @@ -236,7 +236,7 @@ bool FlipStream::OnDataReceived(const char* data, int length) { response_body_.push_back(io_buffer); } - // Note that data may be received for a FlipStream prior to the user calling + // Note that data may be received for a SpdyStream prior to the user calling // ReadResponseBody(), therefore user_callback_ may be NULL. This may often // happen for server initiated streams. if (user_callback_) { @@ -255,7 +255,7 @@ bool FlipStream::OnDataReceived(const char* data, int length) { return true; } -void FlipStream::OnWriteComplete(int status) { +void SpdyStream::OnWriteComplete(int status) { // TODO(mbelshe): Check for cancellation here. If we're cancelled, we // should discontinue the DoLoop. @@ -265,7 +265,7 @@ void FlipStream::OnWriteComplete(int status) { DoLoop(status); } -void FlipStream::OnClose(int status) { +void SpdyStream::OnClose(int status) { response_complete_ = true; response_status_ = status; stream_id_ = 0; @@ -276,7 +276,7 @@ void FlipStream::OnClose(int status) { UpdateHistograms(); } -int FlipStream::DoLoop(int result) { +int SpdyStream::DoLoop(int result) { do { State state = io_state_; io_state_ = STATE_NONE; @@ -285,34 +285,34 @@ int FlipStream::DoLoop(int result) { case STATE_SEND_HEADERS: CHECK(result == OK); LoadLog::BeginEvent(load_log_, - LoadLog::TYPE_FLIP_STREAM_SEND_HEADERS); + LoadLog::TYPE_SPDY_STREAM_SEND_HEADERS); result = DoSendHeaders(); break; case STATE_SEND_HEADERS_COMPLETE: LoadLog::EndEvent(load_log_, - LoadLog::TYPE_FLIP_STREAM_SEND_HEADERS); + LoadLog::TYPE_SPDY_STREAM_SEND_HEADERS); result = DoSendHeadersComplete(result); break; case STATE_SEND_BODY: CHECK(result == OK); LoadLog::BeginEvent(load_log_, - LoadLog::TYPE_FLIP_STREAM_SEND_BODY); + LoadLog::TYPE_SPDY_STREAM_SEND_BODY); result = DoSendBody(); break; case STATE_SEND_BODY_COMPLETE: LoadLog::EndEvent(load_log_, - LoadLog::TYPE_FLIP_STREAM_SEND_BODY); + LoadLog::TYPE_SPDY_STREAM_SEND_BODY); result = DoSendBodyComplete(result); break; case STATE_READ_HEADERS: CHECK(result == OK); LoadLog::BeginEvent(load_log_, - LoadLog::TYPE_FLIP_STREAM_READ_HEADERS); + LoadLog::TYPE_SPDY_STREAM_READ_HEADERS); result = DoReadHeaders(); break; case STATE_READ_HEADERS_COMPLETE: LoadLog::EndEvent(load_log_, - LoadLog::TYPE_FLIP_STREAM_READ_HEADERS); + LoadLog::TYPE_SPDY_STREAM_READ_HEADERS); result = DoReadHeadersComplete(result); break; @@ -322,12 +322,12 @@ int FlipStream::DoLoop(int result) { // to do this is for consistency with the Http code. case STATE_READ_BODY: LoadLog::BeginEvent(load_log_, - LoadLog::TYPE_FLIP_STREAM_READ_BODY); + LoadLog::TYPE_SPDY_STREAM_READ_BODY); result = DoReadBody(); break; case STATE_READ_BODY_COMPLETE: LoadLog::EndEvent(load_log_, - LoadLog::TYPE_FLIP_STREAM_READ_BODY); + LoadLog::TYPE_SPDY_STREAM_READ_BODY); result = DoReadBodyComplete(result); break; case STATE_DONE: @@ -342,7 +342,7 @@ int FlipStream::DoLoop(int result) { return result; } -void FlipStream::DoCallback(int rv) { +void SpdyStream::DoCallback(int rv) { CHECK(rv != ERR_IO_PENDING); CHECK(user_callback_); @@ -352,8 +352,8 @@ void FlipStream::DoCallback(int rv) { c->Run(rv); } -int FlipStream::DoSendHeaders() { - // The FlipSession will always call us back when the send is complete. +int SpdyStream::DoSendHeaders() { + // The SpdySession will always call us back when the send is complete. // TODO(willchan): This code makes the assumption that for the non-push stream // case, the client code calls SendRequest() after creating the stream and // before yielding back to the MessageLoop. This is true in the current code, @@ -363,7 +363,7 @@ int FlipStream::DoSendHeaders() { return ERR_IO_PENDING; } -int FlipStream::DoSendHeadersComplete(int result) { +int SpdyStream::DoSendHeadersComplete(int result) { if (result < 0) return result; @@ -381,7 +381,7 @@ int FlipStream::DoSendHeadersComplete(int result) { // DoSendBody is called to send the optional body for the request. This call // will also be called as each write of a chunk of the body completes. -int FlipStream::DoSendBody() { +int SpdyStream::DoSendBody() { // If we're already in the STATE_SENDING_BODY state, then we've already // sent a portion of the body. In that case, we need to first consume // the bytes written in the body stream. Note that the bytes written is @@ -394,7 +394,7 @@ int FlipStream::DoSendBody() { buf_len); } -int FlipStream::DoSendBodyComplete(int result) { +int SpdyStream::DoSendBodyComplete(int result) { if (result < 0) return result; @@ -410,28 +410,28 @@ int FlipStream::DoSendBodyComplete(int result) { return OK; } -int FlipStream::DoReadHeaders() { +int SpdyStream::DoReadHeaders() { io_state_ = STATE_READ_HEADERS_COMPLETE; return response_->headers ? OK : ERR_IO_PENDING; } -int FlipStream::DoReadHeadersComplete(int result) { +int SpdyStream::DoReadHeadersComplete(int result) { return result; } -int FlipStream::DoReadBody() { - // TODO(mbelshe): merge FlipStreamParser with FlipStream and then this +int SpdyStream::DoReadBody() { + // TODO(mbelshe): merge SpdyStreamParser with SpdyStream and then this // makes sense. return ERR_IO_PENDING; } -int FlipStream::DoReadBodyComplete(int result) { - // TODO(mbelshe): merge FlipStreamParser with FlipStream and then this +int SpdyStream::DoReadBodyComplete(int result) { + // TODO(mbelshe): merge SpdyStreamParser with SpdyStream and then this // makes sense. return ERR_IO_PENDING; } -void FlipStream::UpdateHistograms() { +void SpdyStream::UpdateHistograms() { if (histograms_recorded_) return; diff --git a/net/spdy/spdy_stream.h b/net/spdy/spdy_stream.h index ab2659e..1d750c3 100644 --- a/net/spdy/spdy_stream.h +++ b/net/spdy/spdy_stream.h @@ -21,38 +21,38 @@ namespace net { -class FlipSession; class HttpRequestInfo; class HttpResponseInfo; +class SpdySession; class UploadData; class UploadDataStream; -// The FlipStream is used by the FlipSession to represent each stream known -// on the FlipSession. +// The SpdyStream is used by the SpdySession to represent each stream known +// on the SpdySession. // Streams can be created either by the client or by the server. When they -// are initiated by the client, both the FlipSession and client object (such as -// a FlipNetworkTransaction) will maintain a reference to the stream. When -// initiated by the server, only the FlipSession will maintain any reference, +// are initiated by the client, both the SpdySession and client object (such as +// a SpdyNetworkTransaction) will maintain a reference to the stream. When +// initiated by the server, only the SpdySession will maintain any reference, // until such a time as a client object requests a stream for the path. -class FlipStream : public base::RefCounted<FlipStream> { +class SpdyStream : public base::RefCounted<SpdyStream> { public: - // FlipStream constructor - FlipStream(FlipSession* session, flip::FlipStreamId stream_id, bool pushed, + // SpdyStream constructor + SpdyStream(SpdySession* session, spdy::SpdyStreamId stream_id, bool pushed, LoadLog* log); // Ideally I'd use two abstract classes as interfaces for these two sections, // but since we're ref counted, I can't make both abstract classes inherit // from RefCounted or we'll have two separate ref counts for the same object. // TODO(willchan): Consider using linked_ptr here orcreating proxy wrappers - // for FlipStream to provide the appropriate interface. + // for SpdyStream to provide the appropriate interface. // =================================================== - // Interface for [Http|Flip]NetworkTransaction to use. + // Interface for [Http|Spdy]NetworkTransaction to use. // Sends the request. If |upload_data| is non-NULL, sends that in the request // body. |callback| is used when this completes asynchronously. Note that // the actual SYN_STREAM packet will have already been sent by this point. - // Also note that FlipStream takes ownership of |upload_data|. + // Also note that SpdyStream takes ownership of |upload_data|. int SendRequest(UploadDataStream* upload_data, HttpResponseInfo* response, CompletionCallback* callback); @@ -80,10 +80,10 @@ class FlipStream : public base::RefCounted<FlipStream> { bool pushed() const { return pushed_; } // ================================= - // Interface for FlipSession to use. + // Interface for SpdySession to use. - flip::FlipStreamId stream_id() const { return stream_id_; } - void set_stream_id(flip::FlipStreamId stream_id) { stream_id_ = stream_id; } + spdy::SpdyStreamId stream_id() const { return stream_id_; } + void set_stream_id(spdy::SpdyStreamId stream_id) { stream_id_ = stream_id; } // For pushed streams, we track a path to identify them. const std::string& path() const { return path_; } @@ -92,12 +92,12 @@ class FlipStream : public base::RefCounted<FlipStream> { int priority() const { return priority_; } void set_priority(int priority) { priority_ = priority; } - // Called by the FlipSession when a response (e.g. a SYN_REPLY) has been + // Called by the SpdySession when a response (e.g. a SYN_REPLY) has been // received for this stream. |path| is the path of the URL for a server // initiated stream, otherwise is empty. void OnResponseReceived(const HttpResponseInfo& response); - // Called by the FlipSession when response data has been received for this + // Called by the SpdySession when response data has been received for this // stream. This callback may be called multiple times as data arrives // from the network, and will never be called prior to OnResponseReceived. // |buffer| contains the data received. The stream must copy any data @@ -107,13 +107,13 @@ class FlipStream : public base::RefCounted<FlipStream> { // Returns true on success and false on error. bool OnDataReceived(const char* buffer, int bytes); - // Called by the FlipSession when a write has completed. This callback + // Called by the SpdySession when a write has completed. This callback // will be called multiple times for each write which completes. Writes // include the SYN_STREAM write and also DATA frame writes. // |result| is the number of bytes written or a net error code. void OnWriteComplete(int status); - // Called by the FlipSession when the request is finished. This callback + // Called by the SpdySession when the request is finished. This callback // will always be called at the end of the request and signals to the // stream that the stream has no more network events. No further callbacks // to the stream will be made after this call. @@ -127,7 +127,7 @@ class FlipStream : public base::RefCounted<FlipStream> { } private: - friend class base::RefCounted<FlipStream>; + friend class base::RefCounted<SpdyStream>; enum State { STATE_NONE, @@ -142,7 +142,7 @@ class FlipStream : public base::RefCounted<FlipStream> { STATE_DONE }; - ~FlipStream(); + ~SpdyStream(); // Try to make progress sending/receiving the request/response. int DoLoop(int result); @@ -164,7 +164,7 @@ class FlipStream : public base::RefCounted<FlipStream> { // be called after the stream has completed. void UpdateHistograms(); - flip::FlipStreamId stream_id_; + spdy::SpdyStreamId stream_id_; std::string path_; int priority_; const bool pushed_; @@ -174,7 +174,7 @@ class FlipStream : public base::RefCounted<FlipStream> { bool download_finished_; ScopedBandwidthMetrics metrics_; - scoped_refptr<FlipSession> session_; + scoped_refptr<SpdySession> session_; HttpResponseInfo* response_; scoped_ptr<UploadDataStream> request_body_stream_; @@ -203,7 +203,7 @@ class FlipStream : public base::RefCounted<FlipStream> { int recv_bytes_; bool histograms_recorded_; - DISALLOW_COPY_AND_ASSIGN(FlipStream); + DISALLOW_COPY_AND_ASSIGN(SpdyStream); }; } // namespace net diff --git a/net/spdy/spdy_stream_unittest.cc b/net/spdy/spdy_stream_unittest.cc index f019b5f..1af987c 100644 --- a/net/spdy/spdy_stream_unittest.cc +++ b/net/spdy/spdy_stream_unittest.cc @@ -20,19 +20,19 @@ namespace net { -class FlipSessionPoolPeer { +class SpdySessionPoolPeer { public: - explicit FlipSessionPoolPeer(const scoped_refptr<FlipSessionPool>& pool) + explicit SpdySessionPoolPeer(const scoped_refptr<SpdySessionPool>& pool) : pool_(pool) {} - void RemoveFlipSession(const scoped_refptr<FlipSession>& session) { + void RemoveSpdySession(const scoped_refptr<SpdySession>& session) { pool_->Remove(session); } private: - const scoped_refptr<FlipSessionPool> pool_; + const scoped_refptr<SpdySessionPool> pool_; - DISALLOW_COPY_AND_ASSIGN(FlipSessionPoolPeer); + DISALLOW_COPY_AND_ASSIGN(SpdySessionPoolPeer); }; namespace { @@ -43,7 +43,7 @@ ProxyService* CreateNullProxyService() { } // Helper to manage the lifetimes of the dependencies for a -// FlipNetworkTransaction. +// SpdyNetworkTransaction. class SessionDependencies { public: // Default set of dependencies -- "null" proxy service. @@ -51,20 +51,20 @@ class SessionDependencies { : host_resolver(new MockHostResolver), proxy_service(CreateNullProxyService()), ssl_config_service(new SSLConfigServiceDefaults), - flip_session_pool(new FlipSessionPool) {} + spdy_session_pool(new SpdySessionPool) {} // Custom proxy service dependency. explicit SessionDependencies(ProxyService* proxy_service) : host_resolver(new MockHostResolver), proxy_service(proxy_service), ssl_config_service(new SSLConfigServiceDefaults), - flip_session_pool(new FlipSessionPool) {} + spdy_session_pool(new SpdySessionPool) {} scoped_refptr<MockHostResolverBase> host_resolver; scoped_refptr<ProxyService> proxy_service; scoped_refptr<SSLConfigService> ssl_config_service; MockClientSocketFactory socket_factory; - scoped_refptr<FlipSessionPool> flip_session_pool; + scoped_refptr<SpdySessionPool> spdy_session_pool; }; HttpNetworkSession* CreateSession(SessionDependencies* session_deps) { @@ -73,19 +73,19 @@ HttpNetworkSession* CreateSession(SessionDependencies* session_deps) { session_deps->proxy_service, &session_deps->socket_factory, session_deps->ssl_config_service, - session_deps->flip_session_pool); + session_deps->spdy_session_pool); } -class FlipStreamTest : public testing::Test { +class SpdyStreamTest : public testing::Test { protected: - FlipStreamTest() + SpdyStreamTest() : session_(CreateSession(&session_deps_)), - pool_peer_(session_->flip_session_pool()) {} + pool_peer_(session_->spdy_session_pool()) {} - scoped_refptr<FlipSession> CreateFlipSession() { + scoped_refptr<SpdySession> CreateSpdySession() { HostResolver::RequestInfo resolve_info("www.google.com", 80); - scoped_refptr<FlipSession> session( - session_->flip_session_pool()->Get(resolve_info, session_)); + scoped_refptr<SpdySession> session( + session_->spdy_session_pool()->Get(resolve_info, session_)); return session; } @@ -95,27 +95,27 @@ class FlipStreamTest : public testing::Test { SessionDependencies session_deps_; scoped_refptr<HttpNetworkSession> session_; - FlipSessionPoolPeer pool_peer_; + SpdySessionPoolPeer pool_peer_; }; // Needs fixing, see http://crbug.com/28622 -TEST_F(FlipStreamTest, SendRequest) { - scoped_refptr<FlipSession> session(CreateFlipSession()); +TEST_F(SpdyStreamTest, SendRequest) { + scoped_refptr<SpdySession> session(CreateSpdySession()); HttpRequestInfo request; request.method = "GET"; request.url = GURL("http://www.google.com/"); TestCompletionCallback callback; HttpResponseInfo response; - scoped_refptr<FlipStream> stream(new FlipStream(session, 1, false, NULL)); + scoped_refptr<SpdyStream> stream(new SpdyStream(session, 1, false, NULL)); EXPECT_EQ(ERR_IO_PENDING, stream->SendRequest(NULL, &response, &callback)); - // Need to manually remove the flip session since normally it gets removed on + // Need to manually remove the spdy session since normally it gets removed on // socket close/error, but we aren't communicating over a socket here. - pool_peer_.RemoveFlipSession(session); + pool_peer_.RemoveSpdySession(session); } -// TODO(willchan): Write a longer test for FlipStream that exercises all +// TODO(willchan): Write a longer test for SpdyStream that exercises all // methods. } // namespace diff --git a/net/spdy/spdy_transaction_factory.h b/net/spdy/spdy_transaction_factory.h index 46571bf..bb626f9 100644 --- a/net/spdy/spdy_transaction_factory.h +++ b/net/spdy/spdy_transaction_factory.h @@ -10,16 +10,16 @@ namespace net { -class FlipTransactionFactory : public HttpTransactionFactory { +class SpdyTransactionFactory : public HttpTransactionFactory { public: - explicit FlipTransactionFactory(HttpNetworkSession* session) + explicit SpdyTransactionFactory(HttpNetworkSession* session) : session_(session) { } - virtual ~FlipTransactionFactory() {} + virtual ~SpdyTransactionFactory() {} // HttpTransactionFactory Interface. virtual HttpTransaction* CreateTransaction() { - return new FlipNetworkTransaction(session_); + return new SpdyNetworkTransaction(session_); } virtual HttpCache* GetCache() { return NULL; diff --git a/tools/valgrind/memcheck/suppressions.txt b/tools/valgrind/memcheck/suppressions.txt index 1b9dfc4..0efbcf2 100644 --- a/tools/valgrind/memcheck/suppressions.txt +++ b/tools/valgrind/memcheck/suppressions.txt @@ -385,7 +385,7 @@ Memcheck:Value4 ... fun:inflate - fun:_ZN4flip10FlipFramer15DecompressFrameEPKNS_9FlipFrameE + fun:_ZN4spdy10SpdyFramer15DecompressFrameEPKNS_9SpdyFrameE ... } { @@ -1686,19 +1686,19 @@ bug_29392a Memcheck:Leak fun:_Znw* - fun:_ZN3net15FlipSessionPool3GetERKNS_12HostResolver11RequestInfoEPNS_18HttpNetworkSessionE - fun:_ZN3net22FlipNetworkTransaction16DoInitConnectionEv - fun:_ZN3net22FlipNetworkTransaction6DoLoopEi - fun:_ZN3net22FlipNetworkTransaction5StartEPKNS_15HttpRequestInfoEP14CallbackRunnerI6Tuple1IiEEPNS_7LoadLogE + fun:_ZN3net15SpdySessionPool3GetERKNS_12HostResolver11RequestInfoEPNS_18HttpNetworkSessionE + fun:_ZN3net22SpdyNetworkTransaction16DoInitConnectionEv + fun:_ZN3net22SpdyNetworkTransaction6DoLoopEi + fun:_ZN3net22SpdyNetworkTransaction5StartEPKNS_15HttpRequestInfoEP14CallbackRunnerI6Tuple1IiEEPNS_7LoadLogE } { bug_29392b Memcheck:Leak fun:_Znw* - fun:_ZN3net11FlipSession17GetOrCreateStreamERKNS_15HttpRequestInfoEPKNS_16UploadDataStreamE - fun:_ZN3net22FlipNetworkTransaction13DoSendRequestEv - fun:_ZN3net22FlipNetworkTransaction6DoLoopEi - fun:_ZN3net22FlipNetworkTransaction5StartEPKNS_15HttpRequestInfoEP14CallbackRunnerI6Tuple1IiEEPNS_7LoadLogE + fun:_ZN3net11SpdySession17GetOrCreateStreamERKNS_15HttpRequestInfoEPKNS_16UploadDataStreamE + fun:_ZN3net22SpdyNetworkTransaction13DoSendRequestEv + fun:_ZN3net22SpdyNetworkTransaction6DoLoopEi + fun:_ZN3net22SpdyNetworkTransaction5StartEPKNS_15HttpRequestInfoEP14CallbackRunnerI6Tuple1IiEEPNS_7LoadLogE } { bug_29675 @@ -1731,7 +1731,7 @@ bug_30667a Memcheck:Value4 fun:inflate - fun:_ZN4flip10FlipFramer15DecompressFrameEPKNS_9FlipFrameE + fun:_ZN4spdy10SpdyFramer15DecompressFrameEPKNS_9SpdyFrameE ... fun:_ZN7testing4Test3RunEv fun:_ZN7testing8internal12TestInfoImpl3RunEv @@ -1746,7 +1746,7 @@ Memcheck:Cond fun:inflate_fast fun:inflate - fun:_ZN4flip10FlipFramer15DecompressFrameEPKNS_9FlipFrameE + fun:_ZN4spdy10SpdyFramer15DecompressFrameEPKNS_9SpdyFrameE ... fun:_ZN7testing4Test3RunEv fun:_ZN7testing8internal12TestInfoImpl3RunEv @@ -1760,7 +1760,7 @@ bug_30667c Memcheck:Cond fun:inflate - fun:_ZN4flip10FlipFramer15DecompressFrameEPKNS_9FlipFrameE + fun:_ZN4spdy10SpdyFramer15DecompressFrameEPKNS_9SpdyFrameE ... fun:_ZN7testing4Test3RunEv fun:_ZN7testing8internal12TestInfoImpl3RunEv |