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

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

Issue 42003002: Extract supported codecs from CDM component manifest. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use constant; support existing manifests Created 7 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/file_util.h" 6 #include "base/file_util.h"
7 #include "base/files/file_enumerator.h" 7 #include "base/files/file_enumerator.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "base/version.h" 10 #include "base/version.h"
11 #include "chrome/browser/component_updater/default_component_installer.h" 11 #include "chrome/browser/component_updater/default_component_installer.h"
12 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
13 13
14 namespace { 14 namespace {
15 // Version "0" corresponds to no installed version. By the server's conventions, 15 // Version "0" corresponds to no installed version. By the server's conventions,
16 // we represent it as a dotted quad. 16 // we represent it as a dotted quad.
17 const char kNullVersion[] = "0.0.0.0"; 17 const char kNullVersion[] = "0.0.0.0";
18 } // namespace 18 } // namespace
19 19
20 ComponentInstallerTraits::~ComponentInstallerTraits() {
21 }
22
20 DefaultComponentInstaller::DefaultComponentInstaller( 23 DefaultComponentInstaller::DefaultComponentInstaller(
21 scoped_ptr<ComponentInstallerTraits> installer_traits) 24 scoped_ptr<ComponentInstallerTraits> installer_traits)
22 : current_version_(kNullVersion) { 25 : current_version_(kNullVersion) {
23 installer_traits_ = installer_traits.Pass(); 26 installer_traits_ = installer_traits.Pass();
24 } 27 }
25 28
26 DefaultComponentInstaller::~DefaultComponentInstaller() { 29 DefaultComponentInstaller::~DefaultComponentInstaller() {
27 } 30 }
28 31
29 void DefaultComponentInstaller::Register(ComponentUpdateService* cus) { 32 void DefaultComponentInstaller::Register(ComponentUpdateService* cus) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 installer_traits_->GetBaseDirectory().AppendASCII(version.GetString()); 72 installer_traits_->GetBaseDirectory().AppendASCII(version.GetString());
70 if (base::PathExists(install_path)) { 73 if (base::PathExists(install_path)) {
71 if (!base::DeleteFile(install_path, true)) 74 if (!base::DeleteFile(install_path, true))
72 return false; 75 return false;
73 } 76 }
74 if (!InstallHelper(manifest, unpack_path, install_path)) { 77 if (!InstallHelper(manifest, unpack_path, install_path)) {
75 base::DeleteFile(install_path, true); 78 base::DeleteFile(install_path, true);
76 return false; 79 return false;
77 } 80 }
78 current_version_ = version; 81 current_version_ = version;
79 installer_traits_->ComponentReady(current_version_, GetInstallDirectory()); 82 current_manifest_.reset(manifest.DeepCopy());
83 installer_traits_->ComponentReady(
84 current_version_,
85 GetInstallDirectory(),
86 scoped_ptr<base::DictionaryValue>(current_manifest_->DeepCopy()).Pass());
80 return true; 87 return true;
81 } 88 }
82 89
83 bool DefaultComponentInstaller::GetInstalledFile( 90 bool DefaultComponentInstaller::GetInstalledFile(
84 const std::string& file, 91 const std::string& file,
85 base::FilePath* installed_file) { 92 base::FilePath* installed_file) {
86 if (current_version_.Equals(base::Version(kNullVersion))) 93 if (current_version_.Equals(base::Version(kNullVersion)))
87 return false; // No component has been installed yet. 94 return false; // No component has been installed yet.
88 95
89 *installed_file = 96 *installed_file =
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 } 133 }
127 } else { 134 } else {
128 latest_dir = path; 135 latest_dir = path;
129 latest_version = version; 136 latest_version = version;
130 found = true; 137 found = true;
131 } 138 }
132 } 139 }
133 140
134 if (found) { 141 if (found) {
135 current_version_ = latest_version; 142 current_version_ = latest_version;
143 // TODO(waffles): Why do we save these as members rather than passing them
144 // to FinishRegistration()?
waffles 2013/10/24 23:07:06 There was the thought that the installer would be
ddorwin 2013/10/25 00:06:05 Okay, I'll change the TODO to be for me to remove
136 base::ReadFileToString(latest_dir.AppendASCII("manifest.fingerprint"), 145 base::ReadFileToString(latest_dir.AppendASCII("manifest.fingerprint"),
137 &current_fingerprint_); 146 &current_fingerprint_);
147 current_manifest_.reset(ReadComponentManifest(latest_dir));
148 if (!current_manifest_) {
149 DLOG(ERROR) << "Failed to read manifest for "
150 << installer_traits_->GetName() << " ("
151 << base_dir.MaybeAsASCII() << ").";
152 return;
153 }
138 } 154 }
139 155
140 // Remove older versions of the component. None should be in use during 156 // Remove older versions of the component. None should be in use during
141 // browser startup. 157 // browser startup.
142 for (std::vector<base::FilePath>::iterator iter = older_dirs.begin(); 158 for (std::vector<base::FilePath>::iterator iter = older_dirs.begin();
143 iter != older_dirs.end(); ++iter) { 159 iter != older_dirs.end(); ++iter) {
144 base::DeleteFile(*iter, true); 160 base::DeleteFile(*iter, true);
145 } 161 }
146 162
147 content::BrowserThread::PostTask( 163 content::BrowserThread::PostTask(
(...skipping 19 matching lines...) Expand all
167 installer_traits_->GetHash(&crx.pk_hash); 183 installer_traits_->GetHash(&crx.pk_hash);
168 ComponentUpdateService::Status status = cus->RegisterComponent(crx); 184 ComponentUpdateService::Status status = cus->RegisterComponent(crx);
169 if (status != ComponentUpdateService::kOk && 185 if (status != ComponentUpdateService::kOk &&
170 status != ComponentUpdateService::kReplaced) { 186 status != ComponentUpdateService::kReplaced) {
171 NOTREACHED() << "Component registration failed for " 187 NOTREACHED() << "Component registration failed for "
172 << installer_traits_->GetName(); 188 << installer_traits_->GetName();
173 return; 189 return;
174 } 190 }
175 191
176 if (current_version_.CompareTo(base::Version(kNullVersion)) > 0) { 192 if (current_version_.CompareTo(base::Version(kNullVersion)) > 0) {
193 // TODO(waffles): Why is this function called on the FILE thread? The only
194 // implementation just posts back to the UI thread. Should we instead post
195 // to UI in Install()?
waffles 2013/10/24 23:07:06 The thinking was that people would likely want to
ddorwin 2013/10/25 00:06:05 Assuming we're going to pass in the manifest like
waffles 2013/10/25 16:53:42 I'm OK with passing the manifest; it's fine with m
ddorwin 2013/10/25 19:03:40 Updated TODO.
waffles 2013/10/25 19:43:45 They'll call PathService::OverridePath and then so
196 scoped_ptr<base::DictionaryValue> manifest_copy(
197 current_manifest_->DeepCopy());
177 content::BrowserThread::PostTask( 198 content::BrowserThread::PostTask(
178 content::BrowserThread::FILE, FROM_HERE, 199 content::BrowserThread::FILE, FROM_HERE,
179 base::Bind(&ComponentInstallerTraits::ComponentReady, 200 base::Bind(&ComponentInstallerTraits::ComponentReady,
180 base::Unretained(installer_traits_.get()), 201 base::Unretained(installer_traits_.get()),
181 current_version_, 202 current_version_,
182 GetInstallDirectory())); 203 GetInstallDirectory(),
204 base::Passed(&manifest_copy)));
183 } 205 }
184 } 206 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698