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

Side by Side Diff: Source/platform/weborigin/SecurityPolicy.cpp

Issue 1117513003: Initializes SecurityPolicy static locals during blink initialization (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « Source/platform/weborigin/SecurityPolicy.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "wtf/text/StringHash.h" 42 #include "wtf/text/StringHash.h"
43 43
44 namespace blink { 44 namespace blink {
45 45
46 using OriginAccessWhiteList = Vector<OriginAccessEntry>; 46 using OriginAccessWhiteList = Vector<OriginAccessEntry>;
47 using OriginAccessMap = HashMap<String, OwnPtr<OriginAccessWhiteList>>; 47 using OriginAccessMap = HashMap<String, OwnPtr<OriginAccessWhiteList>>;
48 using OriginSet = HashSet<String>; 48 using OriginSet = HashSet<String>;
49 49
50 static OriginAccessMap& originAccessMap() 50 static OriginAccessMap& originAccessMap()
51 { 51 {
52 AtomicallyInitializedStaticReference(OriginAccessMap, originAccessMap, new O riginAccessMap); 52 DEFINE_STATIC_LOCAL(OriginAccessMap, originAccessMap, ());
53 return originAccessMap; 53 return originAccessMap;
54 } 54 }
55 55
56 static OriginSet& trustworthyOriginSet() 56 static OriginSet& trustworthyOriginSet()
57 { 57 {
58 AtomicallyInitializedStaticReference(OriginSet, trustworthyOriginSet, new Or iginSet); 58 DEFINE_STATIC_LOCAL(OriginSet, trustworthyOriginSet, ());
59 return trustworthyOriginSet; 59 return trustworthyOriginSet;
60 } 60 }
61 61
62 void SecurityPolicy::init()
63 {
64 originAccessMap();
65 trustworthyOriginSet();
66 }
67
62 bool SecurityPolicy::shouldHideReferrer(const KURL& url, const String& referrer) 68 bool SecurityPolicy::shouldHideReferrer(const KURL& url, const String& referrer)
63 { 69 {
64 bool referrerIsSecureURL = protocolIs(referrer, "https"); 70 bool referrerIsSecureURL = protocolIs(referrer, "https");
65 bool referrerIsWebURL = referrerIsSecureURL || protocolIs(referrer, "http"); 71 bool referrerIsWebURL = referrerIsSecureURL || protocolIs(referrer, "http");
66 72
67 if (!referrerIsWebURL) 73 if (!referrerIsWebURL)
68 return true; 74 return true;
69 75
70 if (!referrerIsSecureURL) 76 if (!referrerIsSecureURL)
71 return false; 77 return false;
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 map.remove(it); 203 map.remove(it);
198 } 204 }
199 205
200 void SecurityPolicy::resetOriginAccessWhitelists() 206 void SecurityPolicy::resetOriginAccessWhitelists()
201 { 207 {
202 ASSERT(isMainThread()); 208 ASSERT(isMainThread());
203 originAccessMap().clear(); 209 originAccessMap().clear();
204 } 210 }
205 211
206 } // namespace blink 212 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/weborigin/SecurityPolicy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698