OLD | NEW |
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 "mojo/services/view_manager/public/cpp/view.h" | 5 #include "mojo/services/view_manager/public/cpp/view.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "mojo/services/view_manager/public/cpp/lib/view_private.h" | 9 #include "mojo/services/view_manager/public/cpp/lib/view_private.h" |
10 #include "mojo/services/view_manager/public/cpp/util.h" | 10 #include "mojo/services/view_manager/public/cpp/util.h" |
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
735 } | 735 } |
736 } | 736 } |
737 | 737 |
738 namespace { | 738 namespace { |
739 | 739 |
740 class SharedPropertyChangeObserver : public ViewObserver { | 740 class SharedPropertyChangeObserver : public ViewObserver { |
741 public: | 741 public: |
742 explicit SharedPropertyChangeObserver(View* view) : view_(view) { | 742 explicit SharedPropertyChangeObserver(View* view) : view_(view) { |
743 view_->AddObserver(this); | 743 view_->AddObserver(this); |
744 } | 744 } |
745 virtual ~SharedPropertyChangeObserver() { view_->RemoveObserver(this); } | 745 ~SharedPropertyChangeObserver() override { view_->RemoveObserver(this); } |
746 | 746 |
747 Changes GetAndClearChanges() { | 747 Changes GetAndClearChanges() { |
748 Changes changes; | 748 Changes changes; |
749 changes.swap(changes_); | 749 changes.swap(changes_); |
750 return changes; | 750 return changes; |
751 } | 751 } |
752 | 752 |
753 private: | 753 private: |
754 // Overridden from ViewObserver: | 754 // Overridden from ViewObserver: |
755 void OnViewSharedPropertyChanged( | 755 void OnViewSharedPropertyChanged( |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 typedef std::pair<const void*, intptr_t> PropertyChangeInfo; | 828 typedef std::pair<const void*, intptr_t> PropertyChangeInfo; |
829 | 829 |
830 class LocalPropertyChangeObserver : public ViewObserver { | 830 class LocalPropertyChangeObserver : public ViewObserver { |
831 public: | 831 public: |
832 explicit LocalPropertyChangeObserver(View* view) | 832 explicit LocalPropertyChangeObserver(View* view) |
833 : view_(view), | 833 : view_(view), |
834 property_key_(nullptr), | 834 property_key_(nullptr), |
835 old_property_value_(-1) { | 835 old_property_value_(-1) { |
836 view_->AddObserver(this); | 836 view_->AddObserver(this); |
837 } | 837 } |
838 virtual ~LocalPropertyChangeObserver() { view_->RemoveObserver(this); } | 838 ~LocalPropertyChangeObserver() override { view_->RemoveObserver(this); } |
839 | 839 |
840 PropertyChangeInfo PropertyChangeInfoAndClear() { | 840 PropertyChangeInfo PropertyChangeInfoAndClear() { |
841 PropertyChangeInfo result(property_key_, old_property_value_); | 841 PropertyChangeInfo result(property_key_, old_property_value_); |
842 property_key_ = NULL; | 842 property_key_ = NULL; |
843 old_property_value_ = -3; | 843 old_property_value_ = -3; |
844 return result; | 844 return result; |
845 } | 845 } |
846 | 846 |
847 private: | 847 private: |
848 void OnViewLocalPropertyChanged(View* window, | 848 void OnViewLocalPropertyChanged(View* window, |
(...skipping 26 matching lines...) Expand all Loading... |
875 EXPECT_EQ(PropertyChangeInfo(&prop, -2), o.PropertyChangeInfoAndClear()); | 875 EXPECT_EQ(PropertyChangeInfo(&prop, -2), o.PropertyChangeInfoAndClear()); |
876 v1.ClearLocalProperty(&prop); | 876 v1.ClearLocalProperty(&prop); |
877 EXPECT_EQ(PropertyChangeInfo(&prop, 3), o.PropertyChangeInfoAndClear()); | 877 EXPECT_EQ(PropertyChangeInfo(&prop, 3), o.PropertyChangeInfoAndClear()); |
878 | 878 |
879 // Sanity check to see if |PropertyChangeInfoAndClear| really clears. | 879 // Sanity check to see if |PropertyChangeInfoAndClear| really clears. |
880 EXPECT_EQ(PropertyChangeInfo( | 880 EXPECT_EQ(PropertyChangeInfo( |
881 reinterpret_cast<const void*>(NULL), -3), o.PropertyChangeInfoAndClear()); | 881 reinterpret_cast<const void*>(NULL), -3), o.PropertyChangeInfoAndClear()); |
882 } | 882 } |
883 | 883 |
884 } // namespace mojo | 884 } // namespace mojo |
OLD | NEW |