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

Side by Side Diff: ui/display/chromeos/configure_displays_task.h

Issue 2540313002: Split //ui/display and create //ui/display/manager. (Closed)
Patch Set: Cleanup export header. Created 4 years 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef UI_DISPLAY_CHROMEOS_CONFIGURATION_TASK_H_
6 #define UI_DISPLAY_CHROMEOS_CONFIGURATION_TASK_H_
7
8 #include <stddef.h>
9
10 #include <queue>
11 #include <vector>
12
13 #include "base/callback.h"
14 #include "base/macros.h"
15 #include "base/memory/weak_ptr.h"
16 #include "ui/display/display_export.h"
17 #include "ui/gfx/geometry/point.h"
18
19 namespace ui {
20
21 class DisplayMode;
22 class DisplaySnapshot;
23 class NativeDisplayDelegate;
24
25 struct DISPLAY_EXPORT DisplayConfigureRequest {
26 DisplayConfigureRequest(DisplaySnapshot* display,
27 const DisplayMode* mode,
28 const gfx::Point& origin);
29
30 DisplaySnapshot* display;
31 const DisplayMode* mode;
32 gfx::Point origin;
33 };
34
35 // Applies the display configuration asynchronously.
36 class DISPLAY_EXPORT ConfigureDisplaysTask {
37 public:
38 enum Status {
39 // At least one of the displays failed to apply any mode it supports.
40 ERROR,
41
42 // The requested configuration was applied.
43 SUCCESS,
44
45 // At least one of the displays failed to apply the requested
46 // configuration, but it managed to fall back to another mode.
47 PARTIAL_SUCCESS,
48 };
49
50 typedef base::Callback<void(Status)> ResponseCallback;
51
52 ConfigureDisplaysTask(NativeDisplayDelegate* delegate,
53 const std::vector<DisplayConfigureRequest>& requests,
54 const ResponseCallback& callback);
55 ~ConfigureDisplaysTask();
56
57 // Starts the configuration task.
58 void Run();
59
60 private:
61 void OnConfigured(size_t index, bool success);
62
63 NativeDisplayDelegate* delegate_; // Not owned.
64
65 std::vector<DisplayConfigureRequest> requests_;
66
67 // When the task finishes executing it runs the callback to notify that the
68 // task is done and the task status.
69 ResponseCallback callback_;
70
71 // Stores the indexes of pending requests in |requests_|.
72 std::queue<size_t> pending_request_indexes_;
73
74 // Used to keep make sure that synchronous executions do not recurse during
75 // the configuration.
76 bool is_configuring_;
77
78 // Number of display configured. This is used to check whether there are
79 // pending requests.
80 size_t num_displays_configured_;
81
82 Status task_status_;
83
84 base::WeakPtrFactory<ConfigureDisplaysTask> weak_ptr_factory_;
85
86 DISALLOW_COPY_AND_ASSIGN(ConfigureDisplaysTask);
87 };
88
89 } // namespace ui
90
91 #endif // UI_DISPLAY_CHROMEOS_CONFIGURATION_TASK_H_
OLDNEW
« no previous file with comments | « ui/display/chromeos/apply_content_protection_task_unittest.cc ('k') | ui/display/chromeos/configure_displays_task.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698