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

Unified Diff: ui/aura/mus/window_tree_client.cc

Issue 2741063002: Setup DiscardableMemory in the ash process (Closed)
Patch Set: Rebase Created 3 years, 9 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 | « ui/aura/mus/window_tree_client.h ('k') | ui/views/mus/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/mus/window_tree_client.cc
diff --git a/ui/aura/mus/window_tree_client.cc b/ui/aura/mus/window_tree_client.cc
index bc00034df1b57ced12c7b4e8cd97573612256d7d..1b57f14f5b129b8f4b0614063a38f6bc6f5b712f 100644
--- a/ui/aura/mus/window_tree_client.cc
+++ b/ui/aura/mus/window_tree_client.cc
@@ -13,6 +13,8 @@
#include "base/auto_reset.h"
#include "base/bind.h"
#include "base/memory/ptr_util.h"
+#include "base/threading/thread.h"
+#include "components/discardable_memory/client/client_discardable_shared_memory_manager.h"
#include "mojo/public/cpp/bindings/map.h"
#include "services/service_manager/public/cpp/connector.h"
#include "services/ui/common/accelerator_util.h"
@@ -173,7 +175,8 @@ WindowTreeClient::WindowTreeClient(
WindowTreeClientDelegate* delegate,
WindowManagerDelegate* window_manager_delegate,
mojo::InterfaceRequest<ui::mojom::WindowTreeClient> request,
- scoped_refptr<base::SingleThreadTaskRunner> io_task_runner)
+ scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
+ bool create_discardable_memory)
: connector_(connector),
client_id_(0),
next_window_id_(1),
@@ -192,17 +195,42 @@ WindowTreeClient::WindowTreeClient(
if (window_manager_delegate)
window_manager_delegate->SetWindowManagerClient(this);
if (connector) { // |connector| can be null in tests.
- gpu_ = ui::Gpu::Create(connector, std::move(io_task_runner));
+ if (!io_task_runner) {
+ // |io_task_runner| is null in most case. But for the browser process,
+ // the |io_task_runner| is the browser's IO thread.
+ io_thread_ = base::MakeUnique<base::Thread>("IOThread");
+ base::Thread::Options thread_options(base::MessageLoop::TYPE_IO, 0);
+ thread_options.priority = base::ThreadPriority::NORMAL;
+ CHECK(io_thread_->StartWithOptions(thread_options));
+ io_task_runner = io_thread_->task_runner();
+ }
+
+ gpu_ = ui::Gpu::Create(connector, io_task_runner);
compositor_context_factory_ =
base::MakeUnique<MusContextFactory>(gpu_.get());
initial_context_factory_ = Env::GetInstance()->context_factory();
Env::GetInstance()->set_context_factory(compositor_context_factory_.get());
+
+ // WindowServerTest will create more than one WindowTreeClient. We will not
+ // create the discardable memory manager for those tests.
+ if (create_discardable_memory) {
+ discardable_memory::mojom::DiscardableSharedMemoryManagerPtr manager_ptr;
+ connector->BindInterface(ui::mojom::kServiceName, &manager_ptr);
+ discardable_shared_memory_manager_ = base::MakeUnique<
+ discardable_memory::ClientDiscardableSharedMemoryManager>(
+ std::move(manager_ptr), std::move(io_task_runner));
+ base::DiscardableMemoryAllocator::SetInstance(
+ discardable_shared_memory_manager_.get());
+ }
}
}
WindowTreeClient::~WindowTreeClient() {
in_destructor_ = true;
+ if (discardable_shared_memory_manager_)
+ base::DiscardableMemoryAllocator::SetInstance(nullptr);
+
for (WindowTreeClientObserver& observer : observers_)
observer.OnWillDestroyClient(this);
« no previous file with comments | « ui/aura/mus/window_tree_client.h ('k') | ui/views/mus/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698