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

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

Issue 2471153002: [scheduler] Use Finch to control background throttling. (Closed)
Patch Set: Fix test and address comments 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
« no previous file with comments | « content/browser/renderer_host/DEPS ('k') | content/public/common/common_param_traits_macros.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 7765de69bcad5474a376a061a0100e4a78d1bbea..a0f34b66f7d98c3db9ead41896275692cb19d157 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"
@@ -406,6 +408,23 @@ void RenderViewHostImpl::SyncRendererPrefs() {
Send(new ViewMsg_SetRendererPrefs(GetRoutingID(), renderer_preferences));
}
+namespace {
+
+void SetFloatParameterFromMap(
+ 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;
@@ -565,6 +584,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);
+ SetFloatParameterFromMap(expensive_background_throttling_prefs, "cpu_budget",
+ &prefs.expensive_background_throttling_cpu_budget);
+ SetFloatParameterFromMap(
+ expensive_background_throttling_prefs, "initial_budget",
+ &prefs.expensive_background_throttling_initial_budget);
+ SetFloatParameterFromMap(expensive_background_throttling_prefs, "max_budget",
+ &prefs.expensive_background_throttling_max_budget);
+ SetFloatParameterFromMap(expensive_background_throttling_prefs, "max_delay",
+ &prefs.expensive_background_throttling_max_delay);
+
GetContentClient()->browser()->OverrideWebkitPrefs(this, &prefs);
return prefs;
}
« no previous file with comments | « content/browser/renderer_host/DEPS ('k') | content/public/common/common_param_traits_macros.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698