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

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

Issue 2040453002: views/mus: Create the BitmapUploader only when needed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 6 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
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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 72
73 // static 73 // static
74 base::LazyInstance<base::ThreadLocalPointer< 74 base::LazyInstance<base::ThreadLocalPointer<
75 SurfaceBinding::PerClientState::ClientToStateMap>>::Leaky 75 SurfaceBinding::PerClientState::ClientToStateMap>>::Leaky
76 SurfaceBinding::PerClientState::window_states; 76 SurfaceBinding::PerClientState::window_states;
77 77
78 // static 78 // static
79 SurfaceBinding::PerClientState* SurfaceBinding::PerClientState::Get( 79 SurfaceBinding::PerClientState* SurfaceBinding::PerClientState::Get(
80 shell::Connector* connector, 80 shell::Connector* connector,
81 mus::WindowTreeClient* client) { 81 mus::WindowTreeClient* client) {
82 // |connector| can be null in some unit-tests.
83 if (!connector)
84 return nullptr;
82 ClientToStateMap* window_map = window_states.Pointer()->Get(); 85 ClientToStateMap* window_map = window_states.Pointer()->Get();
83 if (!window_map) { 86 if (!window_map) {
84 window_map = new ClientToStateMap; 87 window_map = new ClientToStateMap;
85 window_states.Pointer()->Set(window_map); 88 window_states.Pointer()->Set(window_map);
86 } 89 }
87 if (!(*window_map)[client]) { 90 if (!(*window_map)[client]) {
88 (*window_map)[client] = new PerClientState(connector, client); 91 (*window_map)[client] = new PerClientState(connector, client);
89 (*window_map)[client]->Init(); 92 (*window_map)[client]->Init();
90 } 93 }
91 return (*window_map)[client]; 94 return (*window_map)[client];
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 SurfaceBinding::SurfaceBinding(shell::Connector* connector, 142 SurfaceBinding::SurfaceBinding(shell::Connector* connector,
140 mus::Window* window, 143 mus::Window* window,
141 mus::mojom::SurfaceType surface_type) 144 mus::mojom::SurfaceType surface_type)
142 : window_(window), 145 : window_(window),
143 surface_type_(surface_type), 146 surface_type_(surface_type),
144 state_(PerClientState::Get(connector, window->window_tree())) {} 147 state_(PerClientState::Get(connector, window->window_tree())) {}
145 148
146 SurfaceBinding::~SurfaceBinding() {} 149 SurfaceBinding::~SurfaceBinding() {}
147 150
148 std::unique_ptr<cc::OutputSurface> SurfaceBinding::CreateOutputSurface() { 151 std::unique_ptr<cc::OutputSurface> SurfaceBinding::CreateOutputSurface() {
149 return state_->CreateOutputSurface(window_, surface_type_); 152 return state_ ? state_->CreateOutputSurface(window_, surface_type_) : nullptr;
150 } 153 }
151 154
152 } // namespace views 155 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698