| OLD | NEW |
| 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/extensions/extension_updater.h" | 5 #include "chrome/browser/extensions/extension_updater.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 if (!success) { | 101 if (!success) { |
| 102 // We know there was an error writing the file. | 102 // We know there was an error writing the file. |
| 103 RecordFileUpdateHistogram(CANT_CREATE_OR_WRITE_TEMP_CRX); | 103 RecordFileUpdateHistogram(CANT_CREATE_OR_WRITE_TEMP_CRX); |
| 104 | 104 |
| 105 } else { | 105 } else { |
| 106 // Test that the file can be read. Based on histograms in | 106 // Test that the file can be read. Based on histograms in |
| 107 // SandboxExtensionUnpacker, we know that many CRX files | 107 // SandboxExtensionUnpacker, we know that many CRX files |
| 108 // can not be read. Try reading. | 108 // can not be read. Try reading. |
| 109 BrowserThread::PostTask( | 109 BrowserThread::PostTask( |
| 110 BrowserThread::FILE, FROM_HERE, | 110 BrowserThread::FILE, FROM_HERE, |
| 111 base::Bind(CheckThatCRXIsReadable, crx_path)); | 111 base::Bind(&CheckThatCRXIsReadable, crx_path)); |
| 112 } | 112 } |
| 113 } | 113 } |
| 114 | 114 |
| 115 void CheckThatCRXIsReadable(const FilePath& crx_path) { | 115 void CheckThatCRXIsReadable(const FilePath& crx_path) { |
| 116 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 116 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 117 | 117 |
| 118 FileWriteResult file_write_result = SUCCESS; | 118 FileWriteResult file_write_result = SUCCESS; |
| 119 | 119 |
| 120 // Open the file in the same way | 120 // Open the file in the same way |
| 121 // SandboxExtensionUnpacker::ValidateSigniture() will. | 121 // SandboxExtensionUnpacker::ValidateSigniture() will. |
| 122 ScopedStdioHandle file(file_util::OpenFile(crx_path, "rb")); | 122 ScopedStdioHandle file(file_util::OpenFile(crx_path, "rb")); |
| 123 if (!file.get()) { | 123 if (!file.get()) { |
| 124 LOG(ERROR) << "Can't read CRX file written for update at path " | 124 LOG(ERROR) << "Can't read CRX file written for update at path " |
| 125 << crx_path.value().c_str(); | 125 << crx_path.value().c_str(); |
| 126 file_write_result = CANT_READ_CRX_FILE; | 126 file_write_result = CANT_READ_CRX_FILE; |
| 127 } | 127 } |
| 128 | 128 |
| 129 BrowserThread::PostTask( | 129 BrowserThread::PostTask( |
| 130 BrowserThread::UI, FROM_HERE, | 130 BrowserThread::UI, FROM_HERE, |
| 131 base::Bind(RecordFileUpdateHistogram, file_write_result)); | 131 base::Bind(&RecordFileUpdateHistogram, file_write_result)); |
| 132 } | 132 } |
| 133 | 133 |
| 134 void RecordFileUpdateHistogram(FileWriteResult file_write_result) { | 134 void RecordFileUpdateHistogram(FileWriteResult file_write_result) { |
| 135 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 135 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 136 UMA_HISTOGRAM_ENUMERATION("Extensions.UpdaterWriteCrxAsFile", | 136 UMA_HISTOGRAM_ENUMERATION("Extensions.UpdaterWriteCrxAsFile", |
| 137 file_write_result, | 137 file_write_result, |
| 138 NUM_FILE_WRITE_RESULTS); | 138 NUM_FILE_WRITE_RESULTS); |
| 139 } | 139 } |
| 140 | 140 |
| 141 } // namespace | 141 } // namespace |
| (...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1244 std::set<std::string>::const_iterator i; | 1244 std::set<std::string>::const_iterator i; |
| 1245 for (i = ids.begin(); i != ids.end(); ++i) | 1245 for (i = ids.begin(); i != ids.end(); ++i) |
| 1246 in_progress_ids_.insert(*i); | 1246 in_progress_ids_.insert(*i); |
| 1247 } | 1247 } |
| 1248 | 1248 |
| 1249 void ExtensionUpdater::RemoveFromInProgress(const std::set<std::string>& ids) { | 1249 void ExtensionUpdater::RemoveFromInProgress(const std::set<std::string>& ids) { |
| 1250 std::set<std::string>::const_iterator i; | 1250 std::set<std::string>::const_iterator i; |
| 1251 for (i = ids.begin(); i != ids.end(); ++i) | 1251 for (i = ids.begin(); i != ids.end(); ++i) |
| 1252 in_progress_ids_.erase(*i); | 1252 in_progress_ids_.erase(*i); |
| 1253 } | 1253 } |
| OLD | NEW |