OLD | NEW |
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 #include "net/http/http_network_session.h" | 5 #include "net/http/http_network_session.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/atomic_sequence_num.h" | 9 #include "base/atomic_sequence_num.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/debug/stack_trace.h" | 11 #include "base/debug/stack_trace.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/memory/memory_coordinator_client_registry.h" |
13 #include "base/profiler/scoped_tracker.h" | 14 #include "base/profiler/scoped_tracker.h" |
14 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
15 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
16 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
17 #include "base/values.h" | 18 #include "base/values.h" |
18 #include "net/http/http_auth_handler_factory.h" | 19 #include "net/http/http_auth_handler_factory.h" |
19 #include "net/http/http_response_body_drainer.h" | 20 #include "net/http/http_response_body_drainer.h" |
20 #include "net/http/http_stream_factory_impl.h" | 21 #include "net/http/http_stream_factory_impl.h" |
21 #include "net/http/url_security_manager.h" | 22 #include "net/http/url_security_manager.h" |
22 #include "net/proxy/proxy_service.h" | 23 #include "net/proxy/proxy_service.h" |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 true; | 230 true; |
230 } | 231 } |
231 | 232 |
232 next_protos_.push_back(kProtoHTTP11); | 233 next_protos_.push_back(kProtoHTTP11); |
233 | 234 |
234 http_server_properties_->SetMaxServerConfigsStoredInProperties( | 235 http_server_properties_->SetMaxServerConfigsStoredInProperties( |
235 params.quic_max_server_configs_stored_in_properties); | 236 params.quic_max_server_configs_stored_in_properties); |
236 | 237 |
237 memory_pressure_listener_.reset(new base::MemoryPressureListener(base::Bind( | 238 memory_pressure_listener_.reset(new base::MemoryPressureListener(base::Bind( |
238 &HttpNetworkSession::OnMemoryPressure, base::Unretained(this)))); | 239 &HttpNetworkSession::OnMemoryPressure, base::Unretained(this)))); |
| 240 base::MemoryCoordinatorClientRegistry::GetInstance()->Register(this); |
239 } | 241 } |
240 | 242 |
241 HttpNetworkSession::~HttpNetworkSession() { | 243 HttpNetworkSession::~HttpNetworkSession() { |
242 base::STLDeleteElements(&response_drainers_); | 244 base::STLDeleteElements(&response_drainers_); |
243 spdy_session_pool_.CloseAllSessions(); | 245 spdy_session_pool_.CloseAllSessions(); |
| 246 base::MemoryCoordinatorClientRegistry::GetInstance()->Unregister(this); |
244 } | 247 } |
245 | 248 |
246 void HttpNetworkSession::AddResponseDrainer(HttpResponseBodyDrainer* drainer) { | 249 void HttpNetworkSession::AddResponseDrainer(HttpResponseBodyDrainer* drainer) { |
247 DCHECK(!base::ContainsKey(response_drainers_, drainer)); | 250 DCHECK(!base::ContainsKey(response_drainers_, drainer)); |
248 response_drainers_.insert(drainer); | 251 response_drainers_.insert(drainer); |
249 } | 252 } |
250 | 253 |
251 void HttpNetworkSession::RemoveResponseDrainer( | 254 void HttpNetworkSession::RemoveResponseDrainer( |
252 HttpResponseBodyDrainer* drainer) { | 255 HttpResponseBodyDrainer* drainer) { |
253 DCHECK(base::ContainsKey(response_drainers_, drainer)); | 256 DCHECK(base::ContainsKey(response_drainers_, drainer)); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 switch (memory_pressure_level) { | 400 switch (memory_pressure_level) { |
398 case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE: | 401 case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE: |
399 break; | 402 break; |
400 case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE: | 403 case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE: |
401 case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL: | 404 case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL: |
402 CloseIdleConnections(); | 405 CloseIdleConnections(); |
403 break; | 406 break; |
404 } | 407 } |
405 } | 408 } |
406 | 409 |
| 410 void HttpNetworkSession::OnMemoryStateChange(base::MemoryState state) { |
| 411 // TODO(hajimehoshi): When the state changes, adjust the sizes of the caches |
| 412 // to reduce the limits. HttpNetworkSession doesn't have the ability to limit |
| 413 // at present. |
| 414 switch (state) { |
| 415 case base::MemoryState::NORMAL: |
| 416 break; |
| 417 case base::MemoryState::THROTTLED: |
| 418 CloseIdleConnections(); |
| 419 break; |
| 420 case base::MemoryState::SUSPENDED: |
| 421 // Note: Not supported at present. Fall through. |
| 422 case base::MemoryState::UNKNOWN: |
| 423 NOTREACHED(); |
| 424 break; |
| 425 } |
| 426 } |
| 427 |
407 } // namespace net | 428 } // namespace net |
OLD | NEW |