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

Side by Side Diff: net/socket/client_socket_pool_base.h

Issue 2678353003: Close idle H2 sockets when SpdySession is initialized. (Closed)
Patch Set: Self Created 3 years, 10 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
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 // A ClientSocketPoolBase is used to restrict the number of sockets open at 5 // A ClientSocketPoolBase is used to restrict the number of sockets open at
6 // a time. It also maintains a list of idle persistent sockets for reuse. 6 // a time. It also maintains a list of idle persistent sockets for reuse.
7 // Subclasses of ClientSocketPool should compose ClientSocketPoolBase to handle 7 // Subclasses of ClientSocketPool should compose ClientSocketPoolBase to handle
8 // the core logic of (1) restricting the number of active (connected or 8 // the core logic of (1) restricting the number of active (connected or
9 // connecting) sockets per "group" (generally speaking, the hostname), (2) 9 // connecting) sockets per "group" (generally speaking, the hostname), (2)
10 // maintaining a per-group list of idle, persistent sockets for reuse, and (3) 10 // maintaining a per-group list of idle, persistent sockets for reuse, and (3)
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 void ReleaseSocket(const std::string& group_name, 281 void ReleaseSocket(const std::string& group_name,
282 std::unique_ptr<StreamSocket> socket, 282 std::unique_ptr<StreamSocket> socket,
283 int id); 283 int id);
284 284
285 // See ClientSocketPool::FlushWithError for documentation on this function. 285 // See ClientSocketPool::FlushWithError for documentation on this function.
286 void FlushWithError(int error); 286 void FlushWithError(int error);
287 287
288 // See ClientSocketPool::CloseIdleSockets for documentation on this function. 288 // See ClientSocketPool::CloseIdleSockets for documentation on this function.
289 void CloseIdleSockets(); 289 void CloseIdleSockets();
290 290
291 // See ClientSocketPool::CloseIdleSocketsInGroup for documentation.
292 void CloseIdleSocketsInGroup(const std::string& group_name);
293
291 // See ClientSocketPool::IdleSocketCount() for documentation on this function. 294 // See ClientSocketPool::IdleSocketCount() for documentation on this function.
292 int idle_socket_count() const { 295 int idle_socket_count() const {
293 return idle_socket_count_; 296 return idle_socket_count_;
294 } 297 }
295 298
296 // See ClientSocketPool::IdleSocketCountInGroup() for documentation on this 299 // See ClientSocketPool::IdleSocketCountInGroup() for documentation on this
297 // function. 300 // function.
298 int IdleSocketCountInGroup(const std::string& group_name) const; 301 int IdleSocketCountInGroup(const std::string& group_name) const;
299 302
300 // See ClientSocketPool::GetLoadState() for documentation on this function. 303 // See ClientSocketPool::GetLoadState() for documentation on this function.
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 CallbackResultPair(const CallbackResultPair& other); 523 CallbackResultPair(const CallbackResultPair& other);
521 ~CallbackResultPair(); 524 ~CallbackResultPair();
522 525
523 CompletionCallback callback; 526 CompletionCallback callback;
524 int result; 527 int result;
525 }; 528 };
526 529
527 typedef std::map<const ClientSocketHandle*, CallbackResultPair> 530 typedef std::map<const ClientSocketHandle*, CallbackResultPair>
528 PendingCallbackMap; 531 PendingCallbackMap;
529 532
533 // Closes all idle sockets in |group| if |force| is true. Else, only closes
534 // idle sockets in |group| that timed out with respect to |now| or can't be
535 // reused.
536 void CleanupIdleSocketsInGroup(bool force,
537 Group* group,
538 const base::TimeTicks& now);
539
530 Group* GetOrCreateGroup(const std::string& group_name); 540 Group* GetOrCreateGroup(const std::string& group_name);
531 void RemoveGroup(const std::string& group_name); 541 void RemoveGroup(const std::string& group_name);
532 void RemoveGroup(GroupMap::iterator it); 542 void RemoveGroup(GroupMap::iterator it);
533 543
534 // Called when the number of idle sockets changes. 544 // Called when the number of idle sockets changes.
535 void IncrementIdleCount(); 545 void IncrementIdleCount();
536 void DecrementIdleCount(); 546 void DecrementIdleCount();
537 547
538 // Scans the group map for groups which have an available socket slot and 548 // Scans the group map for groups which have an available socket slot and
539 // at least one pending request. Returns true if any groups are stalled, and 549 // at least one pending request. Returns true if any groups are stalled, and
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 int id) { 793 int id) {
784 return helper_.ReleaseSocket(group_name, std::move(socket), id); 794 return helper_.ReleaseSocket(group_name, std::move(socket), id);
785 } 795 }
786 796
787 void FlushWithError(int error) { helper_.FlushWithError(error); } 797 void FlushWithError(int error) { helper_.FlushWithError(error); }
788 798
789 bool IsStalled() const { return helper_.IsStalled(); } 799 bool IsStalled() const { return helper_.IsStalled(); }
790 800
791 void CloseIdleSockets() { return helper_.CloseIdleSockets(); } 801 void CloseIdleSockets() { return helper_.CloseIdleSockets(); }
792 802
803 void CloseIdleSocketsInGroup(const std::string& group_name) {
804 return helper_.CloseIdleSocketsInGroup(group_name);
805 }
806
793 int idle_socket_count() const { return helper_.idle_socket_count(); } 807 int idle_socket_count() const { return helper_.idle_socket_count(); }
794 808
795 int IdleSocketCountInGroup(const std::string& group_name) const { 809 int IdleSocketCountInGroup(const std::string& group_name) const {
796 return helper_.IdleSocketCountInGroup(group_name); 810 return helper_.IdleSocketCountInGroup(group_name);
797 } 811 }
798 812
799 LoadState GetLoadState(const std::string& group_name, 813 LoadState GetLoadState(const std::string& group_name,
800 const ClientSocketHandle* handle) const { 814 const ClientSocketHandle* handle) const {
801 return helper_.GetLoadState(group_name, handle); 815 return helper_.GetLoadState(group_name, handle);
802 } 816 }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 }; 895 };
882 896
883 internal::ClientSocketPoolBaseHelper helper_; 897 internal::ClientSocketPoolBaseHelper helper_;
884 898
885 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); 899 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase);
886 }; 900 };
887 901
888 } // namespace net 902 } // namespace net
889 903
890 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ 904 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698