Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(783)

Side by Side Diff: components/cronet/android/url_request_context_adapter.h

Issue 624443003: Setup ProxyConfigServiceAndroid in Cronet (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Matt's comments Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_ADAPTER_H_ 5 #ifndef COMPONENTS_CRONET_ANDROID_URL_REQUEST_CONTEXT_ADAPTER_H_
6 #define COMPONENTS_CRONET_ANDROID_URL_REQUEST_CONTEXT_ADAPTER_H_ 6 #define COMPONENTS_CRONET_ANDROID_URL_REQUEST_CONTEXT_ADAPTER_H_
7 7
8 #include <queue> 8 #include <queue>
9 #include <string> 9 #include <string>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/location.h" 13 #include "base/location.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
17 #include "base/threading/thread.h" 17 #include "base/threading/thread.h"
18 #include "net/base/net_log.h" 18 #include "net/base/net_log.h"
19 #include "net/base/network_change_notifier.h" 19 #include "net/base/network_change_notifier.h"
20 #include "net/proxy/proxy_config_service.h"
mef 2014/10/15 20:04:55 I think you should be able to forward-declare net:
xunjieli 2014/10/15 20:27:46 Done.
20 #include "net/url_request/url_request_context.h" 21 #include "net/url_request/url_request_context.h"
21 #include "net/url_request/url_request_context_getter.h" 22 #include "net/url_request/url_request_context_getter.h"
22 23
23 namespace net { 24 namespace net {
24 class NetLogLogger; 25 class NetLogLogger;
25 } // namespace net 26 } // namespace net
26 27
27 namespace cronet { 28 namespace cronet {
28 29
29 struct URLRequestContextConfig; 30 struct URLRequestContextConfig;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 const std::string& GetUserAgent(const GURL& url) const; 74 const std::string& GetUserAgent(const GURL& url) const;
74 75
75 // net::URLRequestContextGetter implementation: 76 // net::URLRequestContextGetter implementation:
76 virtual net::URLRequestContext* GetURLRequestContext() override; 77 virtual net::URLRequestContext* GetURLRequestContext() override;
77 virtual scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() 78 virtual scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner()
78 const override; 79 const override;
79 80
80 void StartNetLogToFile(const std::string& file_name); 81 void StartNetLogToFile(const std::string& file_name);
81 void StopNetLog(); 82 void StopNetLog();
82 83
84 // Called on main Java thread to initialize URLRequestContext.
85 void InitRequestContextOnMainThread();
86
83 private: 87 private:
84 scoped_refptr<URLRequestContextAdapterDelegate> delegate_; 88 scoped_refptr<URLRequestContextAdapterDelegate> delegate_;
85 scoped_ptr<net::URLRequestContext> context_; 89 scoped_ptr<net::URLRequestContext> context_;
86 std::string user_agent_; 90 std::string user_agent_;
87 base::Thread* network_thread_; 91 base::Thread* network_thread_;
88 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; 92 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_;
89 scoped_ptr<NetLogObserver> net_log_observer_; 93 scoped_ptr<NetLogObserver> net_log_observer_;
90 scoped_ptr<net::NetLogLogger> net_log_logger_; 94 scoped_ptr<net::NetLogLogger> net_log_logger_;
95 scoped_ptr<net::ProxyConfigService> proxy_config_service_;
96 scoped_ptr<URLRequestContextConfig> config_;
91 97
92 // A queue of tasks that need to be run after context has been initialized. 98 // A queue of tasks that need to be run after context has been initialized.
93 std::queue<RunAfterContextInitTask> tasks_waiting_for_context_; 99 std::queue<RunAfterContextInitTask> tasks_waiting_for_context_;
94 bool is_context_initialized_; 100 bool is_context_initialized_;
95 101
96 virtual ~URLRequestContextAdapter(); 102 virtual ~URLRequestContextAdapter();
97 103
98 // Initializes |context_| on the Network thread. 104 // Initializes |context_| on the Network thread.
99 void InitializeURLRequestContext(scoped_ptr<URLRequestContextConfig> config); 105 void InitRequestContextOnNetworkThread();
100 106
101 // Helper function to start writing NetLog data to file. This should only be 107 // Helper function to start writing NetLog data to file. This should only be
102 // run after context is initialized. 108 // run after context is initialized.
103 void StartNetLogToFileHelper(const std::string& file_name); 109 void StartNetLogToFileHelper(const std::string& file_name);
104 // Helper function to stop writing NetLog data to file. This should only be 110 // Helper function to stop writing NetLog data to file. This should only be
105 // run after context is initialized. 111 // run after context is initialized.
106 void StopNetLogHelper(); 112 void StopNetLogHelper();
107 113
108 DISALLOW_COPY_AND_ASSIGN(URLRequestContextAdapter); 114 DISALLOW_COPY_AND_ASSIGN(URLRequestContextAdapter);
109 }; 115 };
110 116
111 } // namespace cronet 117 } // namespace cronet
112 118
113 #endif // COMPONENTS_CRONET_ANDROID_URL_REQUEST_CONTEXT_ADAPTER_H_ 119 #endif // COMPONENTS_CRONET_ANDROID_URL_REQUEST_CONTEXT_ADAPTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698