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

Side by Side Diff: services/ui/ws/threaded_image_cursors.h

Issue 2916823002: Move Mus into chrome's process when running with --mus.
Patch Set: Removing debug include. Created 3 years, 5 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 | « services/ui/ws/test_utils.cc ('k') | services/ui/ws/threaded_image_cursors.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 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 SERVICES_UI_WS_THREADED_IMAGE_CURSORS_H_
6 #define SERVICES_UI_WS_THREADED_IMAGE_CURSORS_H_
7
8 #include "base/memory/weak_ptr.h"
9 #include "ui/base/cursor/cursor.h"
10
11 namespace base {
12 class SingleThreadTaskRunner;
13 }
14
15 namespace display {
16 class Display;
17 }
18
19 namespace ui {
20 class ImageCursors;
21 class ImageCursorsSet;
22 class PlatformWindow;
23
24 namespace ws {
25
26 // Wrapper around ui::ImageCursors, capable of executing its methods
27 // asynchronously via the provided task runner.
28 class ThreadedImageCursors {
29 public:
30 // |resource_runner| is the task runner for the thread which can be used to
31 // load resources; |image_cursors_set_weak_ptr_| points to an object that
32 // lives on |resource_runner|'s thread.
33 // We create an ImageCursors object here and then pass the ownership to
34 // |image_cursors_set_weak_ptr_|. All operations on the ImageCursors object
35 // happen on |resource_runner|, which is why we need the owner to live on
36 // |resource_runner|'s thread.
37 ThreadedImageCursors(
38 scoped_refptr<base::SingleThreadTaskRunner>& resource_task_runner,
39 base::WeakPtr<ui::ImageCursorsSet> image_cursors_set_weak_ptr_);
40 ~ThreadedImageCursors();
41
42 // Executes ui::ImageCursors::SetDisplay asynchronously.
43 // Sets the display the cursors are loaded for. |scale_factor| determines the
44 // size of the image to load. Returns true if the cursor image is reloaded.
45 void SetDisplay(const display::Display& display, float scale_factor);
46
47 // Asynchronously sets the size of the mouse cursor icon.
48 void SetCursorSize(CursorSize cursor_size);
49
50 // Asynchronously sets the cursor type and then sets the corresponding
51 // PlatformCursor on the provided |platform_window|.
52 // |platform_window| pointer needs to be valid while this object is alive.
53 void SetCursor(ui::CursorType cursor_type,
54 ui::PlatformWindow* platform_window);
55
56 // Helper method. Sets |platform_cursor| on the |platform_window|.
57 void SetCursorOnPlatformWindow(ui::PlatformCursor platform_cursor,
58 ui::PlatformWindow* platform_window);
59
60 private:
61 // The object used for performing the actual cursor operations.
62 // Created on UI Service's thread, but is used on the
63 // |resource_task_runner_|'s thread, because it needs to load resources.
64 base::WeakPtr<ui::ImageCursors> image_cursors_weak_ptr_;
65
66 // Task runner for the thread which owns the cursor resources.
67 // |image_cursors_set_weak_ptr__| and |image_cursors_weak_ptr_| should only
68 // be dereferenced on this task runner.
69 scoped_refptr<base::SingleThreadTaskRunner> resource_task_runner_;
70
71 // Task runner of the UI Service thread (where this object is created and
72 // destroyed).
73 scoped_refptr<base::SingleThreadTaskRunner> ui_service_task_runner_;
74
75 // Lives on |resource_runner_|'s thread, used to own the object behid
76 // |image_cursors_weak_ptr_|.
77 base::WeakPtr<ui::ImageCursorsSet> image_cursors_set_weak_ptr_;
78
79 base::WeakPtrFactory<ThreadedImageCursors> weak_ptr_factory_;
80
81 DISALLOW_COPY_AND_ASSIGN(ThreadedImageCursors);
82 };
83
84 } // namespace ws
85 } // namespace ui
86
87 #endif // SERVICES_UI_WS_THREADED_IMAGE_CURSORS_H_
OLDNEW
« no previous file with comments | « services/ui/ws/test_utils.cc ('k') | services/ui/ws/threaded_image_cursors.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698