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

Side by Side Diff: net/base/transport_security_state.cc

Issue 6248026: Rename Real* to Double* in values.* and dependent files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More renames Created 9 years, 10 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
OLDNEW
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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 258
259 return out; 259 return out;
260 } 260 }
261 261
262 bool TransportSecurityState::Serialise(std::string* output) { 262 bool TransportSecurityState::Serialise(std::string* output) {
263 DictionaryValue toplevel; 263 DictionaryValue toplevel;
264 for (std::map<std::string, DomainState>::const_iterator 264 for (std::map<std::string, DomainState>::const_iterator
265 i = enabled_hosts_.begin(); i != enabled_hosts_.end(); ++i) { 265 i = enabled_hosts_.begin(); i != enabled_hosts_.end(); ++i) {
266 DictionaryValue* state = new DictionaryValue; 266 DictionaryValue* state = new DictionaryValue;
267 state->SetBoolean("include_subdomains", i->second.include_subdomains); 267 state->SetBoolean("include_subdomains", i->second.include_subdomains);
268 state->SetReal("created", i->second.created.ToDoubleT()); 268 state->SetDouble("created", i->second.created.ToDoubleT());
269 state->SetReal("expiry", i->second.expiry.ToDoubleT()); 269 state->SetDouble("expiry", i->second.expiry.ToDoubleT());
270 270
271 switch (i->second.mode) { 271 switch (i->second.mode) {
272 case DomainState::MODE_STRICT: 272 case DomainState::MODE_STRICT:
273 state->SetString("mode", "strict"); 273 state->SetString("mode", "strict");
274 break; 274 break;
275 case DomainState::MODE_OPPORTUNISTIC: 275 case DomainState::MODE_OPPORTUNISTIC:
276 state->SetString("mode", "opportunistic"); 276 state->SetString("mode", "opportunistic");
277 break; 277 break;
278 case DomainState::MODE_SPDY_ONLY: 278 case DomainState::MODE_SPDY_ONLY:
279 state->SetString("mode", "spdy-only"); 279 state->SetString("mode", "spdy-only");
(...skipping 30 matching lines...) Expand all
310 if (!dict_value->GetDictionaryWithoutPathExpansion(*i, &state)) 310 if (!dict_value->GetDictionaryWithoutPathExpansion(*i, &state))
311 continue; 311 continue;
312 312
313 bool include_subdomains; 313 bool include_subdomains;
314 std::string mode_string; 314 std::string mode_string;
315 double created; 315 double created;
316 double expiry; 316 double expiry;
317 317
318 if (!state->GetBoolean("include_subdomains", &include_subdomains) || 318 if (!state->GetBoolean("include_subdomains", &include_subdomains) ||
319 !state->GetString("mode", &mode_string) || 319 !state->GetString("mode", &mode_string) ||
320 !state->GetReal("expiry", &expiry)) { 320 !state->GetDouble("expiry", &expiry)) {
321 continue; 321 continue;
322 } 322 }
323 323
324 DomainState::Mode mode; 324 DomainState::Mode mode;
325 if (mode_string == "strict") { 325 if (mode_string == "strict") {
326 mode = DomainState::MODE_STRICT; 326 mode = DomainState::MODE_STRICT;
327 } else if (mode_string == "opportunistic") { 327 } else if (mode_string == "opportunistic") {
328 mode = DomainState::MODE_OPPORTUNISTIC; 328 mode = DomainState::MODE_OPPORTUNISTIC;
329 } else if (mode_string == "spdy-only") { 329 } else if (mode_string == "spdy-only") {
330 mode = DomainState::MODE_SPDY_ONLY; 330 mode = DomainState::MODE_SPDY_ONLY;
331 } else { 331 } else {
332 LOG(WARNING) << "Unknown TransportSecurityState mode string found: " 332 LOG(WARNING) << "Unknown TransportSecurityState mode string found: "
333 << mode_string; 333 << mode_string;
334 continue; 334 continue;
335 } 335 }
336 336
337 base::Time expiry_time = base::Time::FromDoubleT(expiry); 337 base::Time expiry_time = base::Time::FromDoubleT(expiry);
338 base::Time created_time; 338 base::Time created_time;
339 if (state->GetReal("created", &created)) { 339 if (state->GetDouble("created", &created)) {
340 created_time = base::Time::FromDoubleT(created); 340 created_time = base::Time::FromDoubleT(created);
341 } else { 341 } else {
342 // We're migrating an old entry with no creation date. Make sure we 342 // We're migrating an old entry with no creation date. Make sure we
343 // write the new date back in a reasonable time frame. 343 // write the new date back in a reasonable time frame.
344 dirtied = true; 344 dirtied = true;
345 created_time = base::Time::Now(); 345 created_time = base::Time::Now();
346 } 346 }
347 347
348 if (expiry_time <= current_time) { 348 if (expiry_time <= current_time) {
349 // Make sure we dirty the state if we drop an entry. 349 // Make sure we dirty the state if we drop an entry.
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 *include_subdomains = kPreloadedSTS[j].include_subdomains; 450 *include_subdomains = kPreloadedSTS[j].include_subdomains;
451 return true; 451 return true;
452 } 452 }
453 } 453 }
454 } 454 }
455 455
456 return false; 456 return false;
457 } 457 }
458 458
459 } // namespace 459 } // namespace
OLDNEW
« chrome/common/json_value_serializer_unittest.cc ('K') | « media/base/media_format.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698