OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_CONTEXT_ADAPTER_H_ | |
6 #define COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_CONTEXT_ADAPTER_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/callback.h" | |
11 #include "base/macros.h" | |
12 #include "base/memory/ref_counted.h" | |
13 #include "base/memory/scoped_ptr.h" | |
14 #include "base/threading/thread.h" | |
15 #include "net/base/net_log.h" | |
16 #include "net/base/network_change_notifier.h" | |
17 | |
18 namespace base { | |
19 class SingleThreadTaskRunner; | |
20 } // namespace base | |
21 | |
22 namespace net { | |
23 class NetLogLogger; | |
24 class URLRequestContext; | |
25 } // namespace net | |
26 | |
27 namespace cronet { | |
28 | |
29 struct URLRequestContextConfig; | |
30 | |
31 // Adapter between Java CronetUrlRequestContext and net::URLRequestContext. | |
32 class CronetURLRequestContextAdapter { | |
33 public: | |
34 CronetURLRequestContextAdapter(); | |
35 | |
36 ~CronetURLRequestContextAdapter(); | |
37 | |
38 void Initialize(scoped_ptr<URLRequestContextConfig> config, | |
39 const base::Closure& java_init_network_thread); | |
40 | |
41 // Releases all resources for the request context and deletes the object. | |
mmenke
2014/11/07 15:19:09
Worth mentioning it blocks until the thread is des
mef
2014/11/07 16:22:26
Done.
| |
42 void Destroy(); | |
43 | |
44 net::URLRequestContext* GetURLRequestContext(); | |
45 | |
46 scoped_refptr<base::SingleThreadTaskRunner> | |
47 GetNetworkTaskRunner() const; | |
mmenke
2014/11/07 15:19:09
If this doesn't fit on one line, I think generally
mef
2014/11/07 16:22:26
Hmm, fits now. Not sure why was like that.
| |
48 | |
49 void StartNetLogToFile(const std::string& file_name); | |
50 | |
51 void StopNetLog(); | |
52 | |
53 private: | |
54 // Network thread is owned by |this|, but is destroyed from java thread. | |
55 base::Thread* network_thread_; | |
56 // |net_log_logger_| and |context_| should only be accessed on network thread. | |
57 scoped_ptr<net::NetLogLogger> net_log_logger_; | |
58 scoped_ptr<net::URLRequestContext> context_; | |
59 | |
60 // Initializes |context_| on the Network thread. | |
61 void InitializeOnNetworkThread( | |
62 scoped_ptr<URLRequestContextConfig> config, | |
63 const base::Closure& java_init_network_thread); | |
64 void StartNetLogToFileOnNetworkThread(const std::string& file_name); | |
65 void StopNetLogOnNetworkThread(); | |
66 | |
67 DISALLOW_COPY_AND_ASSIGN(CronetURLRequestContextAdapter); | |
68 }; | |
69 | |
70 } // namespace cronet | |
71 | |
72 #endif // COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_CONTEXT_ADAPTER_H_ | |
OLD | NEW |