Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(131)

Side by Side Diff: extensions/common/features/complex_feature.cc

Issue 2193693003: Further reduction of feature_compiler.py generated code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@test-with-leiz
Patch Set: . Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/complex_feature.h" 5 #include "extensions/common/features/complex_feature.h"
6 6
7 #include "base/stl_util.h"
8
7 namespace extensions { 9 namespace extensions {
8 10
9 ComplexFeature::ComplexFeature(std::unique_ptr<FeatureList> features) { 11 ComplexFeature::ComplexFeature(FeatureList* features) {
10 DCHECK_GT(features->size(), 0UL); 12 DCHECK_GT(features->size(), 0UL);
11 features_.swap(*features); 13 features_.swap(*features);
12 no_parent_ = features_[0]->no_parent(); 14 no_parent_ = features_[0]->no_parent();
13 15
14 #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON) 16 #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
15 // Verify IsInternal and no_parent is consistent across all features. 17 // Verify IsInternal and no_parent is consistent across all features.
16 bool first_is_internal = features_[0]->IsInternal(); 18 bool first_is_internal = features_[0]->IsInternal();
17 for (FeatureList::const_iterator it = features_.begin() + 1; 19 for (FeatureList::const_iterator it = features_.begin() + 1;
18 it != features_.end(); 20 it != features_.end();
19 ++it) { 21 ++it) {
20 DCHECK(first_is_internal == (*it)->IsInternal()) 22 DCHECK(first_is_internal == (*it)->IsInternal())
21 << "Complex feature must have consistent values of " 23 << "Complex feature must have consistent values of "
22 "internal across all sub features."; 24 "internal across all sub features.";
23 DCHECK(no_parent_ == (*it)->no_parent()) 25 DCHECK(no_parent_ == (*it)->no_parent())
24 << "Complex feature must have consistent values of " 26 << "Complex feature must have consistent values of "
25 "no_parent across all sub features."; 27 "no_parent across all sub features.";
26 } 28 }
27 #endif 29 #endif
28 } 30 }
29 31
30 ComplexFeature::~ComplexFeature() { 32 ComplexFeature::~ComplexFeature() {
33 STLDeleteElements(&features_);
Devlin 2016/07/29 18:50:14 This makes me a bit sad. Since we control the con
scottmg 2016/07/29 20:05:04 Is something like this what you had in mind? I'm
31 } 34 }
32 35
33 Feature::Availability ComplexFeature::IsAvailableToManifest( 36 Feature::Availability ComplexFeature::IsAvailableToManifest(
34 const std::string& extension_id, 37 const std::string& extension_id,
35 Manifest::Type type, 38 Manifest::Type type,
36 Manifest::Location location, 39 Manifest::Location location,
37 int manifest_version, 40 int manifest_version,
38 Platform platform) const { 41 Platform platform) const {
39 Feature::Availability first_availability = 42 Feature::Availability first_availability =
40 features_[0]->IsAvailableToManifest( 43 features_[0]->IsAvailableToManifest(
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 return false; 99 return false;
97 } 100 }
98 101
99 bool ComplexFeature::IsInternal() const { 102 bool ComplexFeature::IsInternal() const {
100 // Constructor verifies that composed features are consistent, thus we can 103 // Constructor verifies that composed features are consistent, thus we can
101 // return just the first feature's value. 104 // return just the first feature's value.
102 return features_[0]->IsInternal(); 105 return features_[0]->IsInternal();
103 } 106 }
104 107
105 } // namespace extensions 108 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698