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/debug/alias.h" | |
7 #include "base/logging.h" | 8 #include "base/logging.h" |
8 | 9 |
9 namespace { | 10 namespace { |
10 | 11 |
11 // The maximum duration, in seconds, to keep unused idle persistent sockets | 12 // The maximum duration, in seconds, to keep unused idle persistent sockets |
12 // alive. | 13 // alive. |
13 // TODO(ziadh): Change this timeout after getting histogram data on how long it | 14 // TODO(ziadh): Change this timeout after getting histogram data on how long it |
14 // should be. | 15 // should be. |
15 int g_unused_idle_socket_timeout_s = 10; | 16 int g_unused_idle_socket_timeout_s = 10; |
16 | 17 |
17 // The maximum duration, in seconds, to keep used idle persistent sockets alive. | 18 // The maximum duration, in seconds, to keep used idle persistent sockets alive. |
18 int g_used_idle_socket_timeout_s = 300; // 5 minutes | 19 int g_used_idle_socket_timeout_s = 300; // 5 minutes |
19 | 20 |
20 } // namespace | 21 } // namespace |
21 | 22 |
22 namespace net { | 23 namespace net { |
23 | 24 |
25 LayeredPool::LayeredPool() { | |
26 magic_value_ = ALIVE; | |
eroman
2012/03/28 18:25:59
nit: i suggest putting this in initializer list (i
Ryan Hamilton
2012/03/28 18:35:28
Duh! Good point.
| |
27 } | |
28 | |
29 LayeredPool::~LayeredPool() { | |
eroman
2012/03/28 18:25:59
I suggest calling CrashIfFreed() first.
Double-fre
Ryan Hamilton
2012/03/28 18:35:28
Done.
| |
30 magic_value_ = DEAD; | |
31 stack_trace_ = base::debug::StackTrace(); | |
32 } | |
33 | |
34 void LayeredPool::CrashIfFreed() { | |
35 if (magic_value_ != ALIVE) { | |
36 MagicValue magic_value = magic_value_; | |
37 base::debug::StackTrace deletion_callstack = stack_trace_; | |
38 | |
39 base::debug::Alias(&magic_value); | |
40 base::debug::Alias(&deletion_callstack); | |
41 | |
42 CHECK(false); | |
43 } | |
44 } | |
45 | |
24 // static | 46 // static |
25 base::TimeDelta ClientSocketPool::unused_idle_socket_timeout() { | 47 base::TimeDelta ClientSocketPool::unused_idle_socket_timeout() { |
26 return base::TimeDelta::FromSeconds(g_unused_idle_socket_timeout_s); | 48 return base::TimeDelta::FromSeconds(g_unused_idle_socket_timeout_s); |
27 } | 49 } |
28 | 50 |
29 // static | 51 // static |
30 void ClientSocketPool::set_unused_idle_socket_timeout(base::TimeDelta timeout) { | 52 void ClientSocketPool::set_unused_idle_socket_timeout(base::TimeDelta timeout) { |
31 DCHECK_GT(timeout.InSeconds(), 0); | 53 DCHECK_GT(timeout.InSeconds(), 0); |
32 g_unused_idle_socket_timeout_s = timeout.InSeconds(); | 54 g_unused_idle_socket_timeout_s = timeout.InSeconds(); |
33 } | 55 } |
34 | 56 |
35 // static | 57 // static |
36 base::TimeDelta ClientSocketPool::used_idle_socket_timeout() { | 58 base::TimeDelta ClientSocketPool::used_idle_socket_timeout() { |
37 return base::TimeDelta::FromSeconds(g_used_idle_socket_timeout_s); | 59 return base::TimeDelta::FromSeconds(g_used_idle_socket_timeout_s); |
38 } | 60 } |
39 | 61 |
40 // static | 62 // static |
41 void ClientSocketPool::set_used_idle_socket_timeout(base::TimeDelta timeout) { | 63 void ClientSocketPool::set_used_idle_socket_timeout(base::TimeDelta timeout) { |
42 DCHECK_GT(timeout.InSeconds(), 0); | 64 DCHECK_GT(timeout.InSeconds(), 0); |
43 g_used_idle_socket_timeout_s = timeout.InSeconds(); | 65 g_used_idle_socket_timeout_s = timeout.InSeconds(); |
44 } | 66 } |
45 | 67 |
46 ClientSocketPool::ClientSocketPool() {} | 68 ClientSocketPool::ClientSocketPool() {} |
47 | 69 |
48 ClientSocketPool::~ClientSocketPool() {} | 70 ClientSocketPool::~ClientSocketPool() {} |
49 | 71 |
50 } // namespace net | 72 } // namespace net |
OLD | NEW |