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

Side by Side Diff: chrome/browser/chromeos/version_loader.h

Issue 137263007: Move CancelableTaskTracker to //base/task/CancelableTaskTracker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move to base/task/cancelable_task_tracker* Created 6 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) 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_VERSION_LOADER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_VERSION_LOADER_H_
6 #define CHROME_BROWSER_CHROMEOS_VERSION_LOADER_H_ 6 #define CHROME_BROWSER_CHROMEOS_VERSION_LOADER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/gtest_prod_util.h" 11 #include "base/gtest_prod_util.h"
12 #include "chrome/common/cancelable_task_tracker.h" 12 #include "base/task/cancelable_task_tracker.h"
13 13
14 namespace chromeos { 14 namespace chromeos {
15 15
16 // ChromeOSVersionLoader loads the version of Chrome OS from the file system. 16 // ChromeOSVersionLoader loads the version of Chrome OS from the file system.
17 // Loading is done asynchronously in the blocking thread pool. Once loaded, 17 // Loading is done asynchronously in the blocking thread pool. Once loaded,
18 // ChromeOSVersionLoader callback to a method of your choice with the version 18 // ChromeOSVersionLoader callback to a method of your choice with the version
19 // (or an empty string if the version couldn't be found). 19 // (or an empty string if the version couldn't be found).
20 // To use ChromeOSVersionLoader do the following: 20 // To use ChromeOSVersionLoader do the following:
21 // 21 //
22 // . In your class define a member field of type chromeos::VersionLoader and 22 // . In your class define a member field of type chromeos::VersionLoader and
23 // CancelableTaskTracker. 23 // base::CancelableTaskTracker.
24 // . Define the callback method, something like: 24 // . Define the callback method, something like:
25 // void OnGetChromeOSVersion(const std::string& version); 25 // void OnGetChromeOSVersion(const std::string& version);
26 // . When you want the version invoke: 26 // . When you want the version invoke:
27 // VersionLoader::GetVersion() 27 // VersionLoader::GetVersion()
28 // 28 //
29 // This class also provides the ability to load the bios firmware using 29 // This class also provides the ability to load the bios firmware using
30 // VersionLoader::GetFirmware() 30 // VersionLoader::GetFirmware()
31 class VersionLoader { 31 class VersionLoader {
32 public: 32 public:
33 VersionLoader(); 33 VersionLoader();
34 virtual ~VersionLoader(); 34 virtual ~VersionLoader();
35 35
36 enum VersionFormat { 36 enum VersionFormat {
37 VERSION_SHORT, 37 VERSION_SHORT,
38 VERSION_SHORT_WITH_DATE, 38 VERSION_SHORT_WITH_DATE,
39 VERSION_FULL, 39 VERSION_FULL,
40 }; 40 };
41 41
42 // Signature 42 // Signature
43 typedef base::Callback<void(const std::string&)> GetVersionCallback; 43 typedef base::Callback<void(const std::string&)> GetVersionCallback;
44 typedef base::Callback<void(const std::string&)> GetFirmwareCallback; 44 typedef base::Callback<void(const std::string&)> GetFirmwareCallback;
45 45
46 // Asynchronously requests the version. 46 // Asynchronously requests the version.
47 // If |full_version| is true version string with extra info is extracted, 47 // If |full_version| is true version string with extra info is extracted,
48 // otherwise it's in short format x.x.xx.x. 48 // otherwise it's in short format x.x.xx.x.
49 CancelableTaskTracker::TaskId GetVersion(VersionFormat format, 49 base::CancelableTaskTracker::TaskId GetVersion(
50 const GetVersionCallback& callback, 50 VersionFormat format,
51 CancelableTaskTracker* tracker); 51 const GetVersionCallback& callback,
52 base::CancelableTaskTracker* tracker);
52 53
53 CancelableTaskTracker::TaskId GetFirmware(const GetFirmwareCallback& callback, 54 base::CancelableTaskTracker::TaskId GetFirmware(
54 CancelableTaskTracker* tracker); 55 const GetFirmwareCallback& callback,
56 base::CancelableTaskTracker* tracker);
55 57
56 private: 58 private:
57 FRIEND_TEST_ALL_PREFIXES(VersionLoaderTest, ParseFirmware); 59 FRIEND_TEST_ALL_PREFIXES(VersionLoaderTest, ParseFirmware);
58 60
59 // VersionLoader calls into the Backend in the blocking thread pool to load 61 // VersionLoader calls into the Backend in the blocking thread pool to load
60 // and extract the version. 62 // and extract the version.
61 class Backend : public base::RefCountedThreadSafe<Backend> { 63 class Backend : public base::RefCountedThreadSafe<Backend> {
62 public: 64 public:
63 Backend() {} 65 Backend() {}
64 66
(...skipping 17 matching lines...) Expand all
82 static std::string ParseFirmware(const std::string& contents); 84 static std::string ParseFirmware(const std::string& contents);
83 85
84 scoped_refptr<Backend> backend_; 86 scoped_refptr<Backend> backend_;
85 87
86 DISALLOW_COPY_AND_ASSIGN(VersionLoader); 88 DISALLOW_COPY_AND_ASSIGN(VersionLoader);
87 }; 89 };
88 90
89 } // namespace chromeos 91 } // namespace chromeos
90 92
91 #endif // CHROME_BROWSER_CHROMEOS_VERSION_LOADER_H_ 93 #endif // CHROME_BROWSER_CHROMEOS_VERSION_LOADER_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/system/syslogs_provider.cc ('k') | chrome/browser/chromeos/version_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698