| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/mus/renderer_window_tree_client.h" | 5 #include "content/renderer/mus/renderer_window_tree_client.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "services/ui/public/cpp/window_compositor_frame_sink.h" | 10 #include "services/ui/public/cpp/window_compositor_frame_sink.h" |
| 11 | 11 |
| 12 namespace content { | 12 namespace content { |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 typedef std::map<int, RendererWindowTreeClient*> ConnectionMap; | 15 typedef std::map<int, RendererWindowTreeClient*> ConnectionMap; |
| 16 base::LazyInstance<ConnectionMap>::Leaky g_connections = | 16 base::LazyInstance<ConnectionMap>::Leaky g_connections = |
| 17 LAZY_INSTANCE_INITIALIZER; | 17 LAZY_INSTANCE_INITIALIZER; |
| 18 } // namespace | 18 } // namespace |
| 19 | 19 |
| 20 // static | 20 // static |
| 21 RendererWindowTreeClient* RendererWindowTreeClient::Get(int routing_id) { | 21 RendererWindowTreeClient* RendererWindowTreeClient::Get(int routing_id) { |
| 22 auto it = g_connections.Get().find(routing_id); | 22 auto it = g_connections.Get().find(routing_id); |
| 23 if (it != g_connections.Get().end()) | 23 if (it != g_connections.Get().end()) |
| 24 return it->second; | 24 return it->second; |
| 25 return nullptr; | 25 return nullptr; |
| 26 } | 26 } |
| 27 | 27 |
| 28 // static | 28 // static |
| 29 void RendererWindowTreeClient::Create(int routing_id) { | 29 void RendererWindowTreeClient::Create(int routing_id) { |
| 30 DCHECK(g_connections.Get().find(routing_id) == g_connections.Get().end()); | 30 DCHECK(g_connections.Get().find(routing_id) == g_connections.Get().end()) |
| 31 << routing_id; |
| 31 RendererWindowTreeClient* connection = | 32 RendererWindowTreeClient* connection = |
| 32 new RendererWindowTreeClient(routing_id); | 33 new RendererWindowTreeClient(routing_id); |
| 33 g_connections.Get().insert(std::make_pair(routing_id, connection)); | 34 g_connections.Get().insert(std::make_pair(routing_id, connection)); |
| 34 } | 35 } |
| 35 | 36 |
| 37 // static |
| 38 void RendererWindowTreeClient::Destroy(int routing_id) { |
| 39 auto* client = Get(routing_id); |
| 40 if (client) |
| 41 client->DestroySelf(); |
| 42 } |
| 43 |
| 36 RendererWindowTreeClient::RendererWindowTreeClient(int routing_id) | 44 RendererWindowTreeClient::RendererWindowTreeClient(int routing_id) |
| 37 : routing_id_(routing_id), binding_(this) {} | 45 : routing_id_(routing_id), binding_(this) {} |
| 38 | 46 |
| 39 RendererWindowTreeClient::~RendererWindowTreeClient() { | 47 RendererWindowTreeClient::~RendererWindowTreeClient() { |
| 40 g_connections.Get().erase(routing_id_); | 48 g_connections.Get().erase(routing_id_); |
| 41 } | 49 } |
| 42 | 50 |
| 43 void RendererWindowTreeClient::Bind( | 51 void RendererWindowTreeClient::Bind( |
| 44 ui::mojom::WindowTreeClientRequest request) { | 52 ui::mojom::WindowTreeClientRequest request) { |
| 45 binding_.Bind(std::move(request)); | 53 binding_.Bind(std::move(request)); |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 bool success) {} | 224 bool success) {} |
| 217 | 225 |
| 218 void RendererWindowTreeClient::RequestClose(uint32_t window_id) {} | 226 void RendererWindowTreeClient::RequestClose(uint32_t window_id) {} |
| 219 | 227 |
| 220 void RendererWindowTreeClient::GetWindowManager( | 228 void RendererWindowTreeClient::GetWindowManager( |
| 221 mojo::AssociatedInterfaceRequest<ui::mojom::WindowManager> internal) { | 229 mojo::AssociatedInterfaceRequest<ui::mojom::WindowManager> internal) { |
| 222 NOTREACHED(); | 230 NOTREACHED(); |
| 223 } | 231 } |
| 224 | 232 |
| 225 } // namespace content | 233 } // namespace content |
| OLD | NEW |