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

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

Issue 7661009: base: Add Is* functions to Value class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix nat_policy.cc Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/base64.h" 5 #include "base/base64.h"
6 #include "base/json/json_reader.h" 6 #include "base/json/json_reader.h"
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "crypto/sha2.h" 10 #include "crypto/sha2.h"
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 return NULL; 526 return NULL;
527 527
528 const base::StringPiece description_bytes(data->data(), description_len); 528 const base::StringPiece description_bytes(data->data(), description_len);
529 data->remove_prefix(description_len); 529 data->remove_prefix(description_len);
530 530
531 scoped_ptr<Value> description(base::JSONReader::Read( 531 scoped_ptr<Value> description(base::JSONReader::Read(
532 description_bytes.as_string(), true /* allow trailing comma */)); 532 description_bytes.as_string(), true /* allow trailing comma */));
533 if (description.get() == NULL) 533 if (description.get() == NULL)
534 return NULL; 534 return NULL;
535 535
536 if (!description->IsType(Value::TYPE_DICTIONARY)) 536 if (!description->IsDictionary())
537 return NULL; 537 return NULL;
538 return reinterpret_cast<DictionaryValue*>(description.release()); 538 return reinterpret_cast<DictionaryValue*>(description.release());
539 } 539 }
540 540
541 // CRLFilterFromHeader constructs a CRLFilter from the bytes of a header 541 // CRLFilterFromHeader constructs a CRLFilter from the bytes of a header
542 // structures. The header is JSON. See above for details of the keys. 542 // structures. The header is JSON. See above for details of the keys.
543 // 543 //
544 // static 544 // static
545 CRLFilter* CRLFilter::CRLFilterFromHeader(base::StringPiece header_bytes) { 545 CRLFilter* CRLFilter::CRLFilterFromHeader(base::StringPiece header_bytes) {
546 scoped_ptr<Value> header(base::JSONReader::Read( 546 scoped_ptr<Value> header(base::JSONReader::Read(
547 header_bytes.as_string(), 547 header_bytes.as_string(),
548 true /* allow trailing comma */)); 548 true /* allow trailing comma */));
549 if (header.get() == NULL) 549 if (header.get() == NULL)
550 return NULL; 550 return NULL;
551 551
552 if (!header->IsType(Value::TYPE_DICTIONARY)) 552 if (!header->IsDictionary())
553 return NULL; 553 return NULL;
554 DictionaryValue* header_dict = 554 DictionaryValue* header_dict =
555 reinterpret_cast<DictionaryValue*>(header.get()); 555 reinterpret_cast<DictionaryValue*>(header.get());
556 int version; 556 int version;
557 if (!header_dict->GetInteger("Version", &version) || 557 if (!header_dict->GetInteger("Version", &version) ||
558 version != 0) { 558 version != 0) {
559 return NULL; 559 return NULL;
560 } 560 }
561 561
562 double not_before, not_after, max_range, num_entries; 562 double not_before, not_after, max_range, num_entries;
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 return ret; 869 return ret;
870 } 870 }
871 871
872 std::string CRLFilter::SHA256() const { 872 std::string CRLFilter::SHA256() const {
873 std::string s = header_bytes_; 873 std::string s = header_bytes_;
874 s += gcs_bytes_; 874 s += gcs_bytes_;
875 return crypto::SHA256HashString(s); 875 return crypto::SHA256HashString(s);
876 } 876 }
877 877
878 } // namespace net 878 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698