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

Unified Diff: content/browser/renderer_host/render_view_host_impl.cc

Issue 2471153002: [scheduler] Use Finch to control background throttling. (Closed)
Patch Set: Addressed comments from alexclarke@ Created 4 years, 1 month 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
Index: content/browser/renderer_host/render_view_host_impl.cc
diff --git a/content/browser/renderer_host/render_view_host_impl.cc b/content/browser/renderer_host/render_view_host_impl.cc
index 463b5d1e0432dda6abf647fba21089dde042d18f..350272fd3630dd340fa2ee32ce420c3338cd143c 100644
--- a/content/browser/renderer_host/render_view_host_impl.cc
+++ b/content/browser/renderer_host/render_view_host_impl.cc
@@ -19,6 +19,7 @@
#include "base/metrics/field_trial.h"
#include "base/metrics/histogram_macros.h"
#include "base/stl_util.h"
+#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/sys_info.h"
@@ -27,6 +28,7 @@
#include "base/values.h"
#include "build/build_config.h"
#include "cc/base/switches.h"
+#include "components/variations/variations_associated_data.h"
#include "content/browser/bad_message.h"
#include "content/browser/child_process_security_policy_impl.h"
#include "content/browser/dom_storage/session_storage_namespace_impl.h"
@@ -413,6 +415,23 @@ void RenderViewHostImpl::SyncRendererPrefs() {
Send(new ViewMsg_SetRendererPrefs(GetRoutingID(), renderer_preferences));
}
+namespace {
+
+void MaybeSetParameterFromMap(
Sami 2016/11/03 13:21:15 MaybeSetFloat/DoubleParameterFromMap?
altimin 2016/11/04 10:41:25 Done.
+ const std::map<std::string, std::string>& settings,
+ const std::string& setting_name,
+ float* value) {
+ const auto& find_it = settings.find(setting_name);
+ if (find_it == settings.end())
+ return;
+ double parsed_value;
+ if (!base::StringToDouble(find_it->second, &parsed_value))
+ return;
+ *value = parsed_value;
+}
+
+} // namespace
+
WebPreferences RenderViewHostImpl::ComputeWebkitPrefs() {
TRACE_EVENT0("browser", "RenderViewHostImpl::GetWebkitPrefs");
WebPreferences prefs;
@@ -572,6 +591,20 @@ WebPreferences RenderViewHostImpl::ComputeWebkitPrefs() {
if (delegate_ && delegate_->HideDownloadUI())
prefs.hide_download_ui = true;
+ std::map<std::string, std::string> expensive_background_throttling_prefs;
+ variations::GetVariationParamsByFeature(
+ features::kExpensiveBackgroundTimerThrottling,
+ &expensive_background_throttling_prefs);
+ MaybeSetParameterFromMap(expensive_background_throttling_prefs, "cpu_budget",
+ &prefs.expensive_background_throttling_cpu_budget);
+ MaybeSetParameterFromMap(
+ expensive_background_throttling_prefs, "initial_budget",
+ &prefs.expensive_background_throttling_initial_budget);
+ MaybeSetParameterFromMap(expensive_background_throttling_prefs, "max_budget",
+ &prefs.expensive_background_throttling_max_budget);
+ MaybeSetParameterFromMap(expensive_background_throttling_prefs, "max_delay",
+ &prefs.expensive_background_throttling_max_delay);
+
GetContentClient()->browser()->OverrideWebkitPrefs(this, &prefs);
return prefs;
}

Powered by Google App Engine
This is Rietveld 408576698