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

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

Issue 2801603003: Add SpdyString alias for std::string in net/spdy. (Closed)
Patch Set: Created 3 years, 8 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/spdy/spdy_read_queue_unittest.cc ('k') | net/spdy/spdy_session.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 #ifndef NET_SPDY_SPDY_SESSION_H_ 5 #ifndef NET_SPDY_SPDY_SESSION_H_
6 #define NET_SPDY_SPDY_SESSION_H_ 6 #define NET_SPDY_SPDY_SESSION_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <deque> 11 #include <deque>
12 #include <map> 12 #include <map>
13 #include <memory> 13 #include <memory>
14 #include <set> 14 #include <set>
15 #include <string>
16 #include <vector> 15 #include <vector>
17 16
18 #include "base/gtest_prod_util.h" 17 #include "base/gtest_prod_util.h"
19 #include "base/macros.h" 18 #include "base/macros.h"
20 #include "base/memory/ref_counted.h" 19 #include "base/memory/ref_counted.h"
21 #include "base/memory/weak_ptr.h" 20 #include "base/memory/weak_ptr.h"
22 #include "base/time/time.h" 21 #include "base/time/time.h"
23 #include "net/base/host_port_pair.h" 22 #include "net/base/host_port_pair.h"
24 #include "net/base/io_buffer.h" 23 #include "net/base/io_buffer.h"
25 #include "net/base/load_states.h" 24 #include "net/base/load_states.h"
26 #include "net/base/net_errors.h" 25 #include "net/base/net_errors.h"
27 #include "net/base/net_export.h" 26 #include "net/base/net_export.h"
28 #include "net/base/request_priority.h" 27 #include "net/base/request_priority.h"
29 #include "net/log/net_log_source.h" 28 #include "net/log/net_log_source.h"
30 #include "net/socket/client_socket_handle.h" 29 #include "net/socket/client_socket_handle.h"
31 #include "net/socket/client_socket_pool.h" 30 #include "net/socket/client_socket_pool.h"
32 #include "net/socket/next_proto.h" 31 #include "net/socket/next_proto.h"
33 #include "net/socket/ssl_client_socket.h" 32 #include "net/socket/ssl_client_socket.h"
34 #include "net/socket/stream_socket.h" 33 #include "net/socket/stream_socket.h"
35 #include "net/spdy/buffered_spdy_framer.h" 34 #include "net/spdy/buffered_spdy_framer.h"
36 #include "net/spdy/http2_priority_dependencies.h" 35 #include "net/spdy/http2_priority_dependencies.h"
37 #include "net/spdy/multiplexed_session.h" 36 #include "net/spdy/multiplexed_session.h"
37 #include "net/spdy/platform/api/spdy_string.h"
38 #include "net/spdy/platform/api/spdy_string_piece.h" 38 #include "net/spdy/platform/api/spdy_string_piece.h"
39 #include "net/spdy/server_push_delegate.h" 39 #include "net/spdy/server_push_delegate.h"
40 #include "net/spdy/spdy_alt_svc_wire_format.h" 40 #include "net/spdy/spdy_alt_svc_wire_format.h"
41 #include "net/spdy/spdy_buffer.h" 41 #include "net/spdy/spdy_buffer.h"
42 #include "net/spdy/spdy_framer.h" 42 #include "net/spdy/spdy_framer.h"
43 #include "net/spdy/spdy_header_block.h" 43 #include "net/spdy/spdy_header_block.h"
44 #include "net/spdy/spdy_protocol.h" 44 #include "net/spdy/spdy_protocol.h"
45 #include "net/spdy/spdy_session_pool.h" 45 #include "net/spdy/spdy_session_pool.h"
46 #include "net/spdy/spdy_stream.h" 46 #include "net/spdy/spdy_stream.h"
47 #include "net/spdy/spdy_write_queue.h" 47 #include "net/spdy/spdy_write_queue.h"
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 // (Bijective) map from the URL to the ID of the streams that have 285 // (Bijective) map from the URL to the ID of the streams that have
286 // already started to be pushed by the server, but do not have 286 // already started to be pushed by the server, but do not have
287 // consumers yet. Contains a subset of |active_streams_|. 287 // consumers yet. Contains a subset of |active_streams_|.
288 PushedStreamMap streams_; 288 PushedStreamMap streams_;
289 }; 289 };
290 290
291 // Returns true if |new_hostname| can be pooled into an existing connection to 291 // Returns true if |new_hostname| can be pooled into an existing connection to
292 // |old_hostname| associated with |ssl_info|. 292 // |old_hostname| associated with |ssl_info|.
293 static bool CanPool(TransportSecurityState* transport_security_state, 293 static bool CanPool(TransportSecurityState* transport_security_state,
294 const SSLInfo& ssl_info, 294 const SSLInfo& ssl_info,
295 const std::string& old_hostname, 295 const SpdyString& old_hostname,
296 const std::string& new_hostname); 296 const SpdyString& new_hostname);
297 297
298 // Create a new SpdySession. 298 // Create a new SpdySession.
299 // |spdy_session_key| is the host/port that this session connects to, privacy 299 // |spdy_session_key| is the host/port that this session connects to, privacy
300 // and proxy configuration settings that it's using. 300 // and proxy configuration settings that it's using.
301 // |session| is the HttpNetworkSession. |net_log| is the NetLog that we log 301 // |session| is the HttpNetworkSession. |net_log| is the NetLog that we log
302 // network events to. 302 // network events to.
303 SpdySession(const SpdySessionKey& spdy_session_key, 303 SpdySession(const SpdySessionKey& spdy_session_key,
304 HttpServerProperties* http_server_properties, 304 HttpServerProperties* http_server_properties,
305 TransportSecurityState* transport_security_state, 305 TransportSecurityState* transport_security_state,
306 bool enable_sending_initial_data, 306 bool enable_sending_initial_data,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 // Check to see if this SPDY session can support an additional domain. 361 // Check to see if this SPDY session can support an additional domain.
362 // If the session is un-authenticated, then this call always returns true. 362 // If the session is un-authenticated, then this call always returns true.
363 // For SSL-based sessions, verifies that the server certificate in use by 363 // For SSL-based sessions, verifies that the server certificate in use by
364 // this session provides authentication for the domain and no client 364 // this session provides authentication for the domain and no client
365 // certificate or channel ID was sent to the original server during the SSL 365 // certificate or channel ID was sent to the original server during the SSL
366 // handshake. NOTE: This function can have false negatives on some 366 // handshake. NOTE: This function can have false negatives on some
367 // platforms. 367 // platforms.
368 // TODO(wtc): rename this function and the Net.SpdyIPPoolDomainMatch 368 // TODO(wtc): rename this function and the Net.SpdyIPPoolDomainMatch
369 // histogram because this function does more than verifying domain 369 // histogram because this function does more than verifying domain
370 // authentication now. 370 // authentication now.
371 bool VerifyDomainAuthentication(const std::string& domain); 371 bool VerifyDomainAuthentication(const SpdyString& domain);
372 372
373 // Pushes the given producer into the write queue for 373 // Pushes the given producer into the write queue for
374 // |stream|. |stream| is guaranteed to be activated before the 374 // |stream|. |stream| is guaranteed to be activated before the
375 // producer is used to produce its frame. 375 // producer is used to produce its frame.
376 void EnqueueStreamWrite(const base::WeakPtr<SpdyStream>& stream, 376 void EnqueueStreamWrite(const base::WeakPtr<SpdyStream>& stream,
377 SpdyFrameType frame_type, 377 SpdyFrameType frame_type,
378 std::unique_ptr<SpdyBufferProducer> producer); 378 std::unique_ptr<SpdyBufferProducer> producer);
379 379
380 // Creates and returns a HEADERS frame for |stream_id|. 380 // Creates and returns a HEADERS frame for |stream_id|.
381 std::unique_ptr<SpdySerializedFrame> CreateHeaders( 381 std::unique_ptr<SpdySerializedFrame> CreateHeaders(
(...skipping 18 matching lines...) Expand all
400 // Close the given created stream, which must exist but not yet be 400 // Close the given created stream, which must exist but not yet be
401 // active. Note that |stream| may hold the last reference to the 401 // active. Note that |stream| may hold the last reference to the
402 // session. 402 // session.
403 void CloseCreatedStream(const base::WeakPtr<SpdyStream>& stream, int status); 403 void CloseCreatedStream(const base::WeakPtr<SpdyStream>& stream, int status);
404 404
405 // Send a RST_STREAM frame with the given status code and close the 405 // Send a RST_STREAM frame with the given status code and close the
406 // stream with the given ID, which must exist and be active. Note 406 // stream with the given ID, which must exist and be active. Note
407 // that that stream may hold the last reference to the session. 407 // that that stream may hold the last reference to the session.
408 void ResetStream(SpdyStreamId stream_id, 408 void ResetStream(SpdyStreamId stream_id,
409 SpdyErrorCode error_code, 409 SpdyErrorCode error_code,
410 const std::string& description); 410 const SpdyString& description);
411 411
412 // Check if a stream is active. 412 // Check if a stream is active.
413 bool IsStreamActive(SpdyStreamId stream_id) const; 413 bool IsStreamActive(SpdyStreamId stream_id) const;
414 414
415 // The LoadState is used for informing the user of the current network 415 // The LoadState is used for informing the user of the current network
416 // status, such as "resolving host", "connecting", etc. 416 // status, such as "resolving host", "connecting", etc.
417 LoadState GetLoadState() const; 417 LoadState GetLoadState() const;
418 418
419 // Returns server infomation in the form of (scheme/host/port). 419 // Returns server infomation in the form of (scheme/host/port).
420 url::SchemeHostPort GetServer(); 420 url::SchemeHostPort GetServer();
(...skipping 23 matching lines...) Expand all
444 444
445 // Closes this session. This will close all active streams and mark 445 // Closes this session. This will close all active streams and mark
446 // the session as permanently closed. Callers must assume that the 446 // the session as permanently closed. Callers must assume that the
447 // session is destroyed after this is called. (However, it may not 447 // session is destroyed after this is called. (However, it may not
448 // be destroyed right away, e.g. when a SpdySession function is 448 // be destroyed right away, e.g. when a SpdySession function is
449 // present in the call stack.) 449 // present in the call stack.)
450 // 450 //
451 // |err| should be < ERR_IO_PENDING; this function is intended to be 451 // |err| should be < ERR_IO_PENDING; this function is intended to be
452 // called on error. 452 // called on error.
453 // |description| indicates the reason for the error. 453 // |description| indicates the reason for the error.
454 void CloseSessionOnError(Error err, const std::string& description); 454 void CloseSessionOnError(Error err, const SpdyString& description);
455 455
456 // Mark this session as unavailable, meaning that it will not be used to 456 // Mark this session as unavailable, meaning that it will not be used to
457 // service new streams. Unlike when a GOAWAY frame is received, this function 457 // service new streams. Unlike when a GOAWAY frame is received, this function
458 // will not close any streams. 458 // will not close any streams.
459 void MakeUnavailable(); 459 void MakeUnavailable();
460 460
461 // Closes all active streams with stream id's greater than 461 // Closes all active streams with stream id's greater than
462 // |last_good_stream_id|, as well as any created or pending 462 // |last_good_stream_id|, as well as any created or pending
463 // streams. Must be called only when |availability_state_| >= 463 // streams. Must be called only when |availability_state_| >=
464 // STATE_GOING_AWAY. After this function, DcheckGoingAway() will 464 // STATE_GOING_AWAY. After this function, DcheckGoingAway() will
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 void CloseActiveStreamIterator(ActiveStreamMap::iterator it, int status); 699 void CloseActiveStreamIterator(ActiveStreamMap::iterator it, int status);
700 700
701 // Close the stream pointed to by the given iterator. Note that that 701 // Close the stream pointed to by the given iterator. Note that that
702 // stream may hold the last reference to the session. 702 // stream may hold the last reference to the session.
703 void CloseCreatedStreamIterator(CreatedStreamSet::iterator it, int status); 703 void CloseCreatedStreamIterator(CreatedStreamSet::iterator it, int status);
704 704
705 // Calls EnqueueResetStreamFrame() and then 705 // Calls EnqueueResetStreamFrame() and then
706 // CloseActiveStreamIterator(). 706 // CloseActiveStreamIterator().
707 void ResetStreamIterator(ActiveStreamMap::iterator it, 707 void ResetStreamIterator(ActiveStreamMap::iterator it,
708 SpdyErrorCode error_code, 708 SpdyErrorCode error_code,
709 const std::string& description); 709 const SpdyString& description);
710 710
711 // Send a RST_STREAM frame with the given parameters. There should 711 // Send a RST_STREAM frame with the given parameters. There should
712 // either be no active stream with the given ID, or that active 712 // either be no active stream with the given ID, or that active
713 // stream should be closed shortly after this function is called. 713 // stream should be closed shortly after this function is called.
714 void EnqueueResetStreamFrame(SpdyStreamId stream_id, 714 void EnqueueResetStreamFrame(SpdyStreamId stream_id,
715 RequestPriority priority, 715 RequestPriority priority,
716 SpdyErrorCode error_code, 716 SpdyErrorCode error_code,
717 const std::string& description); 717 const SpdyString& description);
718 718
719 // Send a PRIORITY frame with the given parameters. 719 // Send a PRIORITY frame with the given parameters.
720 void EnqueuePriorityFrame(SpdyStreamId stream_id, 720 void EnqueuePriorityFrame(SpdyStreamId stream_id,
721 SpdyStreamId dependency_id, 721 SpdyStreamId dependency_id,
722 int weight, 722 int weight,
723 bool exclusive); 723 bool exclusive);
724 724
725 // Calls DoReadLoop. Use this function instead of DoReadLoop when 725 // Calls DoReadLoop. Use this function instead of DoReadLoop when
726 // posting a task to pump the read loop. 726 // posting a task to pump the read loop.
727 void PumpReadLoop(ReadState expected_read_state, int result); 727 void PumpReadLoop(ReadState expected_read_state, int result);
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 // no created streams. 845 // no created streams.
846 void DcheckGoingAway() const; 846 void DcheckGoingAway() const;
847 847
848 // Calls DcheckGoingAway(), then DCHECKs that |availability_state_| 848 // Calls DcheckGoingAway(), then DCHECKs that |availability_state_|
849 // == STATE_DRAINING, |error_on_close_| has a valid value, and that there 849 // == STATE_DRAINING, |error_on_close_| has a valid value, and that there
850 // are no active streams or unclaimed pushed streams. 850 // are no active streams or unclaimed pushed streams.
851 void DcheckDraining() const; 851 void DcheckDraining() const;
852 852
853 // If the session is already draining, does nothing. Otherwise, moves 853 // If the session is already draining, does nothing. Otherwise, moves
854 // the session to the draining state. 854 // the session to the draining state.
855 void DoDrainSession(Error err, const std::string& description); 855 void DoDrainSession(Error err, const SpdyString& description);
856 856
857 // Called right before closing a (possibly-inactive) stream for a 857 // Called right before closing a (possibly-inactive) stream for a
858 // reason other than being requested to by the stream. 858 // reason other than being requested to by the stream.
859 void LogAbandonedStream(SpdyStream* stream, Error status); 859 void LogAbandonedStream(SpdyStream* stream, Error status);
860 860
861 // Called right before closing an active stream for a reason other 861 // Called right before closing an active stream for a reason other
862 // than being requested to by the stream. 862 // than being requested to by the stream.
863 void LogAbandonedActiveStream(ActiveStreamMap::const_iterator it, 863 void LogAbandonedActiveStream(ActiveStreamMap::const_iterator it,
864 Error status); 864 Error status);
865 865
866 // Invokes a user callback for stream creation. We provide this method so it 866 // Invokes a user callback for stream creation. We provide this method so it
867 // can be deferred to the MessageLoop, so we avoid re-entrancy problems. 867 // can be deferred to the MessageLoop, so we avoid re-entrancy problems.
868 void CompleteStreamRequest( 868 void CompleteStreamRequest(
869 const base::WeakPtr<SpdyStreamRequest>& pending_request); 869 const base::WeakPtr<SpdyStreamRequest>& pending_request);
870 870
871 // Remove old unclaimed pushed streams. 871 // Remove old unclaimed pushed streams.
872 void DeleteExpiredPushedStreams(); 872 void DeleteExpiredPushedStreams();
873 873
874 // BufferedSpdyFramerVisitorInterface: 874 // BufferedSpdyFramerVisitorInterface:
875 void OnError(SpdyFramer::SpdyFramerError spdy_framer_error) override; 875 void OnError(SpdyFramer::SpdyFramerError spdy_framer_error) override;
876 void OnStreamError(SpdyStreamId stream_id, 876 void OnStreamError(SpdyStreamId stream_id,
877 const std::string& description) override; 877 const SpdyString& description) override;
878 void OnPing(SpdyPingId unique_id, bool is_ack) override; 878 void OnPing(SpdyPingId unique_id, bool is_ack) override;
879 void OnRstStream(SpdyStreamId stream_id, SpdyErrorCode error_code) override; 879 void OnRstStream(SpdyStreamId stream_id, SpdyErrorCode error_code) override;
880 void OnGoAway(SpdyStreamId last_accepted_stream_id, 880 void OnGoAway(SpdyStreamId last_accepted_stream_id,
881 SpdyErrorCode error_code, 881 SpdyErrorCode error_code,
882 SpdyStringPiece debug_data) override; 882 SpdyStringPiece debug_data) override;
883 void OnDataFrameHeader(SpdyStreamId stream_id, 883 void OnDataFrameHeader(SpdyStreamId stream_id,
884 size_t length, 884 size_t length,
885 bool fin) override; 885 bool fin) override;
886 void OnStreamFrameData(SpdyStreamId stream_id, 886 void OnStreamFrameData(SpdyStreamId stream_id,
887 const char* data, 887 const char* data,
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
1227 // Used for posting asynchronous IO tasks. We use this even though 1227 // Used for posting asynchronous IO tasks. We use this even though
1228 // SpdySession is refcounted because we don't need to keep the SpdySession 1228 // SpdySession is refcounted because we don't need to keep the SpdySession
1229 // alive if the last reference is within a RunnableMethod. Just revoke the 1229 // alive if the last reference is within a RunnableMethod. Just revoke the
1230 // method. 1230 // method.
1231 base::WeakPtrFactory<SpdySession> weak_factory_; 1231 base::WeakPtrFactory<SpdySession> weak_factory_;
1232 }; 1232 };
1233 1233
1234 } // namespace net 1234 } // namespace net
1235 1235
1236 #endif // NET_SPDY_SPDY_SESSION_H_ 1236 #endif // NET_SPDY_SPDY_SESSION_H_
OLDNEW
« no previous file with comments | « net/spdy/spdy_read_queue_unittest.cc ('k') | net/spdy/spdy_session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698