Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(275)

Side by Side Diff: net/spdy/spdy_session.cc

Issue 2593063003: Add Socket::ReadIfReady() (Closed)
Patch Set: Rebased Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/socket/tcp_socket_win.cc ('k') | net/spdy/spdy_session_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/spdy/spdy_session.h" 5 #include "net/spdy/spdy_session.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <map> 9 #include <map>
10 #include <utility> 10 #include <utility>
(...skipping 28 matching lines...) Expand all
39 #include "net/http/http_server_properties.h" 39 #include "net/http/http_server_properties.h"
40 #include "net/http/http_util.h" 40 #include "net/http/http_util.h"
41 #include "net/http/transport_security_state.h" 41 #include "net/http/transport_security_state.h"
42 #include "net/log/net_log.h" 42 #include "net/log/net_log.h"
43 #include "net/log/net_log_capture_mode.h" 43 #include "net/log/net_log_capture_mode.h"
44 #include "net/log/net_log_event_type.h" 44 #include "net/log/net_log_event_type.h"
45 #include "net/log/net_log_source.h" 45 #include "net/log/net_log_source.h"
46 #include "net/log/net_log_source_type.h" 46 #include "net/log/net_log_source_type.h"
47 #include "net/log/net_log_with_source.h" 47 #include "net/log/net_log_with_source.h"
48 #include "net/proxy/proxy_server.h" 48 #include "net/proxy/proxy_server.h"
49 #include "net/socket/socket.h"
49 #include "net/socket/ssl_client_socket.h" 50 #include "net/socket/ssl_client_socket.h"
50 #include "net/spdy/platform/api/spdy_estimate_memory_usage.h" 51 #include "net/spdy/platform/api/spdy_estimate_memory_usage.h"
51 #include "net/spdy/spdy_buffer_producer.h" 52 #include "net/spdy/spdy_buffer_producer.h"
52 #include "net/spdy/spdy_frame_builder.h" 53 #include "net/spdy/spdy_frame_builder.h"
53 #include "net/spdy/spdy_http_utils.h" 54 #include "net/spdy/spdy_http_utils.h"
54 #include "net/spdy/spdy_protocol.h" 55 #include "net/spdy/spdy_protocol.h"
55 #include "net/spdy/spdy_session_pool.h" 56 #include "net/spdy/spdy_session_pool.h"
56 #include "net/spdy/spdy_stream.h" 57 #include "net/spdy/spdy_stream.h"
57 #include "net/ssl/channel_id_service.h" 58 #include "net/ssl/channel_id_service.h"
58 #include "net/ssl/ssl_cipher_suite_names.h" 59 #include "net/ssl/ssl_cipher_suite_names.h"
(...skipping 1807 matching lines...) Expand 10 before | Expand all | Expand 10 after
1866 1867
1867 return result; 1868 return result;
1868 } 1869 }
1869 1870
1870 int SpdySession::DoRead() { 1871 int SpdySession::DoRead() {
1871 CHECK(in_io_loop_); 1872 CHECK(in_io_loop_);
1872 1873
1873 CHECK(connection_); 1874 CHECK(connection_);
1874 CHECK(connection_->socket()); 1875 CHECK(connection_->socket());
1875 read_state_ = READ_STATE_DO_READ_COMPLETE; 1876 read_state_ = READ_STATE_DO_READ_COMPLETE;
1876 return connection_->socket()->Read( 1877 int rv = ERR_READ_IF_READY_NOT_IMPLEMENTED;
1877 read_buffer_.get(), kReadBufferSize, 1878 if (base::FeatureList::IsEnabled(Socket::kReadIfReadyExperiment)) {
1878 base::Bind(&SpdySession::PumpReadLoop, weak_factory_.GetWeakPtr(), 1879 rv = connection_->socket()->ReadIfReady(
1879 READ_STATE_DO_READ_COMPLETE)); 1880 read_buffer_.get(), kReadBufferSize,
1881 base::Bind(&SpdySession::PumpReadLoop, weak_factory_.GetWeakPtr(),
1882 READ_STATE_DO_READ));
1883 // TODO(xunjieli): Follow-up CL to release |read_buffer_|.
1884 // https://crbug.com/690915.
1885 }
1886 if (rv == ERR_READ_IF_READY_NOT_IMPLEMENTED) {
1887 // Fallback to regular Read().
1888 return connection_->socket()->Read(
1889 read_buffer_.get(), kReadBufferSize,
1890 base::Bind(&SpdySession::PumpReadLoop, weak_factory_.GetWeakPtr(),
1891 READ_STATE_DO_READ_COMPLETE));
1892 }
1893 if (rv == ERR_IO_PENDING)
1894 read_state_ = READ_STATE_DO_READ;
1895 return rv;
1880 } 1896 }
1881 1897
1882 int SpdySession::DoReadComplete(int result) { 1898 int SpdySession::DoReadComplete(int result) {
1883 CHECK(in_io_loop_); 1899 CHECK(in_io_loop_);
1884 1900
1885 // Parse a frame. For now this code requires that the frame fit into our 1901 // Parse a frame. For now this code requires that the frame fit into our
1886 // buffer (kReadBufferSize). 1902 // buffer (kReadBufferSize).
1887 // TODO(mbelshe): support arbitrarily large frames! 1903 // TODO(mbelshe): support arbitrarily large frames!
1888 1904
1889 if (result == 0) { 1905 if (result == 0) {
(...skipping 1278 matching lines...) Expand 10 before | Expand all | Expand 10 after
3168 if (!queue->empty()) { 3184 if (!queue->empty()) {
3169 SpdyStreamId stream_id = queue->front(); 3185 SpdyStreamId stream_id = queue->front();
3170 queue->pop_front(); 3186 queue->pop_front();
3171 return stream_id; 3187 return stream_id;
3172 } 3188 }
3173 } 3189 }
3174 return 0; 3190 return 0;
3175 } 3191 }
3176 3192
3177 } // namespace net 3193 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/tcp_socket_win.cc ('k') | net/spdy/spdy_session_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698