OLD | NEW |
1 // Copyright (c) 2012 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" | |
8 #include "base/logging.h" | 7 #include "base/logging.h" |
9 | 8 |
10 namespace { | 9 namespace { |
11 | 10 |
12 // The maximum duration, in seconds, to keep unused idle persistent sockets | 11 // The maximum duration, in seconds, to keep unused idle persistent sockets |
13 // alive. | 12 // alive. |
14 // 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 |
15 // should be. | 14 // should be. |
16 int g_unused_idle_socket_timeout_s = 10; | 15 int g_unused_idle_socket_timeout_s = 10; |
17 | 16 |
18 // 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. |
19 int g_used_idle_socket_timeout_s = 300; // 5 minutes | 18 int g_used_idle_socket_timeout_s = 300; // 5 minutes |
20 | 19 |
21 } // namespace | 20 } // namespace |
22 | 21 |
23 namespace net { | 22 namespace net { |
24 | 23 |
25 LayeredPool::LayeredPool() : magic_value_(ALIVE) {} | |
26 | |
27 LayeredPool::~LayeredPool() { | |
28 CrashIfFreed(); | |
29 magic_value_ = DEAD; | |
30 stack_trace_ = base::debug::StackTrace(); | |
31 } | |
32 | |
33 void LayeredPool::CrashIfFreed() { | |
34 if (magic_value_ != ALIVE) { | |
35 MagicValue magic_value = magic_value_; | |
36 base::debug::StackTrace deletion_callstack = stack_trace_; | |
37 | |
38 base::debug::Alias(&magic_value); | |
39 base::debug::Alias(&deletion_callstack); | |
40 | |
41 CHECK(false); | |
42 } | |
43 } | |
44 | |
45 // static | 24 // static |
46 base::TimeDelta ClientSocketPool::unused_idle_socket_timeout() { | 25 base::TimeDelta ClientSocketPool::unused_idle_socket_timeout() { |
47 return base::TimeDelta::FromSeconds(g_unused_idle_socket_timeout_s); | 26 return base::TimeDelta::FromSeconds(g_unused_idle_socket_timeout_s); |
48 } | 27 } |
49 | 28 |
50 // static | 29 // static |
51 void ClientSocketPool::set_unused_idle_socket_timeout(base::TimeDelta timeout) { | 30 void ClientSocketPool::set_unused_idle_socket_timeout(base::TimeDelta timeout) { |
52 DCHECK_GT(timeout.InSeconds(), 0); | 31 DCHECK_GT(timeout.InSeconds(), 0); |
53 g_unused_idle_socket_timeout_s = timeout.InSeconds(); | 32 g_unused_idle_socket_timeout_s = timeout.InSeconds(); |
54 } | 33 } |
55 | 34 |
56 // static | 35 // static |
57 base::TimeDelta ClientSocketPool::used_idle_socket_timeout() { | 36 base::TimeDelta ClientSocketPool::used_idle_socket_timeout() { |
58 return base::TimeDelta::FromSeconds(g_used_idle_socket_timeout_s); | 37 return base::TimeDelta::FromSeconds(g_used_idle_socket_timeout_s); |
59 } | 38 } |
60 | 39 |
61 // static | 40 // static |
62 void ClientSocketPool::set_used_idle_socket_timeout(base::TimeDelta timeout) { | 41 void ClientSocketPool::set_used_idle_socket_timeout(base::TimeDelta timeout) { |
63 DCHECK_GT(timeout.InSeconds(), 0); | 42 DCHECK_GT(timeout.InSeconds(), 0); |
64 g_used_idle_socket_timeout_s = timeout.InSeconds(); | 43 g_used_idle_socket_timeout_s = timeout.InSeconds(); |
65 } | 44 } |
66 | 45 |
67 ClientSocketPool::ClientSocketPool() {} | 46 ClientSocketPool::ClientSocketPool() {} |
68 | 47 |
69 ClientSocketPool::~ClientSocketPool() {} | 48 ClientSocketPool::~ClientSocketPool() {} |
70 | 49 |
71 } // namespace net | 50 } // namespace net |
OLD | NEW |