OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef MOJO_UI_ASSOCIATES_VIEW_INSPECTOR_CLIENT_H_ |
| 6 #define MOJO_UI_ASSOCIATES_VIEW_INSPECTOR_CLIENT_H_ |
| 7 |
| 8 #include <queue> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/callback.h" |
| 12 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" |
| 14 #include "mojo/services/ui/views/interfaces/view_associates.mojom.h" |
| 15 #include "mojo/ui/associates/resolved_hits.h" |
| 16 |
| 17 namespace mojo { |
| 18 namespace ui { |
| 19 |
| 20 // Provides facilities for using a |ViewInspector|, including caching. |
| 21 class ViewInspectorClient : public base::RefCounted<ViewInspectorClient> { |
| 22 public: |
| 23 ViewInspectorClient(mojo::ui::ViewInspectorPtr view_inspector); |
| 24 |
| 25 mojo::ui::ViewInspector* view_inspector() { return view_inspector_.get(); } |
| 26 |
| 27 // Resolves all of the scene tokens referenced in the hit test result |
| 28 // then invokes the callback. |
| 29 // Note: May invoke the callback immediately if no remote calls were required. |
| 30 void ResolveHits(mojo::gfx::composition::HitTestResultPtr hit_test_result, |
| 31 const ResolvedHitsCallback& callback); |
| 32 |
| 33 private: |
| 34 friend class base::RefCounted<ViewInspectorClient>; |
| 35 ~ViewInspectorClient(); |
| 36 |
| 37 void ResolveSceneHit( |
| 38 const mojo::gfx::composition::SceneHit* scene_hit, |
| 39 ResolvedHits* resolved_hits, |
| 40 mojo::Array<mojo::gfx::composition::SceneTokenPtr>* missing_scene_tokens); |
| 41 void OnScenesResolved(scoped_ptr<ResolvedHits> resolved_hits, |
| 42 mojo::Array<uint32_t> missing_scene_token_values, |
| 43 const ResolvedHitsCallback& callback, |
| 44 mojo::Array<mojo::ui::ViewTokenPtr> view_tokens); |
| 45 |
| 46 mojo::ui::ViewInspectorPtr view_inspector_; |
| 47 |
| 48 // TODO(jeffbrown): Decide how this should be pruned. |
| 49 SceneTokenValueToViewTokenMap resolved_scene_cache_; |
| 50 |
| 51 std::queue<ResolvedHitsCallback> resolutions_; |
| 52 |
| 53 DISALLOW_COPY_AND_ASSIGN(ViewInspectorClient); |
| 54 }; |
| 55 |
| 56 } // namespace ui |
| 57 } // namespace mojo |
| 58 |
| 59 #endif // MOJO_UI_ASSOCIATES_VIEW_INSPECTOR_CLIENT_H_ |
OLD | NEW |