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

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

Issue 341044: Move chromeos code to namespace chromeos. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 1 month 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
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
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_CHROMEOS_VERSION_LOADER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_VERSION_LOADER_H_
6 #define CHROME_BROWSER_CHROMEOS_CHROMEOS_VERSION_LOADER_H_ 6 #define CHROME_BROWSER_CHROMEOS_VERSION_LOADER_H_
7
8 #include <string>
7 9
8 #include "chrome/browser/cancelable_request.h" 10 #include "chrome/browser/cancelable_request.h"
9 #include "testing/gtest/include/gtest/gtest_prod.h" 11 #include "testing/gtest/include/gtest/gtest_prod.h"
10 12
11 class FilePath; 13 class FilePath;
12 14
15 namespace chromeos {
16
13 // ChromeOSVersionLoader loads the version of Chrome OS from the file system. 17 // ChromeOSVersionLoader loads the version of Chrome OS from the file system.
14 // Loading is done asynchronously on the file thread. Once loaded, 18 // Loading is done asynchronously on the file thread. Once loaded,
15 // ChromeOSVersionLoader callsback to a method of your choice with the version 19 // ChromeOSVersionLoader callsback to a method of your choice with the version
16 // (or an empty string if the version couldn't be found). 20 // (or an empty string if the version couldn't be found).
17 // To use ChromeOSVersionLoader do the following: 21 // To use ChromeOSVersionLoader do the following:
18 // 22 //
19 // . In your class define a member field of type ChromeOSVersionLoader and 23 // . In your class define a member field of type chromeos::VersionLoader and
20 // CancelableRequestConsumerBase. 24 // CancelableRequestConsumerBase.
21 // . Define the callback method, something like: 25 // . Define the callback method, something like:
22 // void OnGetChromeOSVersion(ChromeOSVersionLoader::Handle, 26 // void OnGetChromeOSVersion(chromeos::VersionLoader::Handle,
23 // std::string version); 27 // std::string version);
24 // . When you want the version invoke: loader.GetVersion(&consumer, callback); 28 // . When you want the version invoke: loader.GetVersion(&consumer, callback);
25 class ChromeOSVersionLoader : public CancelableRequestProvider { 29 class VersionLoader : public CancelableRequestProvider {
26 public: 30 public:
27 ChromeOSVersionLoader(); 31 VersionLoader();
28 32
29 // Signature 33 // Signature
30 typedef Callback2<Handle, std::string>::Type GetVersionCallback; 34 typedef Callback2<Handle, std::string>::Type GetVersionCallback;
31 35
32 typedef CancelableRequest<GetVersionCallback> GetVersionRequest; 36 typedef CancelableRequest<GetVersionCallback> GetVersionRequest;
33 37
34 // Asynchronously requests the version. 38 // Asynchronously requests the version.
35 Handle GetVersion(CancelableRequestConsumerBase* consumer, 39 Handle GetVersion(CancelableRequestConsumerBase* consumer,
36 GetVersionCallback* callback); 40 GetVersionCallback* callback);
37 41
38 private: 42 private:
39 FRIEND_TEST(ChromeOSVersionLoaderTest, ParseVersion); 43 FRIEND_TEST(VersionLoaderTest, ParseVersion);
40 44
41 // ChromeOSVersionLoader calls into the Backend on the file thread to load 45 // VersionLoader calls into the Backend on the file thread to load
42 // and extract the version. 46 // and extract the version.
43 class Backend : public base::RefCountedThreadSafe<Backend> { 47 class Backend : public base::RefCountedThreadSafe<Backend> {
44 public: 48 public:
45 Backend() {} 49 Backend() {}
46 50
47 // Calls ParseVersion to get the version # and notifies request. 51 // Calls ParseVersion to get the version # and notifies request.
48 // This is invoked on the file thread. 52 // This is invoked on the file thread.
49 void GetVersion(scoped_refptr<GetVersionRequest> request); 53 void GetVersion(scoped_refptr<GetVersionRequest> request);
50 54
51 private: 55 private:
52 DISALLOW_COPY_AND_ASSIGN(Backend); 56 DISALLOW_COPY_AND_ASSIGN(Backend);
53 }; 57 };
54 58
55 // Extracts the version from the file. 59 // Extracts the version from the file.
56 static std::string ParseVersion(const std::string& contents); 60 static std::string ParseVersion(const std::string& contents);
57 61
58 scoped_refptr<Backend> backend_; 62 scoped_refptr<Backend> backend_;
59 63
60 DISALLOW_COPY_AND_ASSIGN(ChromeOSVersionLoader); 64 DISALLOW_COPY_AND_ASSIGN(VersionLoader);
61 }; 65 };
62 66
63 #endif // CHROME_BROWSER_CHROMEOS_CHROMEOS_VERSION_LOADER_H_ 67 } // namespace chromeos
68
69 #endif // CHROME_BROWSER_CHROMEOS_VERSION_LOADER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698