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