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

Side by Side Diff: chrome/browser/safe_browsing/threat_details.cc

Issue 2733283002: Require explicit selection of traits for LazyInstance (Closed)
Patch Set: Created 3 years, 9 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 (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 // Implementation of the ThreatDetails class. 5 // Implementation of the ThreatDetails class.
6 6
7 #include "chrome/browser/safe_browsing/threat_details.h" 7 #include "chrome/browser/safe_browsing/threat_details.h"
8 8
9 #include <stddef.h> 9 #include <stddef.h>
10 #include <stdint.h> 10 #include <stdint.h>
(...skipping 30 matching lines...) Expand all
41 41
42 const base::Feature kFillDOMInThreatDetails{"FillDOMInThreatDetails", 42 const base::Feature kFillDOMInThreatDetails{"FillDOMInThreatDetails",
43 base::FEATURE_DISABLED_BY_DEFAULT}; 43 base::FEATURE_DISABLED_BY_DEFAULT};
44 44
45 namespace { 45 namespace {
46 46
47 typedef std::unordered_set<std::string> StringSet; 47 typedef std::unordered_set<std::string> StringSet;
48 // A set of HTTPS headers that are allowed to be collected. Contains both 48 // A set of HTTPS headers that are allowed to be collected. Contains both
49 // request and response headers. All entries in this list should be lower-case 49 // request and response headers. All entries in this list should be lower-case
50 // to support case-insensitive comparison. 50 // to support case-insensitive comparison.
51 struct WhitelistedHttpsHeadersTraits : 51 struct WhitelistedHttpsHeadersTraits : base::LazyInstanceTraitsBase<StringSet> {
Nico 2017/03/07 21:43:02 Wait, how does this compile? This derives from Bas
scottmg 2017/03/07 21:56:30 Ahem, it probably doesn't. Fixed.
52 base::DefaultLazyInstanceTraits<StringSet> {
53 static StringSet* New(void* instance) { 52 static StringSet* New(void* instance) {
54 StringSet* headers = base::DefaultLazyInstanceTraits<StringSet>::New( 53 StringSet* headers = base::LazyInstanceTraitsBase<StringSet>::New(instance);
55 instance);
56 headers->insert({"google-creative-id", "google-lineitem-id", "referer", 54 headers->insert({"google-creative-id", "google-lineitem-id", "referer",
57 "content-type", "content-length", "date", "server", "cache-control", 55 "content-type", "content-length", "date", "server", "cache-control",
58 "pragma", "expires"}); 56 "pragma", "expires"});
59 return headers; 57 return headers;
60 } 58 }
61 }; 59 };
62 base::LazyInstance<StringSet, WhitelistedHttpsHeadersTraits> 60 base::LazyInstance<StringSet, WhitelistedHttpsHeadersTraits>
63 g_https_headers_whitelist = LAZY_INSTANCE_INITIALIZER; 61 g_https_headers_whitelist = LAZY_INSTANCE_INITIALIZER;
64 62
65 // Helper function that converts SBThreatType to 63 // Helper function that converts SBThreatType to
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 class ThreatDetailsFactoryImpl : public ThreatDetailsFactory { 135 class ThreatDetailsFactoryImpl : public ThreatDetailsFactory {
138 public: 136 public:
139 ThreatDetails* CreateThreatDetails( 137 ThreatDetails* CreateThreatDetails(
140 BaseUIManager* ui_manager, 138 BaseUIManager* ui_manager,
141 WebContents* web_contents, 139 WebContents* web_contents,
142 const security_interstitials::UnsafeResource& unsafe_resource) override { 140 const security_interstitials::UnsafeResource& unsafe_resource) override {
143 return new ThreatDetails(ui_manager, web_contents, unsafe_resource); 141 return new ThreatDetails(ui_manager, web_contents, unsafe_resource);
144 } 142 }
145 143
146 private: 144 private:
147 friend struct base::DefaultLazyInstanceTraits<ThreatDetailsFactoryImpl>; 145 friend struct base::LazyInstanceTraitsBase<ThreatDetailsFactoryImpl>;
148 146
149 ThreatDetailsFactoryImpl() {} 147 ThreatDetailsFactoryImpl() {}
150 148
151 DISALLOW_COPY_AND_ASSIGN(ThreatDetailsFactoryImpl); 149 DISALLOW_COPY_AND_ASSIGN(ThreatDetailsFactoryImpl);
152 }; 150 };
153 151
154 static base::LazyInstance<ThreatDetailsFactoryImpl> 152 static base::LazyInstance<ThreatDetailsFactoryImpl>
155 g_threat_details_factory_impl = LAZY_INSTANCE_INITIALIZER; 153 g_threat_details_factory_impl = LAZY_INSTANCE_INITIALIZER;
156 154
157 // Create a ThreatDetails for the given tab. 155 // Create a ThreatDetails for the given tab.
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 // Send the report, using the SafeBrowsingService. 582 // Send the report, using the SafeBrowsingService.
585 std::string serialized; 583 std::string serialized;
586 if (!report_->SerializeToString(&serialized)) { 584 if (!report_->SerializeToString(&serialized)) {
587 DLOG(ERROR) << "Unable to serialize the threat report."; 585 DLOG(ERROR) << "Unable to serialize the threat report.";
588 return; 586 return;
589 } 587 }
590 ui_manager_->SendSerializedThreatDetails(serialized); 588 ui_manager_->SendSerializedThreatDetails(serialized);
591 } 589 }
592 590
593 } // namespace safe_browsing 591 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698