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

Unified Diff: content/renderer/render_thread_impl.cc

Issue 114923005: base: Discardable memory types. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add switches::kUseDiscardableMemory to kForwardSwitches Created 6 years, 11 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 | « content/public/common/content_switches.cc ('k') | skia/ext/SkDiscardableMemory_chrome.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_thread_impl.cc
diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc
index 5e8db708edbb397c655e02f4a414fad57bd1aaff..ec28fe54cd9e1dc2da8eb7767577718c6a3dc9ef 100644
--- a/content/renderer/render_thread_impl.cc
+++ b/content/renderer/render_thread_impl.cc
@@ -406,6 +406,29 @@ void RenderThreadImpl::Init() {
renderer_process_id_ = base::kNullProcessId;
+ std::vector<base::DiscardableMemoryType> supported_types;
+ base::DiscardableMemory::GetSupportedTypes(&supported_types);
+ DCHECK(!supported_types.empty());
+
+ // The default preferred type is always the first one in list.
+ base::DiscardableMemoryType type = supported_types[0];
+
+ if (command_line.HasSwitch(switches::kUseDiscardableMemory)) {
+ std::string requested_type_name = command_line.GetSwitchValueASCII(
+ switches::kUseDiscardableMemory);
+ base::DiscardableMemoryType requested_type =
+ base::DiscardableMemory::GetNamedType(requested_type_name);
+ if (std::find(supported_types.begin(),
+ supported_types.end(),
+ requested_type) != supported_types.end()) {
+ type = requested_type;
+ } else {
+ LOG(ERROR) << "Requested discardable memory type is not supported.";
+ }
+ }
+
+ base::DiscardableMemory::SetPreferredType(type);
+
// AllocateGpuMemoryBuffer must be used exclusively on one thread but
// it doesn't have to be the same thread RenderThreadImpl is created on.
allocate_gpu_memory_buffer_thread_checker_.DetachFromThread();
« no previous file with comments | « content/public/common/content_switches.cc ('k') | skia/ext/SkDiscardableMemory_chrome.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698