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

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

Issue 9317074: Create an API around UtilityProcessHost and use that from chrome. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/DEPS ('k') | chrome/browser/extensions/extension_management_api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #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 <vector> 8 #include <vector>
9 9
10 #include "base/at_exit.h" 10 #include "base/at_exit.h"
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/file_path.h" 12 #include "base/file_path.h"
13 #include "base/file_util.h" 13 #include "base/file_util.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/stl_util.h" 16 #include "base/stl_util.h"
17 #include "base/string_number_conversions.h" 17 #include "base/string_number_conversions.h"
18 #include "base/string_piece.h" 18 #include "base/string_piece.h"
19 #include "base/string_util.h" 19 #include "base/string_util.h"
20 #include "base/stringprintf.h" 20 #include "base/stringprintf.h"
21 #include "base/timer.h" 21 #include "base/timer.h"
22 #include "chrome/browser/browser_process.h" 22 #include "chrome/browser/browser_process.h"
23 #include "chrome/browser/component_updater/component_unpacker.h" 23 #include "chrome/browser/component_updater/component_unpacker.h"
24 #include "chrome/common/chrome_notification_types.h" 24 #include "chrome/common/chrome_notification_types.h"
25 #include "chrome/common/chrome_utility_messages.h" 25 #include "chrome/common/chrome_utility_messages.h"
26 #include "chrome/common/chrome_version_info.h" 26 #include "chrome/common/chrome_version_info.h"
27 #include "chrome/common/extensions/extension.h" 27 #include "chrome/common/extensions/extension.h"
28 #include "content/browser/utility_process_host.h"
29 #include "content/public/browser/notification_service.h" 28 #include "content/public/browser/notification_service.h"
29 #include "content/public/browser/utility_process_host.h"
30 #include "content/public/browser/utility_process_host_client.h"
30 #include "content/public/common/url_fetcher_delegate.h" 31 #include "content/public/common/url_fetcher_delegate.h"
31 #include "content/public/common/url_fetcher.h" 32 #include "content/public/common/url_fetcher.h"
32 #include "googleurl/src/gurl.h" 33 #include "googleurl/src/gurl.h"
33 #include "net/base/escape.h" 34 #include "net/base/escape.h"
34 #include "net/base/load_flags.h" 35 #include "net/base/load_flags.h"
35 36
36 using content::BrowserThread; 37 using content::BrowserThread;
38 using content::UtilityProcessHost;
39 using content::UtilityProcessHostClient;
37 40
38 // The component updater is designed to live until process shutdown, so 41 // The component updater is designed to live until process shutdown, so
39 // base::Bind() calls are not refcounted. 42 // base::Bind() calls are not refcounted.
40 43
41 namespace { 44 namespace {
42 // Extends an omaha compatible update check url |query| string. Does 45 // Extends an omaha compatible update check url |query| string. Does
43 // not mutate the string if it would be longer than |limit| chars. 46 // not mutate the string if it would be longer than |limit| chars.
44 bool AddQueryString(const std::string& id, 47 bool AddQueryString(const std::string& id,
45 const std::string& version, 48 const std::string& version,
46 size_t limit, 49 size_t limit,
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 explicit CrxUpdateService(ComponentUpdateService::Configurator* config); 233 explicit CrxUpdateService(ComponentUpdateService::Configurator* config);
231 234
232 virtual ~CrxUpdateService(); 235 virtual ~CrxUpdateService();
233 236
234 // Overrides for ComponentUpdateService. 237 // Overrides for ComponentUpdateService.
235 virtual Status Start() OVERRIDE; 238 virtual Status Start() OVERRIDE;
236 virtual Status Stop() OVERRIDE; 239 virtual Status Stop() OVERRIDE;
237 virtual Status RegisterComponent(const CrxComponent& component) OVERRIDE; 240 virtual Status RegisterComponent(const CrxComponent& component) OVERRIDE;
238 241
239 // The only purpose of this class is to forward the 242 // The only purpose of this class is to forward the
240 // UtilityProcessHost::Client callbacks so CrxUpdateService does 243 // UtilityProcessHostClient callbacks so CrxUpdateService does
241 // not have to derive from it because that is refcounted. 244 // not have to derive from it because that is refcounted.
242 class ManifestParserBridge : public UtilityProcessHost::Client { 245 class ManifestParserBridge : public UtilityProcessHostClient {
243 public: 246 public:
244 explicit ManifestParserBridge(CrxUpdateService* service) 247 explicit ManifestParserBridge(CrxUpdateService* service)
245 : service_(service) {} 248 : service_(service) {}
246 249
247 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE { 250 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE {
248 bool handled = true; 251 bool handled = true;
249 IPC_BEGIN_MESSAGE_MAP(ManifestParserBridge, message) 252 IPC_BEGIN_MESSAGE_MAP(ManifestParserBridge, message)
250 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ParseUpdateManifest_Succeeded, 253 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ParseUpdateManifest_Succeeded,
251 OnParseUpdateManifestSucceeded) 254 OnParseUpdateManifestSucceeded)
252 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ParseUpdateManifest_Failed, 255 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ParseUpdateManifest_Failed,
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 void CrxUpdateService::ParseManifest(const std::string& xml) { 593 void CrxUpdateService::ParseManifest(const std::string& xml) {
591 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 594 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
592 if (config_->InProcess()) { 595 if (config_->InProcess()) {
593 UpdateManifest manifest; 596 UpdateManifest manifest;
594 if (!manifest.Parse(xml)) { 597 if (!manifest.Parse(xml)) {
595 CrxUpdateService::OnParseUpdateManifestFailed(manifest.errors()); 598 CrxUpdateService::OnParseUpdateManifestFailed(manifest.errors());
596 } else { 599 } else {
597 CrxUpdateService::OnParseUpdateManifestSucceeded(manifest.results()); 600 CrxUpdateService::OnParseUpdateManifestSucceeded(manifest.results());
598 } 601 }
599 } else { 602 } else {
600 UtilityProcessHost* host = 603 UtilityProcessHost* host = UtilityProcessHost::Create(
601 new UtilityProcessHost(new ManifestParserBridge(this), 604 new ManifestParserBridge(this), BrowserThread::UI);
602 BrowserThread::UI); 605 host->EnableZygote();
603 host->set_use_linux_zygote(true);
604 host->Send(new ChromeUtilityMsg_ParseUpdateManifest(xml)); 606 host->Send(new ChromeUtilityMsg_ParseUpdateManifest(xml));
605 } 607 }
606 } 608 }
607 609
608 // A valid Omaha update check has arrived, from only the list of components that 610 // A valid Omaha update check has arrived, from only the list of components that
609 // we are currently upgrading we check for a match in which the server side 611 // we are currently upgrading we check for a match in which the server side
610 // version is newer, if so we queue them for an upgrade. The next time we call 612 // version is newer, if so we queue them for an upgrade. The next time we call
611 // ProcessPendingItems() one of them will be drafted for the upgrade process. 613 // ProcessPendingItems() one of them will be drafted for the upgrade process.
612 void CrxUpdateService::OnParseUpdateManifestSucceeded( 614 void CrxUpdateService::OnParseUpdateManifestSucceeded(
613 const UpdateManifest::Results& results) { 615 const UpdateManifest::Results& results) {
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 ScheduleNextRun(false); 762 ScheduleNextRun(false);
761 } 763 }
762 764
763 // The component update factory. Using the component updater as a singleton 765 // The component update factory. Using the component updater as a singleton
764 // is the job of the browser process. 766 // is the job of the browser process.
765 ComponentUpdateService* ComponentUpdateServiceFactory( 767 ComponentUpdateService* ComponentUpdateServiceFactory(
766 ComponentUpdateService::Configurator* config) { 768 ComponentUpdateService::Configurator* config) {
767 DCHECK(config); 769 DCHECK(config);
768 return new CrxUpdateService(config); 770 return new CrxUpdateService(config);
769 } 771 }
OLDNEW
« no previous file with comments | « chrome/browser/DEPS ('k') | chrome/browser/extensions/extension_management_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698