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

Side by Side Diff: chromecast/browser/cast_browser_process.cc

Issue 2647323010: [Chromecast] Add proxy server support to chromecast (Closed)
Patch Set: Fix unittest failure Created 3 years, 10 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 #include "chromecast/browser/cast_browser_process.h" 5 #include "chromecast/browser/cast_browser_process.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
11 #include "chromecast/base/metrics/cast_metrics_helper.h" 11 #include "chromecast/base/metrics/cast_metrics_helper.h"
12 #include "chromecast/browser/cast_browser_context.h" 12 #include "chromecast/browser/cast_browser_context.h"
13 #include "chromecast/browser/cast_resource_dispatcher_host_delegate.h" 13 #include "chromecast/browser/cast_resource_dispatcher_host_delegate.h"
14 #include "chromecast/browser/devtools/remote_debugging_server.h" 14 #include "chromecast/browser/devtools/remote_debugging_server.h"
15 #include "chromecast/browser/metrics/cast_metrics_service_client.h" 15 #include "chromecast/browser/metrics/cast_metrics_service_client.h"
16 #include "chromecast/net/connectivity_checker.h" 16 #include "chromecast/net/connectivity_checker.h"
17 #include "chromecast/service/cast_service.h" 17 #include "chromecast/service/cast_service.h"
18 #include "components/prefs/pref_service.h" 18 #include "components/prefs/pref_service.h"
19 #include "components/proxy_config/pref_proxy_config_tracker_impl.h"
20 #include "content/public/browser/browser_thread.h"
21 #include "net/proxy/proxy_service.h"
19 22
20 #if defined(OS_ANDROID) 23 #if defined(OS_ANDROID)
21 #include "components/crash/content/browser/crash_dump_manager_android.h" 24 #include "components/crash/content/browser/crash_dump_manager_android.h"
22 #endif // defined(OS_ANDROID) 25 #endif // defined(OS_ANDROID)
23 26
24 #if defined(USE_AURA) 27 #if defined(USE_AURA)
25 #include "chromecast/graphics/cast_screen.h" 28 #include "chromecast/graphics/cast_screen.h"
26 #endif // defined(USE_AURA) 29 #endif // defined(USE_AURA)
27 30
28 namespace chromecast { 31 namespace chromecast {
(...skipping 11 matching lines...) Expand all
40 43
41 CastBrowserProcess::CastBrowserProcess() 44 CastBrowserProcess::CastBrowserProcess()
42 : cast_content_browser_client_(nullptr), 45 : cast_content_browser_client_(nullptr),
43 net_log_(nullptr) { 46 net_log_(nullptr) {
44 DCHECK(!g_instance); 47 DCHECK(!g_instance);
45 g_instance = this; 48 g_instance = this;
46 } 49 }
47 50
48 CastBrowserProcess::~CastBrowserProcess() { 51 CastBrowserProcess::~CastBrowserProcess() {
49 DCHECK_EQ(g_instance, this); 52 DCHECK_EQ(g_instance, this);
53 pref_proxy_config_tracker_impl_->DetachFromPrefService();
54 connectivity_checker_->DetachFromPrefService();
55
56 content::BrowserThread::GetTaskRunnerForThread(content::BrowserThread::IO)
57 ->DeleteSoon(FROM_HERE, proxy_service_.release());
50 if (pref_service_) 58 if (pref_service_)
51 pref_service_->CommitPendingWrite(); 59 pref_service_->CommitPendingWrite();
52 g_instance = NULL; 60 g_instance = NULL;
53 } 61 }
54 62
55 void CastBrowserProcess::SetBrowserContext( 63 void CastBrowserProcess::SetBrowserContext(
56 std::unique_ptr<CastBrowserContext> browser_context) { 64 std::unique_ptr<CastBrowserContext> browser_context) {
57 DCHECK(!browser_context_); 65 DCHECK(!browser_context_);
58 browser_context_.swap(browser_context); 66 browser_context_.swap(browser_context);
59 } 67 }
(...skipping 27 matching lines...) Expand all
87 void CastBrowserProcess::SetMetricsServiceClient( 95 void CastBrowserProcess::SetMetricsServiceClient(
88 std::unique_ptr<metrics::CastMetricsServiceClient> metrics_service_client) { 96 std::unique_ptr<metrics::CastMetricsServiceClient> metrics_service_client) {
89 DCHECK(!metrics_service_client_); 97 DCHECK(!metrics_service_client_);
90 metrics_service_client_.swap(metrics_service_client); 98 metrics_service_client_.swap(metrics_service_client);
91 } 99 }
92 100
93 void CastBrowserProcess::SetPrefService( 101 void CastBrowserProcess::SetPrefService(
94 std::unique_ptr<PrefService> pref_service) { 102 std::unique_ptr<PrefService> pref_service) {
95 DCHECK(!pref_service_); 103 DCHECK(!pref_service_);
96 pref_service_.swap(pref_service); 104 pref_service_.swap(pref_service);
105
106 pref_proxy_config_tracker_impl_ =
wzhong 2017/02/07 15:56:02 I'd rather you have a separate function SetPrefPro
almasrymina 2017/02/08 00:48:03 Removed with new approach.
107 base::MakeUnique<PrefProxyConfigTrackerImpl>(
108 pref_service_.get(), content::BrowserThread::GetTaskRunnerForThread(
109 content::BrowserThread::IO));
110 }
111
112 void CastBrowserProcess::SetProxyService() {
113 std::unique_ptr<net::ProxyConfigService> proxy_config_service =
114 pref_proxy_config_tracker_impl_->CreateTrackingProxyConfigService(
115 nullptr);
116
117 proxy_service_ = net::ProxyService::CreateUsingSystemProxyResolver(
118 std::move(proxy_config_service), 0, nullptr);
97 } 119 }
98 120
99 void CastBrowserProcess::SetRemoteDebuggingServer( 121 void CastBrowserProcess::SetRemoteDebuggingServer(
100 std::unique_ptr<RemoteDebuggingServer> remote_debugging_server) { 122 std::unique_ptr<RemoteDebuggingServer> remote_debugging_server) {
101 DCHECK(!remote_debugging_server_); 123 DCHECK(!remote_debugging_server_);
102 remote_debugging_server_.swap(remote_debugging_server); 124 remote_debugging_server_.swap(remote_debugging_server);
103 } 125 }
104 126
105 void CastBrowserProcess::SetResourceDispatcherHostDelegate( 127 void CastBrowserProcess::SetResourceDispatcherHostDelegate(
106 std::unique_ptr<CastResourceDispatcherHostDelegate> delegate) { 128 std::unique_ptr<CastResourceDispatcherHostDelegate> delegate) {
(...skipping 15 matching lines...) Expand all
122 connectivity_checker_.swap(connectivity_checker); 144 connectivity_checker_.swap(connectivity_checker);
123 } 145 }
124 146
125 void CastBrowserProcess::SetNetLog(net::NetLog* net_log) { 147 void CastBrowserProcess::SetNetLog(net::NetLog* net_log) {
126 DCHECK(!net_log_); 148 DCHECK(!net_log_);
127 net_log_ = net_log; 149 net_log_ = net_log;
128 } 150 }
129 151
130 } // namespace shell 152 } // namespace shell
131 } // namespace chromecast 153 } // namespace chromecast
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698