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

Side by Side Diff: chrome/browser/chromeos/login/screens/update_screen.h

Issue 2684473002: Revert of Fold UpdateModel into UpdateScreen. (Closed)
Patch Set: Created 3 years, 10 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_UPDATE_SCREEN_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_UPDATE_SCREEN_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_UPDATE_SCREEN_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_UPDATE_SCREEN_H_
7 7
8 #include <set> 8 #include <set>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/gtest_prod_util.h" 12 #include "base/gtest_prod_util.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/time/time.h" 15 #include "base/time/time.h"
16 #include "base/timer/timer.h" 16 #include "base/timer/timer.h"
17 #include "chrome/browser/chromeos/login/screens/base_screen.h"
18 #include "chrome/browser/chromeos/login/screens/error_screen.h" 17 #include "chrome/browser/chromeos/login/screens/error_screen.h"
18 #include "chrome/browser/chromeos/login/screens/update_model.h"
19 #include "chromeos/dbus/update_engine_client.h" 19 #include "chromeos/dbus/update_engine_client.h"
20 #include "chromeos/network/portal_detector/network_portal_detector.h" 20 #include "chromeos/network/portal_detector/network_portal_detector.h"
21 #include "components/pairing/host_pairing_controller.h" 21 #include "components/pairing/host_pairing_controller.h"
22 22
23 namespace chromeos { 23 namespace chromeos {
24 24
25 class BaseScreenDelegate; 25 class BaseScreenDelegate;
26 class ErrorScreen; 26 class ErrorScreen;
27 class ErrorScreensHistogramHelper; 27 class ErrorScreensHistogramHelper;
28 class NetworkState; 28 class NetworkState;
29 class ScreenManager; 29 class ScreenManager;
30 class UpdateView; 30 class UpdateView;
31 31
32 // Controller for the update screen. 32 // Controller for the update screen.
33 class UpdateScreen : public BaseScreen, 33 class UpdateScreen : public UpdateModel,
34 public UpdateEngineClient::Observer, 34 public UpdateEngineClient::Observer,
35 public NetworkPortalDetector::Observer { 35 public NetworkPortalDetector::Observer {
36 public: 36 public:
37 static UpdateScreen* Get(ScreenManager* manager);
38
39 // Returns true if this instance is still active (i.e. has not been deleted).
40 static bool HasInstance(UpdateScreen* inst);
41
42 UpdateScreen(BaseScreenDelegate* base_screen_delegate, 37 UpdateScreen(BaseScreenDelegate* base_screen_delegate,
43 UpdateView* view, 38 UpdateView* view,
44 pairing_chromeos::HostPairingController* remora_controller); 39 pairing_chromeos::HostPairingController* remora_controller);
45 ~UpdateScreen() override; 40 ~UpdateScreen() override;
46 41
47 // Called when the being destroyed. This should call Unbind() on the 42 static UpdateScreen* Get(ScreenManager* manager);
48 // associated View if this class is destroyed before it. 43
49 void OnViewDestroyed(UpdateView* view); 44 // UpdateModel:
45 void Show() override;
46 void Hide() override;
47 void OnViewDestroyed(UpdateView* view) override;
48 void OnUserAction(const std::string& action_id) override;
49 void OnContextKeyUpdated(const ::login::ScreenContext::KeyType& key) override;
50 50
51 // Starts network check. Made virtual to simplify mocking. 51 // Starts network check. Made virtual to simplify mocking.
52 virtual void StartNetworkCheck(); 52 virtual void StartNetworkCheck();
53 53
54 // Returns true if this instance is still active (i.e. has not been deleted).
55 static bool HasInstance(UpdateScreen* inst);
56
54 void SetIgnoreIdleStatus(bool ignore_idle_status); 57 void SetIgnoreIdleStatus(bool ignore_idle_status);
55 58
56 enum ExitReason { 59 enum ExitReason {
57 REASON_UPDATE_CANCELED = 0, 60 REASON_UPDATE_CANCELED = 0,
58 REASON_UPDATE_INIT_FAILED, 61 REASON_UPDATE_INIT_FAILED,
59 REASON_UPDATE_NON_CRITICAL, 62 REASON_UPDATE_NON_CRITICAL,
60 REASON_UPDATE_ENDED 63 REASON_UPDATE_ENDED
61 }; 64 };
62 // Reports update results to the BaseScreenDelegate. 65 // Reports update results to the BaseScreenDelegate.
63 virtual void ExitUpdate(ExitReason reason); 66 virtual void ExitUpdate(ExitReason reason);
64 67
65 // UpdateEngineClient::Observer implementation: 68 // UpdateEngineClient::Observer implementation:
66 void UpdateStatusChanged(const UpdateEngineClient::Status& status) override; 69 void UpdateStatusChanged(const UpdateEngineClient::Status& status) override;
67 70
68 // NetworkPortalDetector::Observer implementation: 71 // NetworkPortalDetector::Observer implementation:
69 void OnPortalDetectionCompleted( 72 void OnPortalDetectionCompleted(
70 const NetworkState* network, 73 const NetworkState* network,
71 const NetworkPortalDetector::CaptivePortalState& state) override; 74 const NetworkPortalDetector::CaptivePortalState& state) override;
72 75
73 // Skip update UI, usually used only in debug builds/tests. 76 // Skip update UI, usually used only in debug builds/tests.
74 void CancelUpdate(); 77 void CancelUpdate();
75 78
76 base::OneShotTimer& GetErrorMessageTimerForTesting(); 79 base::OneShotTimer& GetErrorMessageTimerForTesting();
77 80
78 private: 81 private:
79 FRIEND_TEST_ALL_PREFIXES(UpdateScreenTest, TestBasic); 82 FRIEND_TEST_ALL_PREFIXES(UpdateScreenTest, TestBasic);
80 FRIEND_TEST_ALL_PREFIXES(UpdateScreenTest, TestUpdateAvailable); 83 FRIEND_TEST_ALL_PREFIXES(UpdateScreenTest, TestUpdateAvailable);
81 FRIEND_TEST_ALL_PREFIXES(UpdateScreenTest, TestAPReselection); 84 FRIEND_TEST_ALL_PREFIXES(UpdateScreenTest, TestAPReselection);
82 85
83 enum class State { 86 enum State {
84 STATE_IDLE = 0, 87 STATE_IDLE = 0,
85 STATE_FIRST_PORTAL_CHECK, 88 STATE_FIRST_PORTAL_CHECK,
86 STATE_UPDATE, 89 STATE_UPDATE,
87 STATE_ERROR 90 STATE_ERROR
88 }; 91 };
89 92
90 // BaseScreen:
91 void Show() override;
92 void Hide() override;
93 void OnUserAction(const std::string& action_id) override;
94
95 // Updates downloading stats (remaining time and downloading 93 // Updates downloading stats (remaining time and downloading
96 // progress) on the AU screen. 94 // progress) on the AU screen.
97 void UpdateDownloadingStats(const UpdateEngineClient::Status& status); 95 void UpdateDownloadingStats(const UpdateEngineClient::Status& status);
98 96
99 // Returns true if there is critical system update that requires installation 97 // Returns true if there is critical system update that requires installation
100 // and immediate reboot. 98 // and immediate reboot.
101 bool HasCriticalUpdate(); 99 bool HasCriticalUpdate();
102 100
103 // Timer notification handlers. 101 // Timer notification handlers.
104 void OnWaitForRebootTimeElapsed(); 102 void OnWaitForRebootTimeElapsed();
(...skipping 18 matching lines...) Expand all
123 void DelayErrorMessage(); 121 void DelayErrorMessage();
124 122
125 // The user requested an attempt to connect to the network should be made. 123 // The user requested an attempt to connect to the network should be made.
126 void OnConnectRequested(); 124 void OnConnectRequested();
127 125
128 // Timer for the interval to wait for the reboot. 126 // Timer for the interval to wait for the reboot.
129 // If reboot didn't happen - ask user to reboot manually. 127 // If reboot didn't happen - ask user to reboot manually.
130 base::OneShotTimer reboot_timer_; 128 base::OneShotTimer reboot_timer_;
131 129
132 // Returns a static InstanceSet. 130 // Returns a static InstanceSet.
133 // TODO(jdufault): There should only ever be one instance of this class.
134 // Remove support for supporting multiple instances. See crbug.com/672142.
135 typedef std::set<UpdateScreen*> InstanceSet; 131 typedef std::set<UpdateScreen*> InstanceSet;
136 static InstanceSet& GetInstanceSet(); 132 static InstanceSet& GetInstanceSet();
137 133
138 // Current state of the update screen. 134 // Current state of the update screen.
139 State state_ = State::STATE_IDLE; 135 State state_;
140 136
141 // Time in seconds after which we decide that the device has not rebooted 137 // Time in seconds after which we decide that the device has not rebooted
142 // automatically. If reboot didn't happen during this interval, ask user to 138 // automatically. If reboot didn't happen during this interval, ask user to
143 // reboot device manually. 139 // reboot device manually.
144 int reboot_check_delay_ = 0; 140 int reboot_check_delay_;
145 141
146 // True if in the process of checking for update. 142 // True if in the process of checking for update.
147 bool is_checking_for_update_ = true; 143 bool is_checking_for_update_;
148 // Flag that is used to detect when update download has just started. 144 // Flag that is used to detect when update download has just started.
149 bool is_downloading_update_ = false; 145 bool is_downloading_update_;
150 // If true, update deadlines are ignored. 146 // If true, update deadlines are ignored.
151 // Note, this is false by default. 147 // Note, this is false by default.
152 bool is_ignore_update_deadlines_ = false; 148 bool is_ignore_update_deadlines_;
153 // Whether the update screen is shown. 149 // Whether the update screen is shown.
154 bool is_shown_ = false; 150 bool is_shown_;
155 // Ignore fist IDLE status that is sent before update screen initiated check. 151 // Ignore fist IDLE status that is sent before update screen initiated check.
156 bool ignore_idle_status_ = true; 152 bool ignore_idle_status_;
157 153
158 UpdateView* view_ = nullptr; 154 UpdateView* view_;
159 155
160 // Used to track updates over Bluetooth. 156 // Used to track updates over Bluetooth.
161 pairing_chromeos::HostPairingController* remora_controller_; 157 pairing_chromeos::HostPairingController* remora_controller_;
162 158
163 // Time of the first notification from the downloading stage. 159 // Time of the first notification from the downloading stage.
164 base::Time download_start_time_; 160 base::Time download_start_time_;
165 double download_start_progress_ = 0; 161 double download_start_progress_;
166 162
167 // Time of the last notification from the downloading stage. 163 // Time of the last notification from the downloading stage.
168 base::Time download_last_time_; 164 base::Time download_last_time_;
169 double download_last_progress_ = 0; 165 double download_last_progress_;
170 166
171 bool is_download_average_speed_computed_ = false; 167 bool is_download_average_speed_computed_;
172 double download_average_speed_ = 0; 168 double download_average_speed_;
173 169
174 // True if there was no notification from NetworkPortalDetector 170 // True if there was no notification from NetworkPortalDetector
175 // about state for the default network. 171 // about state for the default network.
176 bool is_first_detection_notification_ = true; 172 bool is_first_detection_notification_;
177 173
178 // True if there was no notification about captive portal state for 174 // True if there was no notification about captive portal state for
179 // the default network. 175 // the default network.
180 bool is_first_portal_notification_ = true; 176 bool is_first_portal_notification_;
181 177
182 std::unique_ptr<ErrorScreensHistogramHelper> histogram_helper_; 178 std::unique_ptr<ErrorScreensHistogramHelper> histogram_helper_;
183 179
184 // Timer for the captive portal detector to show portal login page. 180 // Timer for the captive portal detector to show portal login page.
185 // If redirect did not happen during this delay, error message is shown 181 // If redirect did not happen during this delay, error message is shown
186 // instead. 182 // instead.
187 base::OneShotTimer error_message_timer_; 183 base::OneShotTimer error_message_timer_;
188 184
189 ErrorScreen::ConnectRequestCallbackSubscription connect_request_subscription_; 185 ErrorScreen::ConnectRequestCallbackSubscription connect_request_subscription_;
190 186
191 base::WeakPtrFactory<UpdateScreen> weak_factory_; 187 base::WeakPtrFactory<UpdateScreen> weak_factory_;
192 188
193 DISALLOW_COPY_AND_ASSIGN(UpdateScreen); 189 DISALLOW_COPY_AND_ASSIGN(UpdateScreen);
194 }; 190 };
195 191
196 } // namespace chromeos 192 } // namespace chromeos
197 193
198 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_UPDATE_SCREEN_H_ 194 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_UPDATE_SCREEN_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/screens/update_model.cc ('k') | chrome/browser/chromeos/login/screens/update_screen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698