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

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

Issue 2471153002: [scheduler] Use Finch to control background throttling. (Closed)
Patch Set: Address nits from skyostil@ 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..6cc15f086b5513ad8ba2353615e95ece65994534 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 MaybeSetFloatParameterFromMap(
ojan 2016/11/08 19:41:15 Drive-by pet-peeve nit: I don't feel like this "Ma
altimin 2016/11/09 14:46:29 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,23 @@ WebPreferences RenderViewHostImpl::ComputeWebkitPrefs() {
if (delegate_ && delegate_->HideDownloadUI())
prefs.hide_download_ui = true;
+ std::map<std::string, std::string> expensive_background_throttling_prefs;
+ variations::GetVariationParamsByFeature(
clamy 2016/11/09 14:28:51 We've tried to avoid using things from components
altimin 2016/11/09 14:46:29 I didn't find any other cases of plumbing paramete
clamy 2016/11/09 15:27:07 Acknowledged.
+ features::kExpensiveBackgroundTimerThrottling,
+ &expensive_background_throttling_prefs);
+ MaybeSetFloatParameterFromMap(
+ expensive_background_throttling_prefs, "cpu_budget",
+ &prefs.expensive_background_throttling_cpu_budget);
+ MaybeSetFloatParameterFromMap(
+ expensive_background_throttling_prefs, "initial_budget",
+ &prefs.expensive_background_throttling_initial_budget);
+ MaybeSetFloatParameterFromMap(
+ expensive_background_throttling_prefs, "max_budget",
+ &prefs.expensive_background_throttling_max_budget);
+ MaybeSetFloatParameterFromMap(
+ 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