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

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 missing include Created 7 years 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
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 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 base::FilePath media_path; 404 base::FilePath media_path;
405 PathService::Get(DIR_MEDIA_LIBS, &media_path); 405 PathService::Get(DIR_MEDIA_LIBS, &media_path);
406 if (!media_path.empty()) 406 if (!media_path.empty())
407 media::InitializeMediaLibrary(media_path); 407 media::InitializeMediaLibrary(media_path);
408 408
409 memory_pressure_listener_.reset(new base::MemoryPressureListener( 409 memory_pressure_listener_.reset(new base::MemoryPressureListener(
410 base::Bind(&RenderThreadImpl::OnMemoryPressure, base::Unretained(this)))); 410 base::Bind(&RenderThreadImpl::OnMemoryPressure, base::Unretained(this))));
411 411
412 renderer_process_id_ = base::kNullProcessId; 412 renderer_process_id_ = base::kNullProcessId;
413 413
414 std::vector<base::DiscardableMemoryType> supported_types;
415 base::DiscardableMemory::GetSupportedTypes(&supported_types);
416 DCHECK(!supported_types.empty());
417
418 // The preferred type is always the first one in list.
419 base::DiscardableMemoryType type = supported_types[0];
420
421 if (command_line.HasSwitch(switches::kUseDiscardableMemory)) {
422 std::string requested_type_name = command_line.GetSwitchValueASCII(
423 switches::kUseDiscardableMemory);
424 base::DiscardableMemoryType requested_type =
425 base::DiscardableMemory::GetNamedType(requested_type_name);
426 if (std::find(supported_types.begin(),
427 supported_types.end(),
428 requested_type) != supported_types.end()) {
429 type = requested_type;
430 } else {
431 LOG(ERROR) << "Requested discardable memory type is not supported.";
432 }
433 }
434
435 base::DiscardableMemory::SetType(type);
436
414 // AllocateGpuMemoryBuffer must be used exclusively on one thread but 437 // AllocateGpuMemoryBuffer must be used exclusively on one thread but
415 // it doesn't have to be the same thread RenderThreadImpl is created on. 438 // it doesn't have to be the same thread RenderThreadImpl is created on.
416 allocate_gpu_memory_buffer_thread_checker_.DetachFromThread(); 439 allocate_gpu_memory_buffer_thread_checker_.DetachFromThread();
417 440
418 TRACE_EVENT_END_ETW("RenderThreadImpl::Init", 0, ""); 441 TRACE_EVENT_END_ETW("RenderThreadImpl::Init", 0, "");
419 } 442 }
420 443
421 RenderThreadImpl::~RenderThreadImpl() { 444 RenderThreadImpl::~RenderThreadImpl() {
422 } 445 }
423 446
(...skipping 935 matching lines...) Expand 10 before | Expand all | Expand 10 after
1359 if (!gamepad_shared_memory_reader_) 1382 if (!gamepad_shared_memory_reader_)
1360 gamepad_shared_memory_reader_.reset(new GamepadSharedMemoryReader); 1383 gamepad_shared_memory_reader_.reset(new GamepadSharedMemoryReader);
1361 gamepad_shared_memory_reader_->SampleGamepads(*data); 1384 gamepad_shared_memory_reader_->SampleGamepads(*data);
1362 } 1385 }
1363 1386
1364 base::ProcessId RenderThreadImpl::renderer_process_id() const { 1387 base::ProcessId RenderThreadImpl::renderer_process_id() const {
1365 return renderer_process_id_; 1388 return renderer_process_id_;
1366 } 1389 }
1367 1390
1368 } // namespace content 1391 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698