| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_CROS_UPDATE_LIBRARY_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_CROS_UPDATE_LIBRARY_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_CROS_UPDATE_LIBRARY_H_ | 6 #define CHROME_BROWSER_CHROMEOS_CROS_UPDATE_LIBRARY_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 std::string new_version; | 49 std::string new_version; |
| 50 int64_t new_size; // Valid during DOWNLOADING, in bytes. | 50 int64_t new_size; // Valid during DOWNLOADING, in bytes. |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 class Observer { | 53 class Observer { |
| 54 public: | 54 public: |
| 55 virtual ~Observer() { } | 55 virtual ~Observer() { } |
| 56 virtual void UpdateStatusChanged(UpdateLibrary* library) = 0; | 56 virtual void UpdateStatusChanged(UpdateLibrary* library) = 0; |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 // static UpdateLibrary* GetStubImplementation(); |
| 60 |
| 59 virtual ~UpdateLibrary() {} | 61 virtual ~UpdateLibrary() {} |
| 60 virtual void AddObserver(Observer* observer) = 0; | 62 virtual void AddObserver(Observer* observer) = 0; |
| 61 virtual void RemoveObserver(Observer* observer) = 0; | 63 virtual void RemoveObserver(Observer* observer) = 0; |
| 62 | 64 |
| 63 // Initiates update check and returns true if check was initiated. | 65 // Initiates update check and returns true if check was initiated. |
| 64 virtual bool CheckForUpdate() = 0; | 66 virtual bool CheckForUpdate() = 0; |
| 65 | 67 |
| 66 // Reboots if update has been performed. | 68 // Reboots if update has been performed. |
| 67 virtual bool RebootAfterUpdate() = 0; | 69 virtual bool RebootAfterUpdate() = 0; |
| 68 | 70 |
| 69 virtual const Status& status() const = 0; | 71 virtual const Status& status() const = 0; |
| 70 }; | |
| 71 | 72 |
| 72 class UpdateLibraryImpl : public UpdateLibrary { | 73 // Get library implementation. |
| 73 public: | 74 static UpdateLibrary* GetImpl(bool stub); |
| 74 UpdateLibraryImpl(); | |
| 75 virtual ~UpdateLibraryImpl(); | |
| 76 | |
| 77 // UpdateLibrary overrides. | |
| 78 virtual void AddObserver(Observer* observer); | |
| 79 virtual void RemoveObserver(Observer* observer); | |
| 80 | |
| 81 virtual bool CheckForUpdate(); | |
| 82 virtual bool RebootAfterUpdate(); | |
| 83 virtual const Status& status() const; | |
| 84 | |
| 85 private: | |
| 86 | |
| 87 // This method is called when there's a change in status. | |
| 88 // This method is called on a background thread. | |
| 89 static void ChangedHandler(void* object, const UpdateProgress& status); | |
| 90 | |
| 91 // This methods starts the monitoring of power changes. | |
| 92 void Init(); | |
| 93 | |
| 94 // Called by the handler to update the power status. | |
| 95 // This will notify all the Observers. | |
| 96 void UpdateStatus(const Status& status); | |
| 97 | |
| 98 ObserverList<Observer> observers_; | |
| 99 | |
| 100 // A reference to the update api, to allow callbacks when the update | |
| 101 // status changes. | |
| 102 UpdateStatusConnection status_connection_; | |
| 103 | |
| 104 // The latest power status. | |
| 105 Status status_; | |
| 106 | |
| 107 DISALLOW_COPY_AND_ASSIGN(UpdateLibraryImpl); | |
| 108 }; | 75 }; |
| 109 | 76 |
| 110 } // namespace chromeos | 77 } // namespace chromeos |
| 111 | 78 |
| 112 #endif // CHROME_BROWSER_CHROMEOS_CROS_UPDATE_LIBRARY_H_ | 79 #endif // CHROME_BROWSER_CHROMEOS_CROS_UPDATE_LIBRARY_H_ |
| 113 | 80 |
| OLD | NEW |