OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 COMPONENTS_CRONET_ANDROID_URL_REQUEST_CONTEXT_PEER_H_ | 5 #ifndef COMPONENTS_CRONET_ANDROID_URL_REQUEST_CONTEXT_ADAPTER_H_ |
6 #define COMPONENTS_CRONET_ANDROID_URL_REQUEST_CONTEXT_PEER_H_ | 6 #define COMPONENTS_CRONET_ANDROID_URL_REQUEST_CONTEXT_ADAPTER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/threading/thread.h" | 14 #include "base/threading/thread.h" |
15 #include "net/base/net_log.h" | 15 #include "net/base/net_log.h" |
16 #include "net/base/network_change_notifier.h" | 16 #include "net/base/network_change_notifier.h" |
(...skipping 15 matching lines...) Expand all Loading... |
32 | 32 |
33 virtual ~NetLogObserver() {} | 33 virtual ~NetLogObserver() {} |
34 | 34 |
35 virtual void OnAddEntry(const net::NetLog::Entry& entry) OVERRIDE; | 35 virtual void OnAddEntry(const net::NetLog::Entry& entry) OVERRIDE; |
36 | 36 |
37 private: | 37 private: |
38 DISALLOW_COPY_AND_ASSIGN(NetLogObserver); | 38 DISALLOW_COPY_AND_ASSIGN(NetLogObserver); |
39 }; | 39 }; |
40 | 40 |
41 // Fully configured |URLRequestContext|. | 41 // Fully configured |URLRequestContext|. |
42 class URLRequestContextPeer : public net::URLRequestContextGetter { | 42 class URLRequestContextAdapter : public net::URLRequestContextGetter { |
43 public: | 43 public: |
44 class URLRequestContextPeerDelegate | 44 class URLRequestContextAdapterDelegate |
45 : public base::RefCountedThreadSafe<URLRequestContextPeerDelegate> { | 45 : public base::RefCountedThreadSafe<URLRequestContextAdapterDelegate> { |
46 public: | 46 public: |
47 virtual void OnContextInitialized(URLRequestContextPeer* context) = 0; | 47 virtual void OnContextInitialized(URLRequestContextAdapter* context) = 0; |
48 | 48 |
49 protected: | 49 protected: |
50 friend class base::RefCountedThreadSafe<URLRequestContextPeerDelegate>; | 50 friend class base::RefCountedThreadSafe<URLRequestContextAdapterDelegate>; |
51 | 51 |
52 virtual ~URLRequestContextPeerDelegate() {} | 52 virtual ~URLRequestContextAdapterDelegate() {} |
53 }; | 53 }; |
54 | 54 |
55 URLRequestContextPeer(URLRequestContextPeerDelegate* delegate, | 55 URLRequestContextAdapter(URLRequestContextAdapterDelegate* delegate, |
56 std::string user_agent); | 56 std::string user_agent); |
57 void Initialize(scoped_ptr<URLRequestContextConfig> config); | 57 void Initialize(scoped_ptr<URLRequestContextConfig> config); |
58 | 58 |
59 const std::string& GetUserAgent(const GURL& url) const; | 59 const std::string& GetUserAgent(const GURL& url) const; |
60 | 60 |
61 // net::URLRequestContextGetter implementation: | 61 // net::URLRequestContextGetter implementation: |
62 virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE; | 62 virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE; |
63 virtual scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() | 63 virtual scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() |
64 const OVERRIDE; | 64 const OVERRIDE; |
65 | 65 |
66 void StartNetLogToFile(const std::string& file_name); | 66 void StartNetLogToFile(const std::string& file_name); |
67 void StopNetLog(); | 67 void StopNetLog(); |
68 | 68 |
69 private: | 69 private: |
70 scoped_refptr<URLRequestContextPeerDelegate> delegate_; | 70 scoped_refptr<URLRequestContextAdapterDelegate> delegate_; |
71 scoped_ptr<net::URLRequestContext> context_; | 71 scoped_ptr<net::URLRequestContext> context_; |
72 std::string user_agent_; | 72 std::string user_agent_; |
73 base::Thread* network_thread_; | 73 base::Thread* network_thread_; |
74 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; | 74 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; |
75 scoped_ptr<NetLogObserver> net_log_observer_; | 75 scoped_ptr<NetLogObserver> net_log_observer_; |
76 scoped_ptr<net::NetLogLogger> net_log_logger_; | 76 scoped_ptr<net::NetLogLogger> net_log_logger_; |
77 | 77 |
78 virtual ~URLRequestContextPeer(); | 78 virtual ~URLRequestContextAdapter(); |
79 | 79 |
80 // Initializes |context_| on the IO thread. | 80 // Initializes |context_| on the IO thread. |
81 void InitializeURLRequestContext(scoped_ptr<URLRequestContextConfig> config); | 81 void InitializeURLRequestContext(scoped_ptr<URLRequestContextConfig> config); |
82 | 82 |
83 DISALLOW_COPY_AND_ASSIGN(URLRequestContextPeer); | 83 DISALLOW_COPY_AND_ASSIGN(URLRequestContextAdapter); |
84 }; | 84 }; |
85 | 85 |
86 } // namespace cronet | 86 } // namespace cronet |
87 | 87 |
88 #endif // COMPONENTS_CRONET_ANDROID_URL_REQUEST_CONTEXT_PEER_H_ | 88 #endif // COMPONENTS_CRONET_ANDROID_URL_REQUEST_CONTEXT_ADAPTER_H_ |
OLD | NEW |