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

Side by Side Diff: components/mus/ws/window_server.cc

Issue 1906623003: Convert //components/mus from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 | « components/mus/ws/window_server.h ('k') | components/mus/ws/window_server_delegate.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/mus/ws/window_server.h" 5 #include "components/mus/ws/window_server.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/ptr_util.h"
8 #include "base/stl_util.h" 9 #include "base/stl_util.h"
9 #include "components/mus/ws/display.h" 10 #include "components/mus/ws/display.h"
10 #include "components/mus/ws/display_binding.h" 11 #include "components/mus/ws/display_binding.h"
11 #include "components/mus/ws/display_manager.h" 12 #include "components/mus/ws/display_manager.h"
12 #include "components/mus/ws/operation.h" 13 #include "components/mus/ws/operation.h"
13 #include "components/mus/ws/server_window.h" 14 #include "components/mus/ws/server_window.h"
14 #include "components/mus/ws/window_coordinate_conversions.h" 15 #include "components/mus/ws/window_coordinate_conversions.h"
15 #include "components/mus/ws/window_manager_access_policy.h" 16 #include "components/mus/ws/window_manager_access_policy.h"
16 #include "components/mus/ws/window_manager_factory_service.h" 17 #include "components/mus/ws/window_manager_factory_service.h"
17 #include "components/mus/ws/window_manager_state.h" 18 #include "components/mus/ws/window_manager_state.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 ConnectionSpecificId WindowServer::GetAndAdvanceNextConnectionId() { 65 ConnectionSpecificId WindowServer::GetAndAdvanceNextConnectionId() {
65 const ConnectionSpecificId id = next_connection_id_++; 66 const ConnectionSpecificId id = next_connection_id_++;
66 DCHECK_LT(id, next_connection_id_); 67 DCHECK_LT(id, next_connection_id_);
67 return id; 68 return id;
68 } 69 }
69 70
70 WindowTree* WindowServer::EmbedAtWindow( 71 WindowTree* WindowServer::EmbedAtWindow(
71 ServerWindow* root, 72 ServerWindow* root,
72 const UserId& user_id, 73 const UserId& user_id,
73 mojom::WindowTreeClientPtr client, 74 mojom::WindowTreeClientPtr client,
74 scoped_ptr<AccessPolicy> access_policy) { 75 std::unique_ptr<AccessPolicy> access_policy) {
75 scoped_ptr<WindowTree> tree_ptr( 76 std::unique_ptr<WindowTree> tree_ptr(
76 new WindowTree(this, user_id, root, std::move(access_policy))); 77 new WindowTree(this, user_id, root, std::move(access_policy)));
77 WindowTree* tree = tree_ptr.get(); 78 WindowTree* tree = tree_ptr.get();
78 79
79 mojom::WindowTreePtr window_tree_ptr; 80 mojom::WindowTreePtr window_tree_ptr;
80 mojom::WindowTreeRequest window_tree_request = GetProxy(&window_tree_ptr); 81 mojom::WindowTreeRequest window_tree_request = GetProxy(&window_tree_ptr);
81 scoped_ptr<WindowTreeBinding> binding = delegate_->CreateWindowTreeBinding( 82 std::unique_ptr<WindowTreeBinding> binding =
82 WindowServerDelegate::BindingType::EMBED, this, tree, 83 delegate_->CreateWindowTreeBinding(
83 &window_tree_request, &client); 84 WindowServerDelegate::BindingType::EMBED, this, tree,
85 &window_tree_request, &client);
84 if (!binding) { 86 if (!binding) {
85 binding.reset(new ws::DefaultWindowTreeBinding( 87 binding.reset(new ws::DefaultWindowTreeBinding(
86 tree, this, std::move(window_tree_request), std::move(client))); 88 tree, this, std::move(window_tree_request), std::move(client)));
87 } 89 }
88 90
89 AddTree(std::move(tree_ptr), std::move(binding), std::move(window_tree_ptr)); 91 AddTree(std::move(tree_ptr), std::move(binding), std::move(window_tree_ptr));
90 OnTreeMessagedClient(tree->id()); 92 OnTreeMessagedClient(tree->id());
91 return tree; 93 return tree;
92 } 94 }
93 95
94 WindowTree* WindowServer::AddTree(scoped_ptr<WindowTree> tree_impl_ptr, 96 WindowTree* WindowServer::AddTree(std::unique_ptr<WindowTree> tree_impl_ptr,
95 scoped_ptr<WindowTreeBinding> binding, 97 std::unique_ptr<WindowTreeBinding> binding,
96 mojom::WindowTreePtr tree_ptr) { 98 mojom::WindowTreePtr tree_ptr) {
97 CHECK_EQ(0u, tree_map_.count(tree_impl_ptr->id())); 99 CHECK_EQ(0u, tree_map_.count(tree_impl_ptr->id()));
98 WindowTree* tree = tree_impl_ptr.get(); 100 WindowTree* tree = tree_impl_ptr.get();
99 tree_map_[tree->id()] = std::move(tree_impl_ptr); 101 tree_map_[tree->id()] = std::move(tree_impl_ptr);
100 tree->Init(std::move(binding), std::move(tree_ptr)); 102 tree->Init(std::move(binding), std::move(tree_ptr));
101 return tree; 103 return tree;
102 } 104 }
103 105
104 WindowTree* WindowServer::CreateTreeForWindowManager( 106 WindowTree* WindowServer::CreateTreeForWindowManager(
105 Display* display, 107 Display* display,
106 mojom::WindowManagerFactory* factory, 108 mojom::WindowManagerFactory* factory,
107 ServerWindow* root, 109 ServerWindow* root,
108 const UserId& user_id) { 110 const UserId& user_id) {
109 mojom::DisplayPtr display_ptr = display->ToMojomDisplay(); 111 mojom::DisplayPtr display_ptr = display->ToMojomDisplay();
110 mojom::WindowTreeClientPtr tree_client; 112 mojom::WindowTreeClientPtr tree_client;
111 factory->CreateWindowManager(std::move(display_ptr), GetProxy(&tree_client)); 113 factory->CreateWindowManager(std::move(display_ptr), GetProxy(&tree_client));
112 scoped_ptr<WindowTree> tree_ptr(new WindowTree( 114 std::unique_ptr<WindowTree> tree_ptr(new WindowTree(
113 this, user_id, root, make_scoped_ptr(new WindowManagerAccessPolicy))); 115 this, user_id, root, base::WrapUnique(new WindowManagerAccessPolicy)));
114 WindowTree* tree = tree_ptr.get(); 116 WindowTree* tree = tree_ptr.get();
115 mojom::WindowTreePtr window_tree_ptr; 117 mojom::WindowTreePtr window_tree_ptr;
116 mojom::WindowTreeRequest tree_request; 118 mojom::WindowTreeRequest tree_request;
117 scoped_ptr<WindowTreeBinding> binding = delegate_->CreateWindowTreeBinding( 119 std::unique_ptr<WindowTreeBinding> binding =
118 WindowServerDelegate::BindingType::WINDOW_MANAGER, this, tree, 120 delegate_->CreateWindowTreeBinding(
119 &tree_request, &tree_client); 121 WindowServerDelegate::BindingType::WINDOW_MANAGER, this, tree,
122 &tree_request, &tree_client);
120 if (!binding) { 123 if (!binding) {
121 DefaultWindowTreeBinding* default_binding = new DefaultWindowTreeBinding( 124 DefaultWindowTreeBinding* default_binding = new DefaultWindowTreeBinding(
122 tree_ptr.get(), this, std::move(tree_client)); 125 tree_ptr.get(), this, std::move(tree_client));
123 binding.reset(default_binding); 126 binding.reset(default_binding);
124 window_tree_ptr = default_binding->CreateInterfacePtrAndBind(); 127 window_tree_ptr = default_binding->CreateInterfacePtrAndBind();
125 } 128 }
126 AddTree(std::move(tree_ptr), std::move(binding), std::move(window_tree_ptr)); 129 AddTree(std::move(tree_ptr), std::move(binding), std::move(window_tree_ptr));
127 tree->ConfigureWindowManager(); 130 tree->ConfigureWindowManager();
128 return tree; 131 return tree;
129 } 132 }
130 133
131 void WindowServer::DestroyTree(WindowTree* tree) { 134 void WindowServer::DestroyTree(WindowTree* tree) {
132 scoped_ptr<WindowTree> tree_ptr; 135 std::unique_ptr<WindowTree> tree_ptr;
133 { 136 {
134 auto iter = tree_map_.find(tree->id()); 137 auto iter = tree_map_.find(tree->id());
135 DCHECK(iter != tree_map_.end()); 138 DCHECK(iter != tree_map_.end());
136 tree_ptr = std::move(iter->second); 139 tree_ptr = std::move(iter->second);
137 tree_map_.erase(iter); 140 tree_map_.erase(iter);
138 } 141 }
139 142
140 // Notify remaining connections so that they can cleanup. 143 // Notify remaining connections so that they can cleanup.
141 for (auto& pair : tree_map_) 144 for (auto& pair : tree_map_)
142 pair.second->OnWindowDestroyingTreeImpl(tree); 145 pair.second->OnWindowDestroyingTreeImpl(tree);
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 void WindowServer::OnFirstDisplayReady() { 670 void WindowServer::OnFirstDisplayReady() {
668 delegate_->OnFirstDisplayReady(); 671 delegate_->OnFirstDisplayReady();
669 } 672 }
670 673
671 void WindowServer::OnNoMoreDisplays() { 674 void WindowServer::OnNoMoreDisplays() {
672 delegate_->OnNoMoreDisplays(); 675 delegate_->OnNoMoreDisplays();
673 } 676 }
674 677
675 } // namespace ws 678 } // namespace ws
676 } // namespace mus 679 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/ws/window_server.h ('k') | components/mus/ws/window_server_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698