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): As OnMemoryStateChange changes the state, we should | |
412 // adjust the limitation to the amount of cache, HttpNetworkSession doesn't | |
413 // have such limitation so far though. | |
Ryan Sleevi
2016/09/26 15:15:59
I often link to https://groups.google.com/a/chromi
hajimehoshi
2016/09/27 11:39:29
Done.
hajimehoshi
2016/09/27 11:39:29
Done.
| |
414 switch (state) { | |
415 case base::MemoryState::NORMAL: | |
416 break; | |
417 case base::MemoryState::THROTTLED: | |
418 // TOOD(hajimehoshi): We don't have throttling 'level' so far. When we | |
419 // have such value, let's change the argument accroding to the value. | |
Ryan Sleevi
2016/09/26 15:15:59
Typo: according
But I'm also uncertain what this
hajimehoshi
2016/09/27 11:39:29
Done (removed). IIRC we don't have any plan to add
| |
420 CloseIdleConnections(); | |
421 break; | |
422 case base::MemoryState::SUSPENDED: | |
423 // Note that SUSPENDED never occurs in the main browser process so far. | |
Ryan Sleevi
2016/09/26 15:15:59
//net shouldn't talk about things like "main brows
hajimehoshi
2016/09/27 11:39:29
Done.
| |
424 // Fall through. | |
425 case base::MemoryState::UNKNOWN: | |
426 NOTREACHED(); | |
427 break; | |
428 } | |
429 } | |
430 | |
407 } // namespace net | 431 } // namespace net |
OLD | NEW |