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

Side by Side Diff: net/cert/test_root_certs.cc

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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
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 #include "net/cert/test_root_certs.h" 5 #include "net/cert/test_root_certs.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "net/cert/x509_certificate.h" 12 #include "net/cert/x509_certificate.h"
13 13
14 namespace net { 14 namespace net {
15 15
16 namespace { 16 namespace {
17 17
18 bool g_has_instance = false; 18 bool g_has_instance = false;
19 19
20 base::LazyInstance<TestRootCerts>::Leaky 20 base::LazyInstance<TestRootCerts>::Leaky g_test_root_certs =
21 g_test_root_certs = LAZY_INSTANCE_INITIALIZER; 21 LAZY_INSTANCE_INITIALIZER;
22 22
23 CertificateList LoadCertificates(const base::FilePath& filename) { 23 CertificateList LoadCertificates(const base::FilePath& filename) {
24 std::string raw_cert; 24 std::string raw_cert;
25 if (!base::ReadFileToString(filename, &raw_cert)) { 25 if (!base::ReadFileToString(filename, &raw_cert)) {
26 LOG(ERROR) << "Can't load certificate " << filename.value(); 26 LOG(ERROR) << "Can't load certificate " << filename.value();
27 return CertificateList(); 27 return CertificateList();
28 } 28 }
29 29
30 return X509Certificate::CreateCertificateListFromBytes( 30 return X509Certificate::CreateCertificateListFromBytes(
31 raw_cert.data(), raw_cert.length(), X509Certificate::FORMAT_AUTO); 31 raw_cert.data(), raw_cert.length(), X509Certificate::FORMAT_AUTO);
(...skipping 16 matching lines...) Expand all
48 return false; 48 return false;
49 49
50 return Add(root_certs.front().get()); 50 return Add(root_certs.front().get());
51 } 51 }
52 52
53 TestRootCerts::TestRootCerts() { 53 TestRootCerts::TestRootCerts() {
54 Init(); 54 Init();
55 g_has_instance = true; 55 g_has_instance = true;
56 } 56 }
57 57
58 ScopedTestRoot::ScopedTestRoot() {} 58 ScopedTestRoot::ScopedTestRoot() {
59 }
59 60
60 ScopedTestRoot::ScopedTestRoot(X509Certificate* cert) { 61 ScopedTestRoot::ScopedTestRoot(X509Certificate* cert) {
61 Reset(cert); 62 Reset(cert);
62 } 63 }
63 64
64 ScopedTestRoot::~ScopedTestRoot() { 65 ScopedTestRoot::~ScopedTestRoot() {
65 Reset(NULL); 66 Reset(NULL);
66 } 67 }
67 68
68 void ScopedTestRoot::Reset(X509Certificate* cert) { 69 void ScopedTestRoot::Reset(X509Certificate* cert) {
69 if (cert_.get()) 70 if (cert_.get())
70 TestRootCerts::GetInstance()->Clear(); 71 TestRootCerts::GetInstance()->Clear();
71 if (cert) 72 if (cert)
72 TestRootCerts::GetInstance()->Add(cert); 73 TestRootCerts::GetInstance()->Add(cert);
73 cert_ = cert; 74 cert_ = cert;
74 } 75 }
75 76
76 } // namespace net 77 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698