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

Side by Side Diff: ui/views/mus/surface_binding.cc

Issue 1995613003: views/mus: Fix some flaky crashes during test teardown. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@views-mus-more-focus-fix
Patch Set: Created 4 years, 7 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
« no previous file with comments | « no previous file | ui/views/mus/surface_context_factory.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "ui/views/mus/surface_binding.h" 5 #include "ui/views/mus/surface_binding.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <map> 9 #include <map>
10 #include <utility> 10 #include <utility>
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 (*window_map)[connection] = new PerConnectionState(connector, connection); 91 (*window_map)[connection] = new PerConnectionState(connector, connection);
92 (*window_map)[connection]->Init(); 92 (*window_map)[connection]->Init();
93 } 93 }
94 return (*window_map)[connection]; 94 return (*window_map)[connection];
95 } 95 }
96 96
97 std::unique_ptr<cc::OutputSurface> 97 std::unique_ptr<cc::OutputSurface>
98 SurfaceBinding::PerConnectionState::CreateOutputSurface( 98 SurfaceBinding::PerConnectionState::CreateOutputSurface(
99 mus::Window* window, 99 mus::Window* window,
100 mus::mojom::SurfaceType surface_type) { 100 mus::mojom::SurfaceType surface_type) {
101 if (gpu_.encountered_error())
102 return nullptr;
101 // TODO(sky): figure out lifetime here. Do I need to worry about the return 103 // TODO(sky): figure out lifetime here. Do I need to worry about the return
102 // value outliving this? 104 // value outliving this?
103 mus::mojom::CommandBufferPtr cb; 105 mus::mojom::CommandBufferPtr cb;
104 gpu_->CreateOffscreenGLES2Context(GetProxy(&cb)); 106 gpu_->CreateOffscreenGLES2Context(GetProxy(&cb));
105 107
106 scoped_refptr<cc::ContextProvider> context_provider( 108 scoped_refptr<cc::ContextProvider> context_provider(
107 new mus::ContextProvider(cb.PassInterface().PassHandle())); 109 new mus::ContextProvider(cb.PassInterface().PassHandle()));
108 return base::WrapUnique(new mus::OutputSurface( 110 return base::WrapUnique(new mus::OutputSurface(
109 context_provider, window->RequestSurface(surface_type))); 111 context_provider, window->RequestSurface(surface_type)));
110 } 112 }
111 113
112 SurfaceBinding::PerConnectionState::PerConnectionState( 114 SurfaceBinding::PerConnectionState::PerConnectionState(
113 shell::Connector* connector, 115 shell::Connector* connector,
114 mus::WindowTreeConnection* connection) 116 mus::WindowTreeConnection* connection)
115 : connector_(connector), connection_(connection) {} 117 : connector_(connector), connection_(connection) {}
116 118
117 SurfaceBinding::PerConnectionState::~PerConnectionState() { 119 SurfaceBinding::PerConnectionState::~PerConnectionState() {
118 ConnectionToStateMap* window_map = window_states.Pointer()->Get(); 120 ConnectionToStateMap* window_map = window_states.Pointer()->Get();
119 DCHECK(window_map); 121 DCHECK(window_map);
120 DCHECK_EQ(this, (*window_map)[connection_]); 122 DCHECK_EQ(this, (*window_map)[connection_]);
121 window_map->erase(connection_); 123 window_map->erase(connection_);
122 if (window_map->empty()) { 124 if (window_map->empty()) {
123 delete window_map; 125 delete window_map;
124 window_states.Pointer()->Set(nullptr); 126 window_states.Pointer()->Set(nullptr);
125 } 127 }
126 } 128 }
127 129
128 void SurfaceBinding::PerConnectionState::Init() { 130 void SurfaceBinding::PerConnectionState::Init() {
129 connector_->ConnectToInterface("mojo:mus", &gpu_); 131 connector_->ConnectToInterface("mojo:mus", &gpu_);
132 gpu_.set_connection_error_handler([]{});
sadrul 2016/05/18 20:00:19 rockot@: This seems to be necessary for the change
sky 2016/05/18 20:10:32 This seems like a bug in the bindings code.
Ken Rockot(use gerrit already) 2016/05/18 20:11:08 Because we lazily set up the internal proxy in Int
sadrul 2016/05/19 20:14:17 OK. Sounds like this is not entirely unexpected, t
sky 2016/05/19 20:59:42 Yes, go for it.
130 } 133 }
131 134
132 // SurfaceBinding -------------------------------------------------------------- 135 // SurfaceBinding --------------------------------------------------------------
133 136
134 SurfaceBinding::SurfaceBinding(shell::Connector* connector, 137 SurfaceBinding::SurfaceBinding(shell::Connector* connector,
135 mus::Window* window, 138 mus::Window* window,
136 mus::mojom::SurfaceType surface_type) 139 mus::mojom::SurfaceType surface_type)
137 : window_(window), 140 : window_(window),
138 surface_type_(surface_type), 141 surface_type_(surface_type),
139 state_(PerConnectionState::Get(connector, window->connection())) {} 142 state_(PerConnectionState::Get(connector, window->connection())) {}
140 143
141 SurfaceBinding::~SurfaceBinding() {} 144 SurfaceBinding::~SurfaceBinding() {}
142 145
143 std::unique_ptr<cc::OutputSurface> SurfaceBinding::CreateOutputSurface() { 146 std::unique_ptr<cc::OutputSurface> SurfaceBinding::CreateOutputSurface() {
144 return state_->CreateOutputSurface(window_, surface_type_); 147 return state_->CreateOutputSurface(window_, surface_type_);
145 } 148 }
146 149
147 } // namespace views 150 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | ui/views/mus/surface_context_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698