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

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

Issue 25909005: Use UtilityProcessHost to patch files. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@nonblocking
Patch Set: Rebase to LKGR/248226 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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/component_updater_service.h" 5 #include "chrome/browser/component_updater/component_updater_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/at_exit.h" 11 #include "base/at_exit.h"
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/file_util.h" 14 #include "base/file_util.h"
15 #include "base/files/file_path.h" 15 #include "base/files/file_path.h"
16 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
18 #include "base/memory/weak_ptr.h" 18 #include "base/memory/weak_ptr.h"
19 #include "base/sequenced_task_runner.h" 19 #include "base/sequenced_task_runner.h"
20 #include "base/stl_util.h" 20 #include "base/stl_util.h"
21 #include "base/threading/sequenced_worker_pool.h" 21 #include "base/threading/sequenced_worker_pool.h"
22 #include "base/timer/timer.h" 22 #include "base/timer/timer.h"
23 #include "chrome/browser/browser_process.h" 23 #include "chrome/browser/browser_process.h"
24 #include "chrome/browser/component_updater/component_patcher.h"
25 #include "chrome/browser/component_updater/component_unpacker.h" 24 #include "chrome/browser/component_updater/component_unpacker.h"
26 #include "chrome/browser/component_updater/component_updater_ping_manager.h" 25 #include "chrome/browser/component_updater/component_updater_ping_manager.h"
27 #include "chrome/browser/component_updater/component_updater_utils.h" 26 #include "chrome/browser/component_updater/component_updater_utils.h"
28 #include "chrome/browser/component_updater/crx_downloader.h" 27 #include "chrome/browser/component_updater/crx_downloader.h"
29 #include "chrome/browser/component_updater/crx_update_item.h" 28 #include "chrome/browser/component_updater/crx_update_item.h"
30 #include "chrome/browser/component_updater/update_checker.h" 29 #include "chrome/browser/component_updater/update_checker.h"
31 #include "chrome/browser/component_updater/update_response.h" 30 #include "chrome/browser/component_updater/update_response.h"
32 #include "chrome/common/chrome_version_info.h" 31 #include "chrome/common/chrome_version_info.h"
33 #include "content/public/browser/browser_thread.h" 32 #include "content/public/browser/browser_thread.h"
34 #include "content/public/browser/resource_controller.h" 33 #include "content/public/browser/resource_controller.h"
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 void NotifyComponentObservers(ComponentObserver::Events event, 243 void NotifyComponentObservers(ComponentObserver::Events event,
245 int extra) const; 244 int extra) const;
246 245
247 bool HasOnDemandItems() const; 246 bool HasOnDemandItems() const;
248 247
249 void OnNewResourceThrottle(base::WeakPtr<CUResourceThrottle> rt, 248 void OnNewResourceThrottle(base::WeakPtr<CUResourceThrottle> rt,
250 const std::string& crx_id); 249 const std::string& crx_id);
251 250
252 scoped_ptr<ComponentUpdateService::Configurator> config_; 251 scoped_ptr<ComponentUpdateService::Configurator> config_;
253 252
254 scoped_ptr<ComponentPatcher> component_patcher_;
255
256 scoped_ptr<UpdateChecker> update_checker_; 253 scoped_ptr<UpdateChecker> update_checker_;
257 254
258 scoped_ptr<PingManager> ping_manager_; 255 scoped_ptr<PingManager> ping_manager_;
259 256
260 scoped_ptr<ComponentUnpacker> unpacker_; 257 scoped_ptr<ComponentUnpacker> unpacker_;
261 258
262 scoped_ptr<CrxDownloader> crx_downloader_; 259 scoped_ptr<CrxDownloader> crx_downloader_;
263 260
264 // A collection of every work item. 261 // A collection of every work item.
265 typedef std::vector<CrxUpdateItem*> UpdateItems; 262 typedef std::vector<CrxUpdateItem*> UpdateItems;
266 UpdateItems work_items_; 263 UpdateItems work_items_;
267 264
268 base::OneShotTimer<CrxUpdateService> timer_; 265 base::OneShotTimer<CrxUpdateService> timer_;
269 266
270 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; 267 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
271 268
272 const Version chrome_version_; 269 const Version chrome_version_;
273 270
274 bool running_; 271 bool running_;
275 272
276 DISALLOW_COPY_AND_ASSIGN(CrxUpdateService); 273 DISALLOW_COPY_AND_ASSIGN(CrxUpdateService);
277 }; 274 };
278 275
279 ////////////////////////////////////////////////////////////////////////////// 276 //////////////////////////////////////////////////////////////////////////////
280 277
281 CrxUpdateService::CrxUpdateService(ComponentUpdateService::Configurator* config) 278 CrxUpdateService::CrxUpdateService(ComponentUpdateService::Configurator* config)
282 : config_(config), 279 : config_(config),
283 component_patcher_(config->CreateComponentPatcher()),
284 ping_manager_(new PingManager(config->PingUrl(), 280 ping_manager_(new PingManager(config->PingUrl(),
285 config->RequestContext())), 281 config->RequestContext())),
286 blocking_task_runner_(BrowserThread::GetBlockingPool()-> 282 blocking_task_runner_(BrowserThread::GetBlockingPool()->
287 GetSequencedTaskRunnerWithShutdownBehavior( 283 GetSequencedTaskRunnerWithShutdownBehavior(
288 BrowserThread::GetBlockingPool()->GetSequenceToken(), 284 BrowserThread::GetBlockingPool()->GetSequenceToken(),
289 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)), 285 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)),
290 chrome_version_(chrome::VersionInfo().Version()), 286 chrome_version_(chrome::VersionInfo().Version()),
291 running_(false) { 287 running_(false) {
292 } 288 }
293 289
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 // Install consists of digital signature verification, unpacking and then 832 // Install consists of digital signature verification, unpacking and then
837 // calling the component specific installer. All that is handled by the 833 // calling the component specific installer. All that is handled by the
838 // |unpacker_|. If there is an error this function is in charge of deleting 834 // |unpacker_|. If there is an error this function is in charge of deleting
839 // the files created. 835 // the files created.
840 void CrxUpdateService::Install(scoped_ptr<CRXContext> context, 836 void CrxUpdateService::Install(scoped_ptr<CRXContext> context,
841 const base::FilePath& crx_path) { 837 const base::FilePath& crx_path) {
842 // This function owns the file at |crx_path| and the |context| object. 838 // This function owns the file at |crx_path| and the |context| object.
843 unpacker_.reset(new ComponentUnpacker(context->pk_hash, 839 unpacker_.reset(new ComponentUnpacker(context->pk_hash,
844 crx_path, 840 crx_path,
845 context->fingerprint, 841 context->fingerprint,
846 component_patcher_.get(),
847 context->installer, 842 context->installer,
843 config_->InProcess(),
848 blocking_task_runner_)); 844 blocking_task_runner_));
849 unpacker_->Unpack(base::Bind(&CrxUpdateService::EndUnpacking, 845 unpacker_->Unpack(base::Bind(&CrxUpdateService::EndUnpacking,
850 base::Unretained(this), 846 base::Unretained(this),
851 context->id, 847 context->id,
852 crx_path)); 848 crx_path));
853 } 849 }
854 850
855 void CrxUpdateService::EndUnpacking(const std::string& component_id, 851 void CrxUpdateService::EndUnpacking(const std::string& component_id,
856 const base::FilePath& crx_path, 852 const base::FilePath& crx_path,
857 ComponentUnpacker::Error error, 853 ComponentUnpacker::Error error,
858 int extended_error) { 854 int extended_error) {
859 if (!DeleteFileAndEmptyParentDirectory(crx_path)) 855 if (!DeleteFileAndEmptyParentDirectory(crx_path))
860 NOTREACHED() << crx_path.value(); 856 NOTREACHED() << crx_path.value();
861 BrowserThread::PostDelayedTask( 857 BrowserThread::PostDelayedTask(
862 BrowserThread::UI, 858 BrowserThread::UI,
863 FROM_HERE, 859 FROM_HERE,
864 base::Bind(&CrxUpdateService::DoneInstalling, base::Unretained(this), 860 base::Bind(&CrxUpdateService::DoneInstalling, base::Unretained(this),
865 component_id, error, extended_error), 861 component_id, error, extended_error),
866 base::TimeDelta::FromMilliseconds(config_->StepDelay())); 862 base::TimeDelta::FromMilliseconds(config_->StepDelay()));
863 // Reset the unpacker last, otherwise we free our own arguments.
Sorin Jianu 2014/02/03 20:57:57 What happens if the unpacker is destroyed sooner?
waffles 2014/02/07 01:00:59 The problem is that the unpacker owns the EndUnpac
Sorin Jianu 2014/02/27 20:53:57 Thank you. I would suggest rewording the comment a
864 unpacker_.reset();
867 } 865 }
868 866
869 // Installation has been completed. Adjust the component status and 867 // Installation has been completed. Adjust the component status and
870 // schedule the next check. Schedule a short delay before trying the full 868 // schedule the next check. Schedule a short delay before trying the full
871 // update when the differential update failed. 869 // update when the differential update failed.
872 void CrxUpdateService::DoneInstalling(const std::string& component_id, 870 void CrxUpdateService::DoneInstalling(const std::string& component_id,
873 ComponentUnpacker::Error error, 871 ComponentUnpacker::Error error,
874 int extra_code) { 872 int extra_code) {
875 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 873 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
876 874
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
995 // The component update factory. Using the component updater as a singleton 993 // The component update factory. Using the component updater as a singleton
996 // is the job of the browser process. 994 // is the job of the browser process.
997 ComponentUpdateService* ComponentUpdateServiceFactory( 995 ComponentUpdateService* ComponentUpdateServiceFactory(
998 ComponentUpdateService::Configurator* config) { 996 ComponentUpdateService::Configurator* config) {
999 DCHECK(config); 997 DCHECK(config);
1000 return new CrxUpdateService(config); 998 return new CrxUpdateService(config);
1001 } 999 }
1002 1000
1003 } // namespace component_updater 1001 } // namespace component_updater
1004 1002
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698