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

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

Issue 937513003: Add Data Saver support to Cronet (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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_CRONET_URL_REQUEST_CONTEXT_ADAPTER_H_ 5 #ifndef COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_CONTEXT_ADAPTER_H_
6 #define COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_CONTEXT_ADAPTER_H_ 6 #define COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_CONTEXT_ADAPTER_H_
7 7
8 #include <jni.h> 8 #include <jni.h>
9 9
10 #include <queue> 10 #include <queue>
11 #include <string> 11 #include <string>
12 12
13 #include "base/android/scoped_java_ref.h" 13 #include "base/android/scoped_java_ref.h"
14 #include "base/callback.h" 14 #include "base/callback.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
17 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
18 #include "base/prefs/pref_service.h"
18 #include "base/threading/thread.h" 19 #include "base/threading/thread.h"
20 #include "net/base/net_log.h"
21 #include "net/base/network_change_notifier.h"
19 22
20 namespace base { 23 namespace base {
21 class SingleThreadTaskRunner; 24 class SingleThreadTaskRunner;
22 } // namespace base 25 } // namespace base
23 26
27 namespace data_reduction_proxy {
28 class DataReductionProxyIOData;
29 class DataReductionProxySettings;
30 }
31
24 namespace net { 32 namespace net {
33 class NetLog;
25 class NetLogLogger; 34 class NetLogLogger;
26 class URLRequestContext; 35 class URLRequestContext;
36 class URLRequestContextGetter;
27 class ProxyConfigService; 37 class ProxyConfigService;
28 } // namespace net 38 } // namespace net
29 39
30 namespace cronet { 40 namespace cronet {
31 41
32 struct URLRequestContextConfig; 42 struct URLRequestContextConfig;
33 43
34 bool CronetUrlRequestContextAdapterRegisterJni(JNIEnv* env); 44 bool CronetUrlRequestContextAdapterRegisterJni(JNIEnv* env);
35 45
36 // Adapter between Java CronetUrlRequestContext and net::URLRequestContext. 46 // Adapter between Java CronetUrlRequestContext and net::URLRequestContext.
(...skipping 26 matching lines...) Expand all
63 73
64 // Default net::LOAD flags used to create requests. 74 // Default net::LOAD flags used to create requests.
65 int default_load_flags() const { return default_load_flags_; } 75 int default_load_flags() const { return default_load_flags_; }
66 76
67 // Called on main Java thread to initialize URLRequestContext. 77 // Called on main Java thread to initialize URLRequestContext.
68 void InitRequestContextOnMainThread(); 78 void InitRequestContextOnMainThread();
69 79
70 private: 80 private:
71 // Initializes |context_| on the Network thread. 81 // Initializes |context_| on the Network thread.
72 void InitializeOnNetworkThread(scoped_ptr<URLRequestContextConfig> config, 82 void InitializeOnNetworkThread(scoped_ptr<URLRequestContextConfig> config,
83 scoped_ptr<net::NetLog> net_log,
73 const base::android::ScopedJavaGlobalRef< 84 const base::android::ScopedJavaGlobalRef<
74 jobject>& jcronet_url_request_context); 85 jobject>& jcronet_url_request_context);
75 86
87 void DestroyOnMainThread();
88
76 // Runs a task that might depend on the context being initialized. 89 // Runs a task that might depend on the context being initialized.
77 // This method should only be run on the network thread. 90 // This method should only be run on the network thread.
78 void RunTaskAfterContextInitOnNetworkThread( 91 void RunTaskAfterContextInitOnNetworkThread(
79 const base::Closure& task_to_run_after_context_init); 92 const base::Closure& task_to_run_after_context_init);
80 93
81 scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() const; 94 scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() const;
82 95
96 void InitializeDataReductionProxyOnMainThread(bool enable);
97
83 void StartNetLogToFileOnNetworkThread(const std::string& file_name); 98 void StartNetLogToFileOnNetworkThread(const std::string& file_name);
84 99
85 void StopNetLogOnNetworkThread(); 100 void StopNetLogOnNetworkThread();
86 101
87 // Network thread is owned by |this|, but is destroyed from java thread. 102 // Network thread is owned by |this|, but is destroyed from java thread.
88 base::Thread* network_thread_; 103 base::Thread* network_thread_;
89 // |net_log_logger_| and |context_| should only be accessed on network thread. 104 // |net_log_logger_| and |context_| should only be accessed on network thread.
90 scoped_ptr<net::NetLogLogger> net_log_logger_; 105 scoped_ptr<net::NetLogLogger> net_log_logger_;
91 scoped_ptr<net::URLRequestContext> context_; 106 scoped_ptr<net::URLRequestContext> context_;
92 scoped_ptr<net::ProxyConfigService> proxy_config_service_; 107 scoped_ptr<net::ProxyConfigService> proxy_config_service_;
93 108
94 // Context config is only valid untng context is initialized. 109 // Context config is only valid untng context is initialized.
95 scoped_ptr<URLRequestContextConfig> context_config_; 110 scoped_ptr<URLRequestContextConfig> context_config_;
96 111
97 // A queue of tasks that need to be run after context has been initialized. 112 // A queue of tasks that need to be run after context has been initialized.
98 std::queue<base::Closure> tasks_waiting_for_context_; 113 std::queue<base::Closure> tasks_waiting_for_context_;
99 bool is_context_initialized_; 114 bool is_context_initialized_;
100 int default_load_flags_; 115 int default_load_flags_;
116 scoped_ptr<PrefService> prefs_;
117 scoped_refptr<base::MessageLoopProxy> ui_task_runner_;
118 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
119
120 scoped_ptr<data_reduction_proxy::DataReductionProxyIOData>
121 data_reduction_proxy_io_data_;
122 scoped_ptr<data_reduction_proxy::DataReductionProxySettings>
123 data_reduction_proxy_settings_;
124
101 125
102 DISALLOW_COPY_AND_ASSIGN(CronetURLRequestContextAdapter); 126 DISALLOW_COPY_AND_ASSIGN(CronetURLRequestContextAdapter);
103 }; 127 };
104 128
105 } // namespace cronet 129 } // namespace cronet
106 130
107 #endif // COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_CONTEXT_ADAPTER_H_ 131 #endif // COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_CONTEXT_ADAPTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698