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

Side by Side Diff: chrome/browser/chromeos/cros/update_library.h

Issue 7575001: cros: Remove unneeded includes from update_library.h plus some random cleanups. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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
11 #include "base/memory/singleton.h"
12 #include "base/observer_list.h"
13 #include "base/time.h"
14 #include "third_party/cros/chromeos_update_engine.h" 11 #include "third_party/cros/chromeos_update_engine.h"
15 12
16 namespace chromeos { 13 namespace chromeos {
17 14
18 // This interface defines interaction with the ChromeOS update library APIs. 15 // This interface defines interaction with the ChromeOS update library APIs.
19 // Classes can add themselves as observers. Users can get an instance of this 16 // Classes can add themselves as observers. Users can get an instance of this
20 // library class like this: chromeos::CrosLibrary::Get()->GetUpdateLibrary() 17 // library class like this: chromeos::CrosLibrary::Get()->GetUpdateLibrary()
21 class UpdateLibrary { 18 class UpdateLibrary {
22 public: 19 public:
23 // TODO(seanparent): Should make the UpdateProgress type copyable. 20 // TODO(seanparent): Should make the UpdateProgress type copyable.
24 // We need to copy it to bind it for a deferred notification. 21 // We need to copy it to bind it for a deferred notification.
25 // Modifying the cros library just for that, for a single use case, 22 // Modifying the cros library just for that, for a single use case,
26 // isn't worth it. Instead we define this a local Status struct that 23 // isn't worth it. Instead we define this a local Status struct that
27 // is copyable. 24 // is copyable.
28 struct Status { 25 struct Status {
29 Status() 26 Status()
30 : status(UPDATE_STATUS_IDLE), 27 : status(UPDATE_STATUS_IDLE),
31 download_progress(0.0), 28 download_progress(0.0),
32 last_checked_time(0), 29 last_checked_time(0),
33 new_size(0) { 30 new_size(0) {
34 } 31 }
35 32
36 explicit Status(const UpdateProgress& x) : 33 explicit Status(const UpdateProgress& o)
37 status(x.status_), 34 : status(o.status_),
38 download_progress(x.download_progress_), 35 download_progress(o.download_progress_),
39 last_checked_time(x.last_checked_time_), 36 last_checked_time(o.last_checked_time_),
40 new_version(x.new_version_), 37 new_version(o.new_version_),
41 new_size(x.new_size_) { 38 new_size(o.new_size_) {
42 } 39 }
43 40
44 UpdateStatusOperation status; 41 UpdateStatusOperation status;
45 double download_progress; // 0.0 - 1.0 42 double download_progress; // 0.0 - 1.0
46 int64_t last_checked_time; // As reported by std::time(). 43 int64_t last_checked_time; // As reported by std::time().
47 std::string new_version; 44 std::string new_version;
48 int64_t new_size; // Valid during DOWNLOADING, in bytes. 45 int64_t new_size; // Valid during DOWNLOADING, in bytes.
49 }; 46 };
50 47
51 class Observer { 48 class Observer {
52 public: 49 public:
53 virtual ~Observer() {} 50 virtual ~Observer() {}
54 51
55 virtual void UpdateStatusChanged(UpdateLibrary* library) = 0; 52 virtual void UpdateStatusChanged(UpdateLibrary* library) = 0;
56 }; 53 };
57 54
58 virtual ~UpdateLibrary() {} 55 virtual ~UpdateLibrary() {}
(...skipping 21 matching lines...) Expand all
80 virtual const Status& status() const = 0; 77 virtual const Status& status() const = 0;
81 78
82 // Factory function, creates a new instance and returns ownership. 79 // Factory function, creates a new instance and returns ownership.
83 // For normal usage, access the singleton via CrosLibrary::Get(). 80 // For normal usage, access the singleton via CrosLibrary::Get().
84 static UpdateLibrary* GetImpl(bool stub); 81 static UpdateLibrary* GetImpl(bool stub);
85 }; 82 };
86 83
87 } // namespace chromeos 84 } // namespace chromeos
88 85
89 #endif // CHROME_BROWSER_CHROMEOS_CROS_UPDATE_LIBRARY_H_ 86 #endif // CHROME_BROWSER_CHROMEOS_CROS_UPDATE_LIBRARY_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/cros/update_library.cc » ('j') | chrome/browser/chromeos/cros/update_library.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698