OLD | NEW |
1 // Copyright 2015 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 #ifndef CHROME_BROWSER_EXTENSIONS_API_GCD_PRIVATE_PRIVET_V3_CONTEXT_GETTER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_GCD_PRIVATE_PRIVET_V3_CONTEXT_GETTER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_GCD_PRIVATE_PRIVET_V3_CONTEXT_GETTER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_GCD_PRIVATE_PRIVET_V3_CONTEXT_GETTER_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
11 #include "net/url_request/url_request_context_getter.h" | 11 #include "net/url_request/url_request_context_getter.h" |
12 | 12 |
13 namespace base { | 13 namespace base { |
14 class SingleThreadTaskRunner; | 14 class SingleThreadTaskRunner; |
15 } | 15 } |
16 | 16 |
17 namespace net { | 17 namespace net { |
18 class CertVerifier; | 18 class CertVerifier; |
19 class URLRequestContext; | 19 class URLRequestContext; |
20 struct SHA256HashValue; | 20 struct SHA256HashValue; |
21 } | 21 } |
22 | 22 |
23 namespace extensions { | 23 namespace extensions { |
24 | 24 |
25 class PrivetV3ContextGetter : public net::URLRequestContextGetter { | 25 class PrivetV3ContextGetter : public net::URLRequestContextGetter { |
26 public: | 26 public: |
27 PrivetV3ContextGetter( | 27 PrivetV3ContextGetter( |
28 const scoped_refptr<base::SingleThreadTaskRunner>& net_task_runner, | 28 const scoped_refptr<base::SingleThreadTaskRunner>& net_task_runner); |
29 const net::SHA256HashValue& certificate_fingerprint); | |
30 | 29 |
31 net::URLRequestContext* GetURLRequestContext() override; | 30 net::URLRequestContext* GetURLRequestContext() override; |
32 | 31 |
33 scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() | 32 scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() |
34 const override; | 33 const override; |
35 | 34 |
| 35 void AddPairedHost(const std::string& host, |
| 36 const net::SHA256HashValue& certificate_fingerprint, |
| 37 const base::Closure& callback); |
| 38 |
36 protected: | 39 protected: |
37 ~PrivetV3ContextGetter() override; | 40 ~PrivetV3ContextGetter() override; |
38 | 41 |
39 private: | 42 private: |
40 scoped_ptr<net::CertVerifier> verifier_; | 43 class CertVerifier; |
| 44 |
| 45 void InitOnNetThread(); |
| 46 void AddPairedHostOnNetThread( |
| 47 const std::string& host, |
| 48 const net::SHA256HashValue& certificate_fingerprint); |
| 49 |
| 50 // Owned by context_ |
| 51 CertVerifier* cert_verifier_ = nullptr; |
41 scoped_ptr<net::URLRequestContext> context_; | 52 scoped_ptr<net::URLRequestContext> context_; |
| 53 |
42 scoped_refptr<base::SingleThreadTaskRunner> net_task_runner_; | 54 scoped_refptr<base::SingleThreadTaskRunner> net_task_runner_; |
43 | 55 |
| 56 base::WeakPtrFactory<PrivetV3ContextGetter> weak_ptr_factory_; |
| 57 |
44 DISALLOW_COPY_AND_ASSIGN(PrivetV3ContextGetter); | 58 DISALLOW_COPY_AND_ASSIGN(PrivetV3ContextGetter); |
45 }; | 59 }; |
46 | 60 |
47 } // namespace extensions | 61 } // namespace extensions |
48 | 62 |
49 #endif // CHROME_BROWSER_EXTENSIONS_API_GCD_PRIVATE_PRIVET_V3_CONTEXT_GETTER_H_ | 63 #endif // CHROME_BROWSER_EXTENSIONS_API_GCD_PRIVATE_PRIVET_V3_CONTEXT_GETTER_H_ |
OLD | NEW |