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

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

Issue 2678353003: Close idle H2 sockets when SpdySession is initialized. (Closed)
Patch Set: Address comments to hook directly to ClientSocketHandle 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/client_socket_pool.h ('k') | net/socket/client_socket_pool_base.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 // 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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 void ReleaseSocket(const std::string& group_name, 286 void ReleaseSocket(const std::string& group_name,
287 std::unique_ptr<StreamSocket> socket, 287 std::unique_ptr<StreamSocket> socket,
288 int id); 288 int id);
289 289
290 // See ClientSocketPool::FlushWithError for documentation on this function. 290 // See ClientSocketPool::FlushWithError for documentation on this function.
291 void FlushWithError(int error); 291 void FlushWithError(int error);
292 292
293 // See ClientSocketPool::CloseIdleSockets for documentation on this function. 293 // See ClientSocketPool::CloseIdleSockets for documentation on this function.
294 void CloseIdleSockets(); 294 void CloseIdleSockets();
295 295
296 // See ClientSocketPool::CloseIdleSocketsInGroup for documentation.
297 void CloseIdleSocketsInGroup(const std::string& group_name);
298
296 // See ClientSocketPool::IdleSocketCount() for documentation on this function. 299 // See ClientSocketPool::IdleSocketCount() for documentation on this function.
297 int idle_socket_count() const { 300 int idle_socket_count() const {
298 return idle_socket_count_; 301 return idle_socket_count_;
299 } 302 }
300 303
301 // See ClientSocketPool::IdleSocketCountInGroup() for documentation on this 304 // See ClientSocketPool::IdleSocketCountInGroup() for documentation on this
302 // function. 305 // function.
303 int IdleSocketCountInGroup(const std::string& group_name) const; 306 int IdleSocketCountInGroup(const std::string& group_name) const;
304 307
305 // See ClientSocketPool::GetLoadState() for documentation on this function. 308 // See ClientSocketPool::GetLoadState() for documentation on this function.
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 CallbackResultPair(const CallbackResultPair& other); 533 CallbackResultPair(const CallbackResultPair& other);
531 ~CallbackResultPair(); 534 ~CallbackResultPair();
532 535
533 CompletionCallback callback; 536 CompletionCallback callback;
534 int result; 537 int result;
535 }; 538 };
536 539
537 typedef std::map<const ClientSocketHandle*, CallbackResultPair> 540 typedef std::map<const ClientSocketHandle*, CallbackResultPair>
538 PendingCallbackMap; 541 PendingCallbackMap;
539 542
543 // Closes all idle sockets in |group| if |force| is true. Else, only closes
544 // idle sockets in |group| that timed out with respect to |now| or can't be
545 // reused.
546 void CleanupIdleSocketsInGroup(bool force,
547 Group* group,
548 const base::TimeTicks& now);
549
540 Group* GetOrCreateGroup(const std::string& group_name); 550 Group* GetOrCreateGroup(const std::string& group_name);
541 void RemoveGroup(const std::string& group_name); 551 void RemoveGroup(const std::string& group_name);
542 void RemoveGroup(GroupMap::iterator it); 552 void RemoveGroup(GroupMap::iterator it);
543 553
544 // Called when the number of idle sockets changes. 554 // Called when the number of idle sockets changes.
545 void IncrementIdleCount(); 555 void IncrementIdleCount();
546 void DecrementIdleCount(); 556 void DecrementIdleCount();
547 557
548 // Scans the group map for groups which have an available socket slot and 558 // Scans the group map for groups which have an available socket slot and
549 // at least one pending request. Returns true if any groups are stalled, and 559 // at least one pending request. Returns true if any groups are stalled, and
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 int id) { 809 int id) {
800 return helper_.ReleaseSocket(group_name, std::move(socket), id); 810 return helper_.ReleaseSocket(group_name, std::move(socket), id);
801 } 811 }
802 812
803 void FlushWithError(int error) { helper_.FlushWithError(error); } 813 void FlushWithError(int error) { helper_.FlushWithError(error); }
804 814
805 bool IsStalled() const { return helper_.IsStalled(); } 815 bool IsStalled() const { return helper_.IsStalled(); }
806 816
807 void CloseIdleSockets() { return helper_.CloseIdleSockets(); } 817 void CloseIdleSockets() { return helper_.CloseIdleSockets(); }
808 818
819 void CloseIdleSocketsInGroup(const std::string& group_name) {
820 return helper_.CloseIdleSocketsInGroup(group_name);
821 }
822
809 int idle_socket_count() const { return helper_.idle_socket_count(); } 823 int idle_socket_count() const { return helper_.idle_socket_count(); }
810 824
811 int IdleSocketCountInGroup(const std::string& group_name) const { 825 int IdleSocketCountInGroup(const std::string& group_name) const {
812 return helper_.IdleSocketCountInGroup(group_name); 826 return helper_.IdleSocketCountInGroup(group_name);
813 } 827 }
814 828
815 LoadState GetLoadState(const std::string& group_name, 829 LoadState GetLoadState(const std::string& group_name,
816 const ClientSocketHandle* handle) const { 830 const ClientSocketHandle* handle) const {
817 return helper_.GetLoadState(group_name, handle); 831 return helper_.GetLoadState(group_name, handle);
818 } 832 }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 }; 911 };
898 912
899 internal::ClientSocketPoolBaseHelper helper_; 913 internal::ClientSocketPoolBaseHelper helper_;
900 914
901 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); 915 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase);
902 }; 916 };
903 917
904 } // namespace net 918 } // namespace net
905 919
906 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ 920 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_
OLDNEW
« no previous file with comments | « net/socket/client_socket_pool.h ('k') | net/socket/client_socket_pool_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698