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

Side by Side Diff: components/mus/public/cpp/lib/window_tree_client_impl.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
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/public/cpp/lib/window_tree_client_impl.h" 5 #include "components/mus/public/cpp/lib/window_tree_client_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 if (pair.second->window() == change.window() && 448 if (pair.second->window() == change.window() &&
449 pair.second->change_type() == change.change_type() && 449 pair.second->change_type() == change.change_type() &&
450 pair.second->Matches(change)) { 450 pair.second->Matches(change)) {
451 return pair.second.get(); 451 return pair.second.get();
452 } 452 }
453 } 453 }
454 return nullptr; 454 return nullptr;
455 } 455 }
456 456
457 uint32_t WindowTreeClientImpl::ScheduleInFlightChange( 457 uint32_t WindowTreeClientImpl::ScheduleInFlightChange(
458 scoped_ptr<InFlightChange> change) { 458 std::unique_ptr<InFlightChange> change) {
459 DCHECK(!change->window() || 459 DCHECK(!change->window() ||
460 windows_.count(change->window()->server_id()) > 0); 460 windows_.count(change->window()->server_id()) > 0);
461 const uint32_t change_id = next_change_id_++; 461 const uint32_t change_id = next_change_id_++;
462 in_flight_map_[change_id] = std::move(change); 462 in_flight_map_[change_id] = std::move(change);
463 return change_id; 463 return change_id;
464 } 464 }
465 465
466 bool WindowTreeClientImpl::ApplyServerChangeToExistingInFlightChange( 466 bool WindowTreeClientImpl::ApplyServerChangeToExistingInFlightChange(
467 const InFlightChange& change) { 467 const InFlightChange& change) {
468 InFlightChange* existing_change = GetOldestInFlightChangeMatching(change); 468 InFlightChange* existing_change = GetOldestInFlightChangeMatching(change);
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 // of the window at the time the server created it. For properties we do not 636 // of the window at the time the server created it. For properties we do not
637 // have changes in flight for we can update them immediately. For properties 637 // have changes in flight for we can update them immediately. For properties
638 // with changes in flight we set the revert value from the server. 638 // with changes in flight we set the revert value from the server.
639 639
640 if (!in_flight_map_.count(change_id)) { 640 if (!in_flight_map_.count(change_id)) {
641 // The window may have been destroyed locally before the server could finish 641 // The window may have been destroyed locally before the server could finish
642 // creating the window, and before the server received the notification that 642 // creating the window, and before the server received the notification that
643 // the window has been destroyed. 643 // the window has been destroyed.
644 return; 644 return;
645 } 645 }
646 scoped_ptr<InFlightChange> change(std::move(in_flight_map_[change_id])); 646 std::unique_ptr<InFlightChange> change(std::move(in_flight_map_[change_id]));
647 in_flight_map_.erase(change_id); 647 in_flight_map_.erase(change_id);
648 648
649 Window* window = change->window(); 649 Window* window = change->window();
650 WindowPrivate window_private(window); 650 WindowPrivate window_private(window);
651 651
652 // Drawn state and ViewportMetrics always come from the server (they can't 652 // Drawn state and ViewportMetrics always come from the server (they can't
653 // be modified locally). 653 // be modified locally).
654 window_private.LocalSetParentDrawn(drawn); 654 window_private.LocalSetParentDrawn(drawn);
655 window_private.LocalSetViewportMetrics(mojom::ViewportMetrics(), 655 window_private.LocalSetViewportMetrics(mojom::ViewportMetrics(),
656 *data->viewport_metrics); 656 *data->viewport_metrics);
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 865
866 void WindowTreeClientImpl::OnWindowInputEvent(uint32_t event_id, 866 void WindowTreeClientImpl::OnWindowInputEvent(uint32_t event_id,
867 Id window_id, 867 Id window_id,
868 mojom::EventPtr event) { 868 mojom::EventPtr event) {
869 Window* window = GetWindowByServerId(window_id); 869 Window* window = GetWindowByServerId(window_id);
870 if (!window || !window->input_event_handler_) { 870 if (!window || !window->input_event_handler_) {
871 tree_->OnWindowInputEventAck(event_id, mojom::EventResult::UNHANDLED); 871 tree_->OnWindowInputEventAck(event_id, mojom::EventResult::UNHANDLED);
872 return; 872 return;
873 } 873 }
874 874
875 scoped_ptr<base::Callback<void(mojom::EventResult)>> ack_callback( 875 std::unique_ptr<base::Callback<void(mojom::EventResult)>> ack_callback(
876 new base::Callback<void(mojom::EventResult)>( 876 new base::Callback<void(mojom::EventResult)>(
877 base::Bind(&mojom::WindowTree::OnWindowInputEventAck, 877 base::Bind(&mojom::WindowTree::OnWindowInputEventAck,
878 base::Unretained(tree_), event_id))); 878 base::Unretained(tree_), event_id)));
879 window->input_event_handler_->OnWindowInputEvent( 879 window->input_event_handler_->OnWindowInputEvent(
880 window, *event.To<scoped_ptr<ui::Event>>().get(), &ack_callback); 880 window, *event.To<std::unique_ptr<ui::Event>>().get(), &ack_callback);
881 881
882 // The handler did not take ownership of the callback, so we send the ack, 882 // The handler did not take ownership of the callback, so we send the ack,
883 // marking the event as not consumed. 883 // marking the event as not consumed.
884 if (ack_callback) 884 if (ack_callback)
885 ack_callback->Run(mojom::EventResult::UNHANDLED); 885 ack_callback->Run(mojom::EventResult::UNHANDLED);
886 } 886 }
887 887
888 void WindowTreeClientImpl::OnWindowFocused(Id focused_window_id) { 888 void WindowTreeClientImpl::OnWindowFocused(Id focused_window_id) {
889 Window* focused_window = GetWindowByServerId(focused_window_id); 889 Window* focused_window = GetWindowByServerId(focused_window_id);
890 InFlightFocusChange new_change(this, focused_window); 890 InFlightFocusChange new_change(this, focused_window);
(...skipping 11 matching lines...) Expand all
902 return; 902 return;
903 903
904 InFlightPredefinedCursorChange new_change(window, cursor); 904 InFlightPredefinedCursorChange new_change(window, cursor);
905 if (ApplyServerChangeToExistingInFlightChange(new_change)) 905 if (ApplyServerChangeToExistingInFlightChange(new_change))
906 return; 906 return;
907 907
908 WindowPrivate(window).LocalSetPredefinedCursor(cursor); 908 WindowPrivate(window).LocalSetPredefinedCursor(cursor);
909 } 909 }
910 910
911 void WindowTreeClientImpl::OnChangeCompleted(uint32_t change_id, bool success) { 911 void WindowTreeClientImpl::OnChangeCompleted(uint32_t change_id, bool success) {
912 scoped_ptr<InFlightChange> change(std::move(in_flight_map_[change_id])); 912 std::unique_ptr<InFlightChange> change(std::move(in_flight_map_[change_id]));
913 in_flight_map_.erase(change_id); 913 in_flight_map_.erase(change_id);
914 if (!change) 914 if (!change)
915 return; 915 return;
916 916
917 if (!success) 917 if (!success)
918 change->ChangeFailed(); 918 change->ChangeFailed();
919 919
920 InFlightChange* next_change = GetOldestInFlightChangeMatching(*change); 920 InFlightChange* next_change = GetOldestInFlightChangeMatching(*change);
921 if (next_change) { 921 if (next_change) {
922 if (!success) 922 if (!success)
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
962 } 962 }
963 963
964 void WindowTreeClientImpl::WmSetProperty(uint32_t change_id, 964 void WindowTreeClientImpl::WmSetProperty(uint32_t change_id,
965 Id window_id, 965 Id window_id,
966 const mojo::String& name, 966 const mojo::String& name,
967 mojo::Array<uint8_t> transit_data) { 967 mojo::Array<uint8_t> transit_data) {
968 Window* window = GetWindowByServerId(window_id); 968 Window* window = GetWindowByServerId(window_id);
969 bool result = false; 969 bool result = false;
970 if (window) { 970 if (window) {
971 DCHECK(window_manager_delegate_); 971 DCHECK(window_manager_delegate_);
972 scoped_ptr<std::vector<uint8_t>> data; 972 std::unique_ptr<std::vector<uint8_t>> data;
973 if (!transit_data.is_null()) { 973 if (!transit_data.is_null()) {
974 data.reset( 974 data.reset(
975 new std::vector<uint8_t>(transit_data.To<std::vector<uint8_t>>())); 975 new std::vector<uint8_t>(transit_data.To<std::vector<uint8_t>>()));
976 } 976 }
977 result = window_manager_delegate_->OnWmSetProperty(window, name, &data); 977 result = window_manager_delegate_->OnWmSetProperty(window, name, &data);
978 if (result) { 978 if (result) {
979 // If the resulting bounds differ return false. Returning false ensures 979 // If the resulting bounds differ return false. Returning false ensures
980 // the client applies the bounds we set below. 980 // the client applies the bounds we set below.
981 window->SetSharedPropertyInternal(name, data.get()); 981 window->SetSharedPropertyInternal(name, data.get());
982 } 982 }
983 } 983 }
984 window_manager_internal_client_->WmResponse(change_id, result); 984 window_manager_internal_client_->WmResponse(change_id, result);
985 } 985 }
986 986
987 void WindowTreeClientImpl::WmCreateTopLevelWindow( 987 void WindowTreeClientImpl::WmCreateTopLevelWindow(
988 uint32_t change_id, 988 uint32_t change_id,
989 mojo::Map<mojo::String, mojo::Array<uint8_t>> transport_properties) { 989 mojo::Map<mojo::String, mojo::Array<uint8_t>> transport_properties) {
990 std::map<std::string, std::vector<uint8_t>> properties = 990 std::map<std::string, std::vector<uint8_t>> properties =
991 transport_properties.To<std::map<std::string, std::vector<uint8_t>>>(); 991 transport_properties.To<std::map<std::string, std::vector<uint8_t>>>();
992 Window* window = 992 Window* window =
993 window_manager_delegate_->OnWmCreateTopLevelWindow(&properties); 993 window_manager_delegate_->OnWmCreateTopLevelWindow(&properties);
994 window_manager_internal_client_->OnWmCreatedTopLevelWindow(change_id, 994 window_manager_internal_client_->OnWmCreatedTopLevelWindow(change_id,
995 server_id(window)); 995 server_id(window));
996 } 996 }
997 997
998 void WindowTreeClientImpl::OnAccelerator(uint32_t id, mojom::EventPtr event) { 998 void WindowTreeClientImpl::OnAccelerator(uint32_t id, mojom::EventPtr event) {
999 window_manager_delegate_->OnAccelerator( 999 window_manager_delegate_->OnAccelerator(
1000 id, *event.To<scoped_ptr<ui::Event>>().get()); 1000 id, *event.To<std::unique_ptr<ui::Event>>().get());
1001 } 1001 }
1002 1002
1003 void WindowTreeClientImpl::SetFrameDecorationValues( 1003 void WindowTreeClientImpl::SetFrameDecorationValues(
1004 mojom::FrameDecorationValuesPtr values) { 1004 mojom::FrameDecorationValuesPtr values) {
1005 window_manager_internal_client_->WmSetFrameDecorationValues( 1005 window_manager_internal_client_->WmSetFrameDecorationValues(
1006 std::move(values)); 1006 std::move(values));
1007 } 1007 }
1008 1008
1009 void WindowTreeClientImpl::AddAccelerator( 1009 void WindowTreeClientImpl::AddAccelerator(
1010 uint32_t id, 1010 uint32_t id,
(...skipping 21 matching lines...) Expand all
1032 1032
1033 void WindowTreeClientImpl::SetUnderlaySurfaceOffsetAndExtendedHitArea( 1033 void WindowTreeClientImpl::SetUnderlaySurfaceOffsetAndExtendedHitArea(
1034 Window* window, 1034 Window* window,
1035 const gfx::Vector2d& offset, 1035 const gfx::Vector2d& offset,
1036 const gfx::Insets& hit_area) { 1036 const gfx::Insets& hit_area) {
1037 window_manager_internal_client_->SetUnderlaySurfaceOffsetAndExtendedHitArea( 1037 window_manager_internal_client_->SetUnderlaySurfaceOffsetAndExtendedHitArea(
1038 server_id(window), offset.x(), offset.y(), mojo::Insets::From(hit_area)); 1038 server_id(window), offset.x(), offset.y(), mojo::Insets::From(hit_area));
1039 } 1039 }
1040 1040
1041 } // namespace mus 1041 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/public/cpp/lib/window_tree_client_impl.h ('k') | components/mus/public/cpp/output_surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698