OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chrome/browser/extensions/api/gcd_private/privet_v3_context_getter.h" | 5 #include "chrome/browser/extensions/api/gcd_private/privet_v3_context_getter.h" |
6 | 6 |
7 #include "base/atomicops.h" | 7 #include "base/atomicops.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "chrome/common/chrome_content_client.h" | 10 #include "chrome/common/chrome_content_client.h" |
11 #include "chrome/common/chrome_switches.h" | |
12 #include "net/base/net_errors.h" | 11 #include "net/base/net_errors.h" |
13 #include "net/cert/cert_verifier.h" | 12 #include "net/cert/cert_verifier.h" |
14 #include "net/cert/cert_verify_result.h" | 13 #include "net/cert/cert_verify_result.h" |
15 #include "net/cert/x509_certificate.h" | 14 #include "net/cert/x509_certificate.h" |
16 #include "net/url_request/url_request_context.h" | 15 #include "net/url_request/url_request_context.h" |
17 #include "net/url_request/url_request_context_builder.h" | 16 #include "net/url_request/url_request_context_builder.h" |
18 | 17 |
19 namespace extensions { | 18 namespace extensions { |
20 | 19 |
21 namespace { | 20 namespace { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 } | 86 } |
88 | 87 |
89 std::map<std::string, net::SHA256HashValue> fingerprints_; | 88 std::map<std::string, net::SHA256HashValue> fingerprints_; |
90 | 89 |
91 DISALLOW_COPY_AND_ASSIGN(CertVerifier); | 90 DISALLOW_COPY_AND_ASSIGN(CertVerifier); |
92 }; | 91 }; |
93 | 92 |
94 PrivetV3ContextGetter::PrivetV3ContextGetter( | 93 PrivetV3ContextGetter::PrivetV3ContextGetter( |
95 const scoped_refptr<base::SingleThreadTaskRunner>& net_task_runner) | 94 const scoped_refptr<base::SingleThreadTaskRunner>& net_task_runner) |
96 : net_task_runner_(net_task_runner), weak_ptr_factory_(this) { | 95 : net_task_runner_(net_task_runner), weak_ptr_factory_(this) { |
97 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | |
98 switches::kEnablePrivetV3)); | |
99 } | 96 } |
100 | 97 |
101 net::URLRequestContext* PrivetV3ContextGetter::GetURLRequestContext() { | 98 net::URLRequestContext* PrivetV3ContextGetter::GetURLRequestContext() { |
102 InitOnNetThread(); | 99 InitOnNetThread(); |
103 return context_.get(); | 100 return context_.get(); |
104 } | 101 } |
105 | 102 |
106 scoped_refptr<base::SingleThreadTaskRunner> | 103 scoped_refptr<base::SingleThreadTaskRunner> |
107 PrivetV3ContextGetter::GetNetworkTaskRunner() const { | 104 PrivetV3ContextGetter::GetNetworkTaskRunner() const { |
108 return net_task_runner_; | 105 return net_task_runner_; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 const net::SHA256HashValue& certificate_fingerprint) { | 139 const net::SHA256HashValue& certificate_fingerprint) { |
143 InitOnNetThread(); | 140 InitOnNetThread(); |
144 cert_verifier_->AddPairedHost(host, certificate_fingerprint); | 141 cert_verifier_->AddPairedHost(host, certificate_fingerprint); |
145 } | 142 } |
146 | 143 |
147 PrivetV3ContextGetter::~PrivetV3ContextGetter() { | 144 PrivetV3ContextGetter::~PrivetV3ContextGetter() { |
148 DCHECK(net_task_runner_->BelongsToCurrentThread()); | 145 DCHECK(net_task_runner_->BelongsToCurrentThread()); |
149 } | 146 } |
150 | 147 |
151 } // namespace extensions | 148 } // namespace extensions |
OLD | NEW |