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

Side by Side Diff: chrome/browser/component_updater/recovery_component_installer.cc

Issue 109673004: Revert "Update all users of base::Version to explicitly specify the namespace, and clean up the hea… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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) 2012 The Chromium Authors. All rights reserved. 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 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 #include "chrome/browser/component_updater/recovery_component_installer.h" 5 #include "chrome/browser/component_updater/recovery_component_installer.h"
6 6
7 #include "base/base_paths.h" 7 #include "base/base_paths.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 28 matching lines...) Expand all
39 #else // OS_LINUX, OS_MACOSX, etc. 39 #else // OS_LINUX, OS_MACOSX, etc.
40 FILE_PATH_LITERAL("ChromeRecovery"); 40 FILE_PATH_LITERAL("ChromeRecovery");
41 #endif 41 #endif
42 42
43 const char kRecoveryManifestName[] = "ChromeRecovery"; 43 const char kRecoveryManifestName[] = "ChromeRecovery";
44 44
45 } // namespace 45 } // namespace
46 46
47 class RecoveryComponentInstaller : public ComponentInstaller { 47 class RecoveryComponentInstaller : public ComponentInstaller {
48 public: 48 public:
49 explicit RecoveryComponentInstaller(const base::Version& version, 49 explicit RecoveryComponentInstaller(const Version& version,
50 PrefService* prefs); 50 PrefService* prefs);
51 51
52 virtual ~RecoveryComponentInstaller() {} 52 virtual ~RecoveryComponentInstaller() {}
53 53
54 virtual void OnUpdateError(int error) OVERRIDE; 54 virtual void OnUpdateError(int error) OVERRIDE;
55 55
56 virtual bool Install(const base::DictionaryValue& manifest, 56 virtual bool Install(const base::DictionaryValue& manifest,
57 const base::FilePath& unpack_path) OVERRIDE; 57 const base::FilePath& unpack_path) OVERRIDE;
58 58
59 virtual bool GetInstalledFile(const std::string& file, 59 virtual bool GetInstalledFile(const std::string& file,
60 base::FilePath* installed_file) OVERRIDE; 60 base::FilePath* installed_file) OVERRIDE;
61 61
62 private: 62 private:
63 base::Version current_version_; 63 Version current_version_;
64 PrefService* prefs_; 64 PrefService* prefs_;
65 }; 65 };
66 66
67 void RecoveryRegisterHelper(ComponentUpdateService* cus, 67 void RecoveryRegisterHelper(ComponentUpdateService* cus,
68 PrefService* prefs) { 68 PrefService* prefs) {
69 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 69 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
70 base::Version version(prefs->GetString(prefs::kRecoveryComponentVersion)); 70 Version version(prefs->GetString(prefs::kRecoveryComponentVersion));
71 if (!version.IsValid()) { 71 if (!version.IsValid()) {
72 NOTREACHED(); 72 NOTREACHED();
73 return; 73 return;
74 } 74 }
75 75
76 CrxComponent recovery; 76 CrxComponent recovery;
77 recovery.name = "recovery"; 77 recovery.name = "recovery";
78 recovery.installer = new RecoveryComponentInstaller(version, prefs); 78 recovery.installer = new RecoveryComponentInstaller(version, prefs);
79 recovery.version = version; 79 recovery.version = version;
80 recovery.pk_hash.assign(kSha2Hash, &kSha2Hash[sizeof(kSha2Hash)]); 80 recovery.pk_hash.assign(kSha2Hash, &kSha2Hash[sizeof(kSha2Hash)]);
81 if (cus->RegisterComponent(recovery) != ComponentUpdateService::kOk) { 81 if (cus->RegisterComponent(recovery) != ComponentUpdateService::kOk) {
82 NOTREACHED() << "Recovery component registration failed."; 82 NOTREACHED() << "Recovery component registration failed.";
83 } 83 }
84 } 84 }
85 85
86 void RecoveryUpdateVersionHelper(const base::Version& version, 86 void RecoveryUpdateVersionHelper(const Version& version, PrefService* prefs) {
87 PrefService* prefs) {
88 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 87 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
89 prefs->SetString(prefs::kRecoveryComponentVersion, version.GetString()); 88 prefs->SetString(prefs::kRecoveryComponentVersion, version.GetString());
90 } 89 }
91 90
92 RecoveryComponentInstaller::RecoveryComponentInstaller( 91 RecoveryComponentInstaller::RecoveryComponentInstaller(
93 const base::Version& version, PrefService* prefs) 92 const Version& version, PrefService* prefs)
94 : current_version_(version), prefs_(prefs){ 93 : current_version_(version), prefs_(prefs){
95 DCHECK(version.IsValid()); 94 DCHECK(version.IsValid());
96 } 95 }
97 96
98 void RecoveryComponentInstaller::OnUpdateError(int error) { 97 void RecoveryComponentInstaller::OnUpdateError(int error) {
99 NOTREACHED() << "Recovery component update error: " << error; 98 NOTREACHED() << "Recovery component update error: " << error;
100 } 99 }
101 100
102 bool RecoveryComponentInstaller::Install(const base::DictionaryValue& manifest, 101 bool RecoveryComponentInstaller::Install(const base::DictionaryValue& manifest,
103 const base::FilePath& unpack_path) { 102 const base::FilePath& unpack_path) {
104 std::string name; 103 std::string name;
105 manifest.GetStringASCII("name", &name); 104 manifest.GetStringASCII("name", &name);
106 if (name != kRecoveryManifestName) 105 if (name != kRecoveryManifestName)
107 return false; 106 return false;
108 std::string proposed_version; 107 std::string proposed_version;
109 manifest.GetStringASCII("version", &proposed_version); 108 manifest.GetStringASCII("version", &proposed_version);
110 base::Version version(proposed_version.c_str()); 109 Version version(proposed_version.c_str());
111 if (!version.IsValid()) 110 if (!version.IsValid())
112 return false; 111 return false;
113 if (current_version_.CompareTo(version) >= 0) 112 if (current_version_.CompareTo(version) >= 0)
114 return false; 113 return false;
115 base::FilePath main_file = unpack_path.Append(kRecoveryFileName); 114 base::FilePath main_file = unpack_path.Append(kRecoveryFileName);
116 if (!base::PathExists(main_file)) 115 if (!base::PathExists(main_file))
117 return false; 116 return false;
118 // Passed the basic tests. The installation continues with the 117 // Passed the basic tests. The installation continues with the
119 // recovery component itself running from the temp directory. 118 // recovery component itself running from the temp directory.
120 CommandLine cmdline(main_file); 119 CommandLine cmdline(main_file);
(...skipping 27 matching lines...) Expand all
148 BrowserThread::UI, 147 BrowserThread::UI,
149 FROM_HERE, 148 FROM_HERE,
150 base::Bind(&RecoveryRegisterHelper, cus, prefs), 149 base::Bind(&RecoveryRegisterHelper, cus, prefs),
151 base::TimeDelta::FromSeconds(6)); 150 base::TimeDelta::FromSeconds(6));
152 #endif 151 #endif
153 } 152 }
154 153
155 void RegisterPrefsForRecoveryComponent(PrefRegistrySimple* registry) { 154 void RegisterPrefsForRecoveryComponent(PrefRegistrySimple* registry) {
156 registry->RegisterStringPref(prefs::kRecoveryComponentVersion, "0.0.0.0"); 155 registry->RegisterStringPref(prefs::kRecoveryComponentVersion, "0.0.0.0");
157 } 156 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698