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

Side by Side Diff: chrome/browser/extensions/updater/safe_manifest_parser.cc

Issue 19085002: Get rid of ResourceDispatcherHost check in safe_manifest_parser.cc. Single process mode is now hand… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 5 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/extensions/updater/extension_updater_unittest.cc ('k') | no next file » | 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) 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/extensions/updater/safe_manifest_parser.h" 5 #include "chrome/browser/extensions/updater/safe_manifest_parser.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "chrome/common/chrome_utility_messages.h" 11 #include "chrome/common/chrome_utility_messages.h"
12 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
13 #include "content/public/browser/resource_dispatcher_host.h"
14 #include "content/public/browser/utility_process_host.h" 13 #include "content/public/browser/utility_process_host.h"
15 #include "content/public/common/content_switches.h" 14 #include "content/public/common/content_switches.h"
16 #include "ipc/ipc_message_macros.h" 15 #include "ipc/ipc_message_macros.h"
17 16
18 using content::BrowserThread; 17 using content::BrowserThread;
19 18
20 namespace extensions { 19 namespace extensions {
21 20
22 SafeManifestParser::SafeManifestParser(const std::string& xml, 21 SafeManifestParser::SafeManifestParser(const std::string& xml,
23 ManifestFetchData* fetch_data, 22 ManifestFetchData* fetch_data,
(...skipping 14 matching lines...) Expand all
38 } 37 }
39 38
40 SafeManifestParser::~SafeManifestParser() { 39 SafeManifestParser::~SafeManifestParser() {
41 // If we're using UtilityProcessHost, we may not be destroyed on 40 // If we're using UtilityProcessHost, we may not be destroyed on
42 // the UI or IO thread. 41 // the UI or IO thread.
43 } 42 }
44 43
45 void SafeManifestParser::ParseInSandbox() { 44 void SafeManifestParser::ParseInSandbox() {
46 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 45 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
47 46
48 // TODO(asargent) we shouldn't need to do this branch here - instead 47 content::UtilityProcessHost* host = content::UtilityProcessHost::Create(
49 // UtilityProcessHost should handle it for us. (http://crbug.com/19192) 48 this,
50 bool use_utility_process = content::ResourceDispatcherHost::Get() && 49 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI).get());
51 !CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess); 50 host->EnableZygote();
52 if (use_utility_process) { 51 host->Send(new ChromeUtilityMsg_ParseUpdateManifest(xml_));
53 content::UtilityProcessHost* host = content::UtilityProcessHost::Create(
54 this,
55 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI).get());
56 host->EnableZygote();
57 host->Send(new ChromeUtilityMsg_ParseUpdateManifest(xml_));
58 } else {
59 UpdateManifest manifest;
60 if (manifest.Parse(xml_)) {
61 if (!BrowserThread::PostTask(
62 BrowserThread::UI, FROM_HERE,
63 base::Bind(
64 &SafeManifestParser::OnParseUpdateManifestSucceeded, this,
65 manifest.results()))) {
66 NOTREACHED();
67 }
68 } else {
69 if (!BrowserThread::PostTask(
70 BrowserThread::UI, FROM_HERE,
71 base::Bind(
72 &SafeManifestParser::OnParseUpdateManifestFailed, this,
73 manifest.errors()))) {
74 NOTREACHED();
75 }
76 }
77 }
78 } 52 }
79 53
80 bool SafeManifestParser::OnMessageReceived(const IPC::Message& message) { 54 bool SafeManifestParser::OnMessageReceived(const IPC::Message& message) {
81 bool handled = true; 55 bool handled = true;
82 IPC_BEGIN_MESSAGE_MAP(SafeManifestParser, message) 56 IPC_BEGIN_MESSAGE_MAP(SafeManifestParser, message)
83 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ParseUpdateManifest_Succeeded, 57 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ParseUpdateManifest_Succeeded,
84 OnParseUpdateManifestSucceeded) 58 OnParseUpdateManifestSucceeded)
85 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ParseUpdateManifest_Failed, 59 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ParseUpdateManifest_Failed,
86 OnParseUpdateManifestFailed) 60 OnParseUpdateManifestFailed)
87 IPC_MESSAGE_UNHANDLED(handled = false) 61 IPC_MESSAGE_UNHANDLED(handled = false)
(...skipping 10 matching lines...) Expand all
98 72
99 void SafeManifestParser::OnParseUpdateManifestFailed( 73 void SafeManifestParser::OnParseUpdateManifestFailed(
100 const std::string& error_message) { 74 const std::string& error_message) {
101 VLOG(2) << "parsing manifest failed (" << fetch_data_->full_url() << ")"; 75 VLOG(2) << "parsing manifest failed (" << fetch_data_->full_url() << ")";
102 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 76 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
103 LOG(WARNING) << "Error parsing update manifest:\n" << error_message; 77 LOG(WARNING) << "Error parsing update manifest:\n" << error_message;
104 update_callback_.Run(*fetch_data_, NULL); 78 update_callback_.Run(*fetch_data_, NULL);
105 } 79 }
106 80
107 } // namespace extensions 81 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/updater/extension_updater_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698