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

Side by Side Diff: chrome/browser/chromeos/dbus/update_engine_client.h

Issue 9838085: Move files inside chrome/browser/chromeos/dbus to chromeos/dbus (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase Created 8 years, 8 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_CHROMEOS_DBUS_UPDATE_ENGINE_CLIENT_H_
6 #define CHROME_BROWSER_CHROMEOS_DBUS_UPDATE_ENGINE_CLIENT_H_
7
8 #include "base/callback.h"
9 #include "base/observer_list.h"
10 #include "chrome/browser/chromeos/dbus/dbus_client_implementation_type.h"
11
12 #include <string>
13
14 namespace dbus {
15 class Bus;
16 } // namespace
17
18 namespace chromeos {
19
20 // UpdateEngineClient is used to communicate with the update engine.
21 class UpdateEngineClient {
22 public:
23 // Edges for state machine
24 // IDLE->CHECKING_FOR_UPDATE
25 // CHECKING_FOR_UPDATE->IDLE
26 // CHECKING_FOR_UPDATE->UPDATE_AVAILABLE
27 // ...
28 // FINALIZING->UPDATE_NEED_REBOOT
29 // Any state can transition to REPORTING_ERROR_EVENT and then on to IDLE.
30 enum UpdateStatusOperation {
31 UPDATE_STATUS_ERROR = -1,
32 UPDATE_STATUS_IDLE = 0,
33 UPDATE_STATUS_CHECKING_FOR_UPDATE,
34 UPDATE_STATUS_UPDATE_AVAILABLE,
35 UPDATE_STATUS_DOWNLOADING,
36 UPDATE_STATUS_VERIFYING,
37 UPDATE_STATUS_FINALIZING,
38 UPDATE_STATUS_UPDATED_NEED_REBOOT,
39 UPDATE_STATUS_REPORTING_ERROR_EVENT
40 };
41
42 // The status of the ongoing update attempt.
43 struct Status {
44 Status() : status(UPDATE_STATUS_IDLE),
45 download_progress(0.0),
46 last_checked_time(0),
47 new_size(0) {
48 }
49
50 UpdateStatusOperation status;
51 double download_progress; // 0.0 - 1.0
52 int64_t last_checked_time; // As reported by std::time().
53 std::string new_version;
54 int64_t new_size; // Valid during DOWNLOADING, in bytes.
55 };
56
57 // The result code used for RequestUpdateCheck().
58 enum UpdateCheckResult {
59 UPDATE_RESULT_SUCCESS,
60 UPDATE_RESULT_FAILED,
61 UPDATE_RESULT_NOTIMPLEMENTED,
62 };
63
64 // Interface for observing changes from the update engine.
65 class Observer {
66 public:
67 // Called when the status is updated.
68 virtual void UpdateStatusChanged(const Status& status) {}
69 };
70
71 virtual ~UpdateEngineClient();
72
73 // Adds and removes the observer.
74 virtual void AddObserver(Observer* observer) = 0;
75 virtual void RemoveObserver(Observer* observer) = 0;
76 // Returns true if this object has the given observer.
77 virtual bool HasObserver(Observer* observer) = 0;
78
79 // Called once RequestUpdateCheck() is complete. Takes one parameter:
80 // - UpdateCheckResult: the result of the update check.
81 typedef base::Callback<void(UpdateCheckResult)> UpdateCheckCallback;
82
83 // Requests an update check and calls |callback| when completed.
84 virtual void RequestUpdateCheck(UpdateCheckCallback callback) = 0;
85
86 // Reboots if update has been performed.
87 virtual void RebootAfterUpdate() = 0;
88
89 // Requests to set the release track (channel). |track| should look like
90 // "beta-channel" or "dev-channel".
91 virtual void SetReleaseTrack(const std::string& track) = 0;
92
93 // Called once GetReleaseTrack() is complete. Takes one parameter;
94 // - string: the release track name like "beta-channel".
95 typedef base::Callback<void(const std::string&)> GetReleaseTrackCallback;
96
97 // Requests to get the release track and calls |callback| with the
98 // release track (channel). On error, calls |callback| with an empty
99 // string.
100 virtual void GetReleaseTrack(GetReleaseTrackCallback callback) = 0;
101
102 // Returns the last status the object received from the update engine.
103 //
104 // Ideally, the D-Bus client should be state-less, but there are clients
105 // that need this information.
106 virtual Status GetLastStatus() = 0;
107
108 // Returns an empty UpdateCheckCallback that does nothing.
109 static UpdateCheckCallback EmptyUpdateCheckCallback();
110
111 // Creates the instance.
112 static UpdateEngineClient* Create(DBusClientImplementationType type,
113 dbus::Bus* bus);
114
115 protected:
116 // Create() should be used instead.
117 UpdateEngineClient();
118
119 private:
120 DISALLOW_COPY_AND_ASSIGN(UpdateEngineClient);
121 };
122
123 } // namespace chromeos
124
125 #endif // CHROME_BROWSER_CHROMEOS_DBUS_UPDATE_ENGINE_CLIENT_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/dbus/speech_synthesizer_client.cc ('k') | chrome/browser/chromeos/dbus/update_engine_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698