| 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_PEER_H_ |
| 6 #define COMPONENTS_CRONET_ANDROID_URL_REQUEST_CONTEXT_PEER_H_ | 6 #define COMPONENTS_CRONET_ANDROID_URL_REQUEST_CONTEXT_PEER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 class NetLogLogger; | 21 class NetLogLogger; |
| 22 } // namespace net | 22 } // namespace net |
| 23 | 23 |
| 24 namespace cronet { | 24 namespace cronet { |
| 25 | 25 |
| 26 struct URLRequestContextConfig; | 26 struct URLRequestContextConfig; |
| 27 | 27 |
| 28 // Implementation of the Chromium NetLog observer interface. | 28 // Implementation of the Chromium NetLog observer interface. |
| 29 class NetLogObserver : public net::NetLog::ThreadSafeObserver { | 29 class NetLogObserver : public net::NetLog::ThreadSafeObserver { |
| 30 public: | 30 public: |
| 31 explicit NetLogObserver(int log_level) { log_level_ = log_level; } | 31 explicit NetLogObserver() {} |
| 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 int log_level_; | |
| 39 | |
| 40 DISALLOW_COPY_AND_ASSIGN(NetLogObserver); | 38 DISALLOW_COPY_AND_ASSIGN(NetLogObserver); |
| 41 }; | 39 }; |
| 42 | 40 |
| 43 // Fully configured |URLRequestContext|. | 41 // Fully configured |URLRequestContext|. |
| 44 class URLRequestContextPeer : public net::URLRequestContextGetter { | 42 class URLRequestContextPeer : public net::URLRequestContextGetter { |
| 45 public: | 43 public: |
| 46 class URLRequestContextPeerDelegate | 44 class URLRequestContextPeerDelegate |
| 47 : public base::RefCountedThreadSafe<URLRequestContextPeerDelegate> { | 45 : public base::RefCountedThreadSafe<URLRequestContextPeerDelegate> { |
| 48 public: | 46 public: |
| 49 virtual void OnContextInitialized(URLRequestContextPeer* context) = 0; | 47 virtual void OnContextInitialized(URLRequestContextPeer* context) = 0; |
| 50 | 48 |
| 51 protected: | 49 protected: |
| 52 friend class base::RefCountedThreadSafe<URLRequestContextPeerDelegate>; | 50 friend class base::RefCountedThreadSafe<URLRequestContextPeerDelegate>; |
| 53 | 51 |
| 54 virtual ~URLRequestContextPeerDelegate() {} | 52 virtual ~URLRequestContextPeerDelegate() {} |
| 55 }; | 53 }; |
| 56 | 54 |
| 57 URLRequestContextPeer(URLRequestContextPeerDelegate* delegate, | 55 URLRequestContextPeer(URLRequestContextPeerDelegate* delegate, |
| 58 std::string user_agent, | 56 std::string user_agent); |
| 59 int log_level); | |
| 60 void Initialize(scoped_ptr<URLRequestContextConfig> config); | 57 void Initialize(scoped_ptr<URLRequestContextConfig> config); |
| 61 | 58 |
| 62 const std::string& GetUserAgent(const GURL& url) const; | 59 const std::string& GetUserAgent(const GURL& url) const; |
| 63 | 60 |
| 64 int logging_level() const { return logging_level_; } | |
| 65 | |
| 66 // net::URLRequestContextGetter implementation: | 61 // net::URLRequestContextGetter implementation: |
| 67 virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE; | 62 virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE; |
| 68 virtual scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() | 63 virtual scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() |
| 69 const OVERRIDE; | 64 const OVERRIDE; |
| 70 | 65 |
| 71 void StartNetLogToFile(const std::string& file_name); | 66 void StartNetLogToFile(const std::string& file_name); |
| 72 void StopNetLog(); | 67 void StopNetLog(); |
| 73 | 68 |
| 74 private: | 69 private: |
| 75 scoped_refptr<URLRequestContextPeerDelegate> delegate_; | 70 scoped_refptr<URLRequestContextPeerDelegate> delegate_; |
| 76 scoped_ptr<net::URLRequestContext> context_; | 71 scoped_ptr<net::URLRequestContext> context_; |
| 77 int logging_level_; | |
| 78 std::string user_agent_; | 72 std::string user_agent_; |
| 79 base::Thread* network_thread_; | 73 base::Thread* network_thread_; |
| 80 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; | 74 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; |
| 81 scoped_ptr<NetLogObserver> net_log_observer_; | 75 scoped_ptr<NetLogObserver> net_log_observer_; |
| 82 scoped_ptr<net::NetLogLogger> net_log_logger_; | 76 scoped_ptr<net::NetLogLogger> net_log_logger_; |
| 83 | 77 |
| 84 virtual ~URLRequestContextPeer(); | 78 virtual ~URLRequestContextPeer(); |
| 85 | 79 |
| 86 // Initializes |context_| on the IO thread. | 80 // Initializes |context_| on the IO thread. |
| 87 void InitializeURLRequestContext(scoped_ptr<URLRequestContextConfig> config); | 81 void InitializeURLRequestContext(scoped_ptr<URLRequestContextConfig> config); |
| 88 | 82 |
| 89 DISALLOW_COPY_AND_ASSIGN(URLRequestContextPeer); | 83 DISALLOW_COPY_AND_ASSIGN(URLRequestContextPeer); |
| 90 }; | 84 }; |
| 91 | 85 |
| 92 } // namespace cronet | 86 } // namespace cronet |
| 93 | 87 |
| 94 #endif // COMPONENTS_CRONET_ANDROID_URL_REQUEST_CONTEXT_PEER_H_ | 88 #endif // COMPONENTS_CRONET_ANDROID_URL_REQUEST_CONTEXT_PEER_H_ |
| OLD | NEW |