| OLD | NEW |
| 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" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 SafeManifestParser::SafeManifestParser(const std::string& xml, | 22 SafeManifestParser::SafeManifestParser(const std::string& xml, |
| 23 ManifestFetchData* fetch_data, | 23 ManifestFetchData* fetch_data, |
| 24 const UpdateCallback& update_callback) | 24 const UpdateCallback& update_callback) |
| 25 : xml_(xml), | 25 : xml_(xml), |
| 26 fetch_data_(fetch_data), | 26 fetch_data_(fetch_data), |
| 27 update_callback_(update_callback) { | 27 update_callback_(update_callback) { |
| 28 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 28 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 29 } | 29 } |
| 30 | 30 |
| 31 SafeManifestParser::~SafeManifestParser() { | |
| 32 // If we're using UtilityProcessHost, we may not be destroyed on | |
| 33 // the UI or IO thread. | |
| 34 } | |
| 35 | |
| 36 void SafeManifestParser::Start() { | 31 void SafeManifestParser::Start() { |
| 37 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 32 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 38 if (!BrowserThread::PostTask( | 33 if (!BrowserThread::PostTask( |
| 39 BrowserThread::IO, FROM_HERE, | 34 BrowserThread::IO, FROM_HERE, |
| 40 base::Bind(&SafeManifestParser::ParseInSandbox, this))) { | 35 base::Bind(&SafeManifestParser::ParseInSandbox, this))) { |
| 41 NOTREACHED(); | 36 NOTREACHED(); |
| 42 } | 37 } |
| 43 } | 38 } |
| 44 | 39 |
| 40 SafeManifestParser::~SafeManifestParser() { |
| 41 // If we're using UtilityProcessHost, we may not be destroyed on |
| 42 // the UI or IO thread. |
| 43 } |
| 44 |
| 45 void SafeManifestParser::ParseInSandbox() { | 45 void SafeManifestParser::ParseInSandbox() { |
| 46 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 46 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 47 | 47 |
| 48 // TODO(asargent) we shouldn't need to do this branch here - instead | 48 // TODO(asargent) we shouldn't need to do this branch here - instead |
| 49 // UtilityProcessHost should handle it for us. (http://crbug.com/19192) | 49 // UtilityProcessHost should handle it for us. (http://crbug.com/19192) |
| 50 bool use_utility_process = content::ResourceDispatcherHost::Get() && | 50 bool use_utility_process = content::ResourceDispatcherHost::Get() && |
| 51 !CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess); | 51 !CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess); |
| 52 if (use_utility_process) { | 52 if (use_utility_process) { |
| 53 content::UtilityProcessHost* host = content::UtilityProcessHost::Create( | 53 content::UtilityProcessHost* host = content::UtilityProcessHost::Create( |
| 54 this, BrowserThread::UI); | 54 this, BrowserThread::UI); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 | 97 |
| 98 void SafeManifestParser::OnParseUpdateManifestFailed( | 98 void SafeManifestParser::OnParseUpdateManifestFailed( |
| 99 const std::string& error_message) { | 99 const std::string& error_message) { |
| 100 VLOG(2) << "parsing manifest failed (" << fetch_data_->full_url() << ")"; | 100 VLOG(2) << "parsing manifest failed (" << fetch_data_->full_url() << ")"; |
| 101 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 101 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 102 LOG(WARNING) << "Error parsing update manifest:\n" << error_message; | 102 LOG(WARNING) << "Error parsing update manifest:\n" << error_message; |
| 103 update_callback_.Run(*fetch_data_, NULL); | 103 update_callback_.Run(*fetch_data_, NULL); |
| 104 } | 104 } |
| 105 | 105 |
| 106 } // namespace extensions | 106 } // namespace extensions |
| OLD | NEW |