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/component_loader.h" | 5 #include "chrome/browser/extensions/component_loader.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
11 #include "base/json/json_string_value_serializer.h" | 11 #include "base/json/json_string_value_serializer.h" |
12 #include "base/metrics/field_trial.h" | 12 #include "base/metrics/field_trial.h" |
13 #include "base/metrics/histogram_macros.h" | |
13 #include "base/path_service.h" | 14 #include "base/path_service.h" |
15 #include "base/time/time.h" | |
14 #include "chrome/browser/extensions/extension_service.h" | 16 #include "chrome/browser/extensions/extension_service.h" |
15 #include "chrome/browser/search/hotword_service.h" | 17 #include "chrome/browser/search/hotword_service.h" |
16 #include "chrome/browser/search/hotword_service_factory.h" | 18 #include "chrome/browser/search/hotword_service_factory.h" |
17 #include "chrome/common/chrome_paths.h" | 19 #include "chrome/common/chrome_paths.h" |
18 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
19 #include "chrome/common/chrome_version_info.h" | 21 #include "chrome/common/chrome_version_info.h" |
20 #include "chrome/common/extensions/extension_constants.h" | 22 #include "chrome/common/extensions/extension_constants.h" |
21 #include "chrome/grit/generated_resources.h" | 23 #include "chrome/grit/generated_resources.h" |
22 #include "components/crx_file/id_util.h" | 24 #include "components/crx_file/id_util.h" |
23 #include "content/public/browser/browser_context.h" | 25 #include "content/public/browser/browser_context.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
117 local_state_(local_state), | 119 local_state_(local_state), |
118 browser_context_(browser_context), | 120 browser_context_(browser_context), |
119 extension_service_(extension_service), | 121 extension_service_(extension_service), |
120 weak_factory_(this) {} | 122 weak_factory_(this) {} |
121 | 123 |
122 ComponentLoader::~ComponentLoader() { | 124 ComponentLoader::~ComponentLoader() { |
123 ClearAllRegistered(); | 125 ClearAllRegistered(); |
124 } | 126 } |
125 | 127 |
126 void ComponentLoader::LoadAll() { | 128 void ComponentLoader::LoadAll() { |
129 base::TimeTicks start_time = base::TimeTicks::Now(); | |
Mark P
2015/01/28 21:30:12
nit: might as well be const
| |
127 for (RegisteredComponentExtensions::iterator it = | 130 for (RegisteredComponentExtensions::iterator it = |
128 component_extensions_.begin(); | 131 component_extensions_.begin(); |
129 it != component_extensions_.end(); ++it) { | 132 it != component_extensions_.end(); ++it) { |
130 Load(*it); | 133 Load(*it); |
131 } | 134 } |
135 UMA_HISTOGRAM_TIMES("Extensions.LoadAllComponentTime", | |
136 base::TimeTicks::Now() - start_time); | |
132 } | 137 } |
133 | 138 |
134 base::DictionaryValue* ComponentLoader::ParseManifest( | 139 base::DictionaryValue* ComponentLoader::ParseManifest( |
135 const std::string& manifest_contents) const { | 140 const std::string& manifest_contents) const { |
136 JSONStringValueSerializer serializer(manifest_contents); | 141 JSONStringValueSerializer serializer(manifest_contents); |
137 scoped_ptr<base::Value> manifest(serializer.Deserialize(NULL, NULL)); | 142 scoped_ptr<base::Value> manifest(serializer.Deserialize(NULL, NULL)); |
138 | 143 |
139 if (!manifest.get() || !manifest->IsType(base::Value::TYPE_DICTIONARY)) { | 144 if (!manifest.get() || !manifest->IsType(base::Value::TYPE_DICTIONARY)) { |
140 LOG(ERROR) << "Failed to parse extension manifest."; | 145 LOG(ERROR) << "Failed to parse extension manifest."; |
141 return NULL; | 146 return NULL; |
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
660 off_the_record_context, Extension::GetBaseURLFromExtensionId(id)); | 665 off_the_record_context, Extension::GetBaseURLFromExtensionId(id)); |
661 storage::FileSystemContext* file_system_context = | 666 storage::FileSystemContext* file_system_context = |
662 content::BrowserContext::GetStoragePartitionForSite( | 667 content::BrowserContext::GetStoragePartitionForSite( |
663 off_the_record_context, site)->GetFileSystemContext(); | 668 off_the_record_context, site)->GetFileSystemContext(); |
664 file_system_context->EnableTemporaryFileSystemInIncognito(); | 669 file_system_context->EnableTemporaryFileSystemInIncognito(); |
665 } | 670 } |
666 #endif | 671 #endif |
667 } | 672 } |
668 | 673 |
669 } // namespace extensions | 674 } // namespace extensions |
OLD | NEW |