| 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/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" | |
| 19 #include "base/string_util.h" | 18 #include "base/string_util.h" |
| 20 #include "base/stringprintf.h" | 19 #include "base/stringprintf.h" |
| 21 #include "base/timer.h" | 20 #include "base/timer.h" |
| 22 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
| 23 #include "chrome/browser/component_updater/component_unpacker.h" | 22 #include "chrome/browser/component_updater/component_unpacker.h" |
| 24 #include "chrome/common/chrome_notification_types.h" | 23 #include "chrome/common/chrome_notification_types.h" |
| 25 #include "chrome/common/chrome_utility_messages.h" | 24 #include "chrome/common/chrome_utility_messages.h" |
| 26 #include "chrome/common/chrome_version_info.h" | 25 #include "chrome/common/chrome_version_info.h" |
| 27 #include "chrome/common/extensions/extension.h" | 26 #include "chrome/common/extensions/extension.h" |
| 28 #include "content/browser/utility_process_host.h" | 27 #include "content/browser/utility_process_host.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 request.append(query); | 67 request.append(query); |
| 69 return request; | 68 return request; |
| 70 } | 69 } |
| 71 | 70 |
| 72 // Produces an extension-like friendly |id|. This might be removed in the | 71 // Produces an extension-like friendly |id|. This might be removed in the |
| 73 // future if we roll our on packing tools. | 72 // future if we roll our on packing tools. |
| 74 static std::string HexStringToID(const std::string& hexstr) { | 73 static std::string HexStringToID(const std::string& hexstr) { |
| 75 std::string id; | 74 std::string id; |
| 76 for (size_t i = 0; i < hexstr.size(); ++i) { | 75 for (size_t i = 0; i < hexstr.size(); ++i) { |
| 77 int val; | 76 int val; |
| 78 if (base::HexStringToInt(base::StringPiece(hexstr.begin() + i, | 77 if (base::HexStringToInt(hexstr.begin() + i, hexstr.begin() + i + 1, &val)) |
| 79 hexstr.begin() + i + 1), | |
| 80 &val)) { | |
| 81 id.append(1, val + 'a'); | 78 id.append(1, val + 'a'); |
| 82 } else { | 79 else |
| 83 id.append(1, 'a'); | 80 id.append(1, 'a'); |
| 84 } | |
| 85 } | 81 } |
| 86 DCHECK(Extension::IdIsValid(id)); | 82 DCHECK(Extension::IdIsValid(id)); |
| 87 return id; | 83 return id; |
| 88 } | 84 } |
| 89 | 85 |
| 90 // Returns given a crx id it returns a small number, less than 100, that has a | 86 // Returns given a crx id it returns a small number, less than 100, that has a |
| 91 // decent chance of being unique among the registered components. It also has | 87 // decent chance of being unique among the registered components. It also has |
| 92 // the nice property that can be trivially computed by hand. | 88 // the nice property that can be trivially computed by hand. |
| 93 static int CrxIdtoUMAId(const std::string& id) { | 89 static int CrxIdtoUMAId(const std::string& id) { |
| 94 CHECK(id.size() > 2); | 90 CHECK(id.size() > 2); |
| (...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 ScheduleNextRun(false); | 754 ScheduleNextRun(false); |
| 759 } | 755 } |
| 760 | 756 |
| 761 // The component update factory. Using the component updater as a singleton | 757 // The component update factory. Using the component updater as a singleton |
| 762 // is the job of the browser process. | 758 // is the job of the browser process. |
| 763 ComponentUpdateService* ComponentUpdateServiceFactory( | 759 ComponentUpdateService* ComponentUpdateServiceFactory( |
| 764 ComponentUpdateService::Configurator* config) { | 760 ComponentUpdateService::Configurator* config) { |
| 765 DCHECK(config); | 761 DCHECK(config); |
| 766 return new CrxUpdateService(config); | 762 return new CrxUpdateService(config); |
| 767 } | 763 } |
| OLD | NEW |