Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(164)

Unified Diff: net/http/http_network_session.cc

Issue 2359723006: Make HttpNetworkSession a client of memory coordinator (Closed)
Patch Set: Address on reviews Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/http/http_network_session.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_network_session.cc
diff --git a/net/http/http_network_session.cc b/net/http/http_network_session.cc
index 66a4eab8b06649bcdb76d4f5142b6912c2fe0bdc..03392bb773c429cb9be704380ac180c0137b9059 100644
--- a/net/http/http_network_session.cc
+++ b/net/http/http_network_session.cc
@@ -10,6 +10,7 @@
#include "base/compiler_specific.h"
#include "base/debug/stack_trace.h"
#include "base/logging.h"
+#include "base/memory/memory_coordinator_client_registry.h"
#include "base/profiler/scoped_tracker.h"
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
@@ -236,11 +237,13 @@ HttpNetworkSession::HttpNetworkSession(const Params& params)
memory_pressure_listener_.reset(new base::MemoryPressureListener(base::Bind(
&HttpNetworkSession::OnMemoryPressure, base::Unretained(this))));
+ base::MemoryCoordinatorClientRegistry::GetInstance()->Register(this);
}
HttpNetworkSession::~HttpNetworkSession() {
base::STLDeleteElements(&response_drainers_);
spdy_session_pool_.CloseAllSessions();
+ base::MemoryCoordinatorClientRegistry::GetInstance()->Unregister(this);
}
void HttpNetworkSession::AddResponseDrainer(HttpResponseBodyDrainer* drainer) {
@@ -404,4 +407,22 @@ void HttpNetworkSession::OnMemoryPressure(
}
}
+void HttpNetworkSession::OnMemoryStateChange(base::MemoryState state) {
+ // TODO(hajimehoshi): When the state changes, adjust the sizes of the caches
+ // to reduce the limits. HttpNetworkSession doesn't have the ability to limit
+ // at present.
+ switch (state) {
+ case base::MemoryState::NORMAL:
+ break;
+ case base::MemoryState::THROTTLED:
+ CloseIdleConnections();
+ break;
+ case base::MemoryState::SUSPENDED:
+ // Note: Not supported at present. Fall through.
+ case base::MemoryState::UNKNOWN:
+ NOTREACHED();
+ break;
+ }
+}
+
} // namespace net
« no previous file with comments | « net/http/http_network_session.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698