OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/socket/client_socket_pool.h" | 5 #include "net/socket/client_socket_pool.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 | 8 |
9 namespace { | 9 namespace { |
10 | 10 |
11 // The maximum duration, in seconds, to keep unused idle persistent sockets | 11 // The maximum duration, in seconds, to keep unused idle persistent sockets |
12 // alive. | 12 // alive. |
13 // TODO(ziadh): Change this timeout after getting histogram data on how long it | 13 // TODO(ziadh): Change this timeout after getting histogram data on how long it |
14 // should be. | 14 // should be. |
15 int g_unused_idle_socket_timeout_s = 10; | 15 int g_unused_idle_socket_timeout_s = 10; |
16 | 16 |
17 // The maximum duration, in seconds, to keep used idle persistent sockets alive. | 17 // The maximum duration, in seconds, to keep used idle persistent sockets alive. |
18 int g_used_idle_socket_timeout_s = 300; // 5 minutes | 18 int g_used_idle_socket_timeout_s = 300; // 5 minutes |
19 | 19 |
20 } // namespace | 20 } // namespace |
21 | 21 |
22 namespace net { | 22 namespace net { |
23 | 23 |
24 LayeredPool::LayeredPool() { | |
25 magic_value_ = 0xDEADBEEF; | |
26 } | |
27 | |
28 LayeredPool::~LayeredPool() { | |
29 magic_value_ = 0; | |
eroman
2012/03/28 18:02:50
Two comments:
(1) Define the magic values as an
Ryan Hamilton
2012/03/28 18:15:44
Done!
| |
30 stack_trace_ = base::debug::StackTrace(); | |
31 } | |
32 | |
33 void crash(base::debug::StackTrace trace) { | |
34 CHECK(false); | |
35 } | |
36 | |
37 void LayeredPool::CrashIfFreed() { | |
38 if (magic_value_ != 0xDEADBEEF) | |
39 crash(stack_trace_); | |
eroman
2012/03/28 18:02:50
OK, so you will want to do some extra work here. S
Ryan Hamilton
2012/03/28 18:15:44
AH! Awesome. I kinda thought that adding the Sta
| |
40 } | |
41 | |
24 // static | 42 // static |
25 base::TimeDelta ClientSocketPool::unused_idle_socket_timeout() { | 43 base::TimeDelta ClientSocketPool::unused_idle_socket_timeout() { |
26 return base::TimeDelta::FromSeconds(g_unused_idle_socket_timeout_s); | 44 return base::TimeDelta::FromSeconds(g_unused_idle_socket_timeout_s); |
27 } | 45 } |
28 | 46 |
29 // static | 47 // static |
30 void ClientSocketPool::set_unused_idle_socket_timeout(base::TimeDelta timeout) { | 48 void ClientSocketPool::set_unused_idle_socket_timeout(base::TimeDelta timeout) { |
31 DCHECK_GT(timeout.InSeconds(), 0); | 49 DCHECK_GT(timeout.InSeconds(), 0); |
32 g_unused_idle_socket_timeout_s = timeout.InSeconds(); | 50 g_unused_idle_socket_timeout_s = timeout.InSeconds(); |
33 } | 51 } |
34 | 52 |
35 // static | 53 // static |
36 base::TimeDelta ClientSocketPool::used_idle_socket_timeout() { | 54 base::TimeDelta ClientSocketPool::used_idle_socket_timeout() { |
37 return base::TimeDelta::FromSeconds(g_used_idle_socket_timeout_s); | 55 return base::TimeDelta::FromSeconds(g_used_idle_socket_timeout_s); |
38 } | 56 } |
39 | 57 |
40 // static | 58 // static |
41 void ClientSocketPool::set_used_idle_socket_timeout(base::TimeDelta timeout) { | 59 void ClientSocketPool::set_used_idle_socket_timeout(base::TimeDelta timeout) { |
42 DCHECK_GT(timeout.InSeconds(), 0); | 60 DCHECK_GT(timeout.InSeconds(), 0); |
43 g_used_idle_socket_timeout_s = timeout.InSeconds(); | 61 g_used_idle_socket_timeout_s = timeout.InSeconds(); |
44 } | 62 } |
45 | 63 |
46 ClientSocketPool::ClientSocketPool() {} | 64 ClientSocketPool::ClientSocketPool() {} |
47 | 65 |
48 ClientSocketPool::~ClientSocketPool() {} | 66 ClientSocketPool::~ClientSocketPool() {} |
49 | 67 |
50 } // namespace net | 68 } // namespace net |
OLD | NEW |