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

Side by Side Diff: components/view_manager/display_manager.cc

Issue 1229553002: Mandoline: ConnectToApplication and ConnectToService should fail gracefully (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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 | mojo/application/public/cpp/application_impl.h » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/view_manager/display_manager.h" 5 #include "components/view_manager/display_manager.h"
6 6
7 #include "base/numerics/safe_conversions.h" 7 #include "base/numerics/safe_conversions.h"
8 #include "components/view_manager/display_manager_factory.h" 8 #include "components/view_manager/display_manager_factory.h"
9 #include "components/view_manager/gles2/gpu_state.h" 9 #include "components/view_manager/gles2/gpu_state.h"
10 #include "components/view_manager/native_viewport/onscreen_context_provider.h" 10 #include "components/view_manager/native_viewport/onscreen_context_provider.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 native_viewport::PlatformViewport::Create(this, is_headless_).Pass(); 112 native_viewport::PlatformViewport::Create(this, is_headless_).Pass();
113 platform_viewport_->Init(gfx::Rect(metrics_.size_in_pixels.To<gfx::Size>())); 113 platform_viewport_->Init(gfx::Rect(metrics_.size_in_pixels.To<gfx::Size>()));
114 platform_viewport_->Show(); 114 platform_viewport_->Show();
115 115
116 mojo::ContextProviderPtr context_provider; 116 mojo::ContextProviderPtr context_provider;
117 context_provider_->Bind(GetProxy(&context_provider).Pass()); 117 context_provider_->Bind(GetProxy(&context_provider).Pass());
118 mojo::DisplayFactoryPtr display_factory; 118 mojo::DisplayFactoryPtr display_factory;
119 mojo::URLRequestPtr request(mojo::URLRequest::New()); 119 mojo::URLRequestPtr request(mojo::URLRequest::New());
120 request->url = mojo::String::From("mojo:surfaces_service"); 120 request->url = mojo::String::From("mojo:surfaces_service");
121 app_impl_->ConnectToService(request.Pass(), &display_factory); 121 app_impl_->ConnectToService(request.Pass(), &display_factory);
122 // TODO(fsamuel): We should indicate to the delegate that this object failed
123 // to initialize.
124 if (!display_factory)
125 return;
122 display_factory->Create(context_provider.Pass(), 126 display_factory->Create(context_provider.Pass(),
123 nullptr, // returner - we never submit resources. 127 nullptr, // returner - we never submit resources.
124 GetProxy(&display_)); 128 GetProxy(&display_));
125 } 129 }
126 130
127 DefaultDisplayManager::~DefaultDisplayManager() { 131 DefaultDisplayManager::~DefaultDisplayManager() {
128 // Destroy before |platform_viewport_| because this will destroy 132 // Destroy before |platform_viewport_| because this will destroy
129 // CommandBufferDriver objects that contain child windows. Otherwise if this 133 // CommandBufferDriver objects that contain child windows. Otherwise if this
130 // class destroys its window first, X errors will occur. 134 // class destroys its window first, X errors will occur.
131 context_provider_.reset(); 135 context_provider_.reset();
(...skipping 28 matching lines...) Expand all
160 gfx::Rect rect(metrics_.size_in_pixels.To<gfx::Size>()); 164 gfx::Rect rect(metrics_.size_in_pixels.To<gfx::Size>());
161 auto pass = mojo::CreateDefaultPass(1, rect); 165 auto pass = mojo::CreateDefaultPass(1, rect);
162 pass->damage_rect = Rect::From(dirty_rect_); 166 pass->damage_rect = Rect::From(dirty_rect_);
163 167
164 DrawViewTree(pass.get(), delegate_->GetRootView(), gfx::Vector2d(), 1.0f); 168 DrawViewTree(pass.get(), delegate_->GetRootView(), gfx::Vector2d(), 1.0f);
165 169
166 auto frame = mojo::Frame::New(); 170 auto frame = mojo::Frame::New();
167 frame->passes.push_back(pass.Pass()); 171 frame->passes.push_back(pass.Pass());
168 frame->resources.resize(0u); 172 frame->resources.resize(0u);
169 frame_pending_ = true; 173 frame_pending_ = true;
170 display_->SubmitFrame( 174 if (display_) {
171 frame.Pass(), 175 display_->SubmitFrame(
172 base::Bind(&DefaultDisplayManager::DidDraw, base::Unretained(this))); 176 frame.Pass(),
177 base::Bind(&DefaultDisplayManager::DidDraw, base::Unretained(this)));
178 }
173 dirty_rect_ = gfx::Rect(); 179 dirty_rect_ = gfx::Rect();
174 } 180 }
175 181
176 void DefaultDisplayManager::DidDraw() { 182 void DefaultDisplayManager::DidDraw() {
177 frame_pending_ = false; 183 frame_pending_ = false;
178 if (!dirty_rect_.IsEmpty()) 184 if (!dirty_rect_.IsEmpty())
179 WantToDraw(); 185 WantToDraw();
180 } 186 }
181 187
182 void DefaultDisplayManager::WantToDraw() { 188 void DefaultDisplayManager::WantToDraw() {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 225
220 metrics_.size_in_pixels = metrics.size_in_pixels.Clone(); 226 metrics_.size_in_pixels = metrics.size_in_pixels.Clone();
221 metrics_.device_pixel_ratio = metrics.device_pixel_ratio; 227 metrics_.device_pixel_ratio = metrics.device_pixel_ratio;
222 } 228 }
223 229
224 void DefaultDisplayManager::OnDestroyed() { 230 void DefaultDisplayManager::OnDestroyed() {
225 delegate_->OnDisplayClosed(); 231 delegate_->OnDisplayClosed();
226 } 232 }
227 233
228 } // namespace view_manager 234 } // namespace view_manager
OLDNEW
« no previous file with comments | « no previous file | mojo/application/public/cpp/application_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698