OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "net/base/transport_security_state.h" | 5 #include "net/base/transport_security_state.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 // include_subdomains is. | 93 // include_subdomains is. |
94 if (i == 0) | 94 if (i == 0) |
95 return true; | 95 return true; |
96 | 96 |
97 return j->second.include_subdomains; | 97 return j->second.include_subdomains; |
98 } | 98 } |
99 | 99 |
100 return false; | 100 return false; |
101 } | 101 } |
102 | 102 |
| 103 void TransportSecurityState::DeleteSince(const base::Time& time) { |
| 104 bool dirtied = false; |
| 105 |
| 106 std::map<std::string, DomainState>::iterator i = enabled_hosts_.begin(); |
| 107 while (i != enabled_hosts_.end()) { |
| 108 if (i->second.created >= time) { |
| 109 dirtied = true; |
| 110 enabled_hosts_.erase(i++); |
| 111 } else { |
| 112 i++; |
| 113 } |
| 114 } |
| 115 |
| 116 if (dirtied) |
| 117 DirtyNotify(); |
| 118 } |
| 119 |
103 // MaxAgeToInt converts a string representation of a number of seconds into a | 120 // MaxAgeToInt converts a string representation of a number of seconds into a |
104 // int. We use strtol in order to handle overflow correctly. The string may | 121 // int. We use strtol in order to handle overflow correctly. The string may |
105 // contain an arbitary number which we should truncate correctly rather than | 122 // contain an arbitary number which we should truncate correctly rather than |
106 // throwing a parse failure. | 123 // throwing a parse failure. |
107 static bool MaxAgeToInt(std::string::const_iterator begin, | 124 static bool MaxAgeToInt(std::string::const_iterator begin, |
108 std::string::const_iterator end, | 125 std::string::const_iterator end, |
109 int* result) { | 126 int* result) { |
110 const std::string s(begin, end); | 127 const std::string s(begin, end); |
111 char* endptr; | 128 char* endptr; |
112 long int i = strtol(s.data(), &endptr, 10 /* base */); | 129 long int i = strtol(s.data(), &endptr, 10 /* base */); |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 new_state.created = created_time; | 360 new_state.created = created_time; |
344 new_state.expiry = expiry_time; | 361 new_state.expiry = expiry_time; |
345 new_state.include_subdomains = include_subdomains; | 362 new_state.include_subdomains = include_subdomains; |
346 enabled_hosts_[hashed] = new_state; | 363 enabled_hosts_[hashed] = new_state; |
347 } | 364 } |
348 | 365 |
349 *dirty = dirtied; | 366 *dirty = dirtied; |
350 return true; | 367 return true; |
351 } | 368 } |
352 | 369 |
353 void TransportSecurityState::DeleteSince(const base::Time& time) { | |
354 bool dirtied = false; | |
355 | |
356 std::map<std::string, DomainState>::iterator i = enabled_hosts_.begin(); | |
357 while (i != enabled_hosts_.end()) { | |
358 if (i->second.created >= time) { | |
359 dirtied = true; | |
360 enabled_hosts_.erase(i++); | |
361 } else { | |
362 i++; | |
363 } | |
364 } | |
365 | |
366 if (dirtied) | |
367 DirtyNotify(); | |
368 } | |
369 | |
370 TransportSecurityState::~TransportSecurityState() { | 370 TransportSecurityState::~TransportSecurityState() { |
371 } | 371 } |
372 | 372 |
373 void TransportSecurityState::DirtyNotify() { | 373 void TransportSecurityState::DirtyNotify() { |
374 if (delegate_) | 374 if (delegate_) |
375 delegate_->StateIsDirty(this); | 375 delegate_->StateIsDirty(this); |
376 } | 376 } |
377 | 377 |
378 // static | 378 // static |
379 std::string TransportSecurityState::CanonicaliseHost(const std::string& host) { | 379 std::string TransportSecurityState::CanonicaliseHost(const std::string& host) { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 *include_subdomains = kPreloadedSTS[j].include_subdomains; | 448 *include_subdomains = kPreloadedSTS[j].include_subdomains; |
449 return true; | 449 return true; |
450 } | 450 } |
451 } | 451 } |
452 } | 452 } |
453 | 453 |
454 return false; | 454 return false; |
455 } | 455 } |
456 | 456 |
457 } // namespace | 457 } // namespace |
OLD | NEW |