| 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::CreateIfNecessary(int routing_id) { |
| 30 DCHECK(g_connections.Get().find(routing_id) == g_connections.Get().end()) | 30 if (Get(routing_id)) |
| 31 << routing_id; | 31 return; |
| 32 RendererWindowTreeClient* connection = | 32 RendererWindowTreeClient* connection = |
| 33 new RendererWindowTreeClient(routing_id); | 33 new RendererWindowTreeClient(routing_id); |
| 34 g_connections.Get().insert(std::make_pair(routing_id, connection)); | 34 g_connections.Get().insert(std::make_pair(routing_id, connection)); |
| 35 } | 35 } |
| 36 | 36 |
| 37 // static | 37 // static |
| 38 void RendererWindowTreeClient::Destroy(int routing_id) { | 38 void RendererWindowTreeClient::Destroy(int routing_id) { |
| 39 auto* client = Get(routing_id); | 39 auto* client = Get(routing_id); |
| 40 if (client) | 40 if (client) |
| 41 client->DestroySelf(); | 41 client->DestroySelf(); |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 bool success) {} | 224 bool success) {} |
| 225 | 225 |
| 226 void RendererWindowTreeClient::RequestClose(uint32_t window_id) {} | 226 void RendererWindowTreeClient::RequestClose(uint32_t window_id) {} |
| 227 | 227 |
| 228 void RendererWindowTreeClient::GetWindowManager( | 228 void RendererWindowTreeClient::GetWindowManager( |
| 229 mojo::AssociatedInterfaceRequest<ui::mojom::WindowManager> internal) { | 229 mojo::AssociatedInterfaceRequest<ui::mojom::WindowManager> internal) { |
| 230 NOTREACHED(); | 230 NOTREACHED(); |
| 231 } | 231 } |
| 232 | 232 |
| 233 } // namespace content | 233 } // namespace content |
| OLD | NEW |