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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/public/common/content_switches.cc ('k') | skia/ext/SkDiscardableMemory_chrome.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/render_thread_impl.h" 5 #include "content/renderer/render_thread_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <map> 9 #include <map>
10 #include <vector> 10 #include <vector>
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 base::FilePath media_path; 399 base::FilePath media_path;
400 PathService::Get(DIR_MEDIA_LIBS, &media_path); 400 PathService::Get(DIR_MEDIA_LIBS, &media_path);
401 if (!media_path.empty()) 401 if (!media_path.empty())
402 media::InitializeMediaLibrary(media_path); 402 media::InitializeMediaLibrary(media_path);
403 403
404 memory_pressure_listener_.reset(new base::MemoryPressureListener( 404 memory_pressure_listener_.reset(new base::MemoryPressureListener(
405 base::Bind(&RenderThreadImpl::OnMemoryPressure, base::Unretained(this)))); 405 base::Bind(&RenderThreadImpl::OnMemoryPressure, base::Unretained(this))));
406 406
407 renderer_process_id_ = base::kNullProcessId; 407 renderer_process_id_ = base::kNullProcessId;
408 408
409 std::vector<base::DiscardableMemoryType> supported_types;
410 base::DiscardableMemory::GetSupportedTypes(&supported_types);
411 DCHECK(!supported_types.empty());
412
413 // The default preferred type is always the first one in list.
414 base::DiscardableMemoryType type = supported_types[0];
415
416 if (command_line.HasSwitch(switches::kUseDiscardableMemory)) {
417 std::string requested_type_name = command_line.GetSwitchValueASCII(
418 switches::kUseDiscardableMemory);
419 base::DiscardableMemoryType requested_type =
420 base::DiscardableMemory::GetNamedType(requested_type_name);
421 if (std::find(supported_types.begin(),
422 supported_types.end(),
423 requested_type) != supported_types.end()) {
424 type = requested_type;
425 } else {
426 LOG(ERROR) << "Requested discardable memory type is not supported.";
427 }
428 }
429
430 base::DiscardableMemory::SetPreferredType(type);
431
409 // AllocateGpuMemoryBuffer must be used exclusively on one thread but 432 // AllocateGpuMemoryBuffer must be used exclusively on one thread but
410 // it doesn't have to be the same thread RenderThreadImpl is created on. 433 // it doesn't have to be the same thread RenderThreadImpl is created on.
411 allocate_gpu_memory_buffer_thread_checker_.DetachFromThread(); 434 allocate_gpu_memory_buffer_thread_checker_.DetachFromThread();
412 435
413 TRACE_EVENT_END_ETW("RenderThreadImpl::Init", 0, ""); 436 TRACE_EVENT_END_ETW("RenderThreadImpl::Init", 0, "");
414 } 437 }
415 438
416 RenderThreadImpl::~RenderThreadImpl() { 439 RenderThreadImpl::~RenderThreadImpl() {
417 } 440 }
418 441
(...skipping 935 matching lines...) Expand 10 before | Expand all | Expand 10 after
1354 if (!gamepad_shared_memory_reader_) 1377 if (!gamepad_shared_memory_reader_)
1355 gamepad_shared_memory_reader_.reset(new GamepadSharedMemoryReader); 1378 gamepad_shared_memory_reader_.reset(new GamepadSharedMemoryReader);
1356 gamepad_shared_memory_reader_->SampleGamepads(*data); 1379 gamepad_shared_memory_reader_->SampleGamepads(*data);
1357 } 1380 }
1358 1381
1359 base::ProcessId RenderThreadImpl::renderer_process_id() const { 1382 base::ProcessId RenderThreadImpl::renderer_process_id() const {
1360 return renderer_process_id_; 1383 return renderer_process_id_;
1361 } 1384 }
1362 1385
1363 } // namespace content 1386 } // namespace content
OLDNEW
« 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