| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "extensions/common/features/feature_provider.h" | 5 #include "extensions/common/features/feature_provider.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <memory> |
| 8 | 9 |
| 9 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 10 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "base/metrics/histogram_macros.h" | 12 #include "base/metrics/histogram_macros.h" |
| 13 #include "base/trace_event/trace_event.h" | 13 #include "base/trace_event/trace_event.h" |
| 14 #include "content/public/common/content_switches.h" | 14 #include "content/public/common/content_switches.h" |
| 15 #include "extensions/common/extensions_client.h" | 15 #include "extensions/common/extensions_client.h" |
| 16 #include "extensions/common/features/feature.h" | 16 #include "extensions/common/features/feature.h" |
| 17 #include "extensions/common/features/feature_util.h" | 17 #include "extensions/common/features/feature_util.h" |
| 18 #include "extensions/common/switches.h" | 18 #include "extensions/common/switches.h" |
| 19 | 19 |
| 20 namespace extensions { | 20 namespace extensions { |
| 21 | 21 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 52 // browser process on startup, as well as on renderer and extension | 52 // browser process on startup, as well as on renderer and extension |
| 53 // processes throughout the execution of the browser. We are more | 53 // processes throughout the execution of the browser. We are more |
| 54 // interested in how long this takes as a startup cost, so we are | 54 // interested in how long this takes as a startup cost, so we are |
| 55 // just measuring the time in the browser process. | 55 // just measuring the time in the browser process. |
| 56 if (process_type == std::string()) { | 56 if (process_type == std::string()) { |
| 57 UMA_HISTOGRAM_TIMES("Extensions.FeatureProviderStaticInitTime", | 57 UMA_HISTOGRAM_TIMES("Extensions.FeatureProviderStaticInitTime", |
| 58 base::Time::Now() - begin_time); | 58 base::Time::Now() - begin_time); |
| 59 } | 59 } |
| 60 } | 60 } |
| 61 | 61 |
| 62 std::map<std::string, scoped_ptr<FeatureProvider>> feature_providers_; | 62 std::map<std::string, std::unique_ptr<FeatureProvider>> feature_providers_; |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 base::LazyInstance<Static> g_static = LAZY_INSTANCE_INITIALIZER; | 65 base::LazyInstance<Static> g_static = LAZY_INSTANCE_INITIALIZER; |
| 66 | 66 |
| 67 const Feature* GetFeatureFromProviderByName(const std::string& provider_name, | 67 const Feature* GetFeatureFromProviderByName(const std::string& provider_name, |
| 68 const std::string& feature_name) { | 68 const std::string& feature_name) { |
| 69 const Feature* feature = | 69 const Feature* feature = |
| 70 FeatureProvider::GetByName(provider_name)->GetFeature(feature_name); | 70 FeatureProvider::GetByName(provider_name)->GetFeature(feature_name); |
| 71 // We should always refer to existing features, but we can't CHECK here | 71 // We should always refer to existing features, but we can't CHECK here |
| 72 // due to flaky JSONReader fails, see: crbug.com/176381, crbug.com/602936 | 72 // due to flaky JSONReader fails, see: crbug.com/176381, crbug.com/602936 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 const Feature* FeatureProvider::GetPermissionFeature(const std::string& name) { | 116 const Feature* FeatureProvider::GetPermissionFeature(const std::string& name) { |
| 117 return GetFeatureFromProviderByName("permission", name); | 117 return GetFeatureFromProviderByName("permission", name); |
| 118 } | 118 } |
| 119 | 119 |
| 120 // static | 120 // static |
| 121 const Feature* FeatureProvider::GetBehaviorFeature(const std::string& name) { | 121 const Feature* FeatureProvider::GetBehaviorFeature(const std::string& name) { |
| 122 return GetFeatureFromProviderByName("behavior", name); | 122 return GetFeatureFromProviderByName("behavior", name); |
| 123 } | 123 } |
| 124 | 124 |
| 125 } // namespace extensions | 125 } // namespace extensions |
| OLD | NEW |