OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/safe_browsing/safe_browsing_service.h" | 5 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
132 | 132 |
133 // Implementation for net::UrlRequestContextGetter. | 133 // Implementation for net::UrlRequestContextGetter. |
134 net::URLRequestContext* GetURLRequestContext() override; | 134 net::URLRequestContext* GetURLRequestContext() override; |
135 scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() | 135 scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() |
136 const override; | 136 const override; |
137 | 137 |
138 // Shuts down any pending requests using the getter, and sets |shut_down_| to | 138 // Shuts down any pending requests using the getter, and sets |shut_down_| to |
139 // true. | 139 // true. |
140 void ServiceShuttingDown(); | 140 void ServiceShuttingDown(); |
141 | 141 |
142 void SetQuicEnabledOnIOThread(bool quic_enabled); | |
143 | |
142 protected: | 144 protected: |
143 ~SafeBrowsingURLRequestContextGetter() override; | 145 ~SafeBrowsingURLRequestContextGetter() override; |
144 | 146 |
145 private: | 147 private: |
146 bool shut_down_; | 148 bool shut_down_; |
147 | 149 |
148 scoped_refptr<net::URLRequestContextGetter> system_context_getter_; | 150 scoped_refptr<net::URLRequestContextGetter> system_context_getter_; |
149 | 151 |
150 std::unique_ptr<net::CookieStore> safe_browsing_cookie_store_; | 152 std::unique_ptr<net::CookieStore> safe_browsing_cookie_store_; |
151 | 153 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
232 } | 234 } |
233 | 235 |
234 void SafeBrowsingURLRequestContextGetter::ServiceShuttingDown() { | 236 void SafeBrowsingURLRequestContextGetter::ServiceShuttingDown() { |
235 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 237 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
236 | 238 |
237 shut_down_ = true; | 239 shut_down_ = true; |
238 URLRequestContextGetter::NotifyContextShuttingDown(); | 240 URLRequestContextGetter::NotifyContextShuttingDown(); |
239 safe_browsing_request_context_.reset(); | 241 safe_browsing_request_context_.reset(); |
240 } | 242 } |
241 | 243 |
244 void SafeBrowsingURLRequestContextGetter::SetQuicEnabledOnIOThread( | |
245 bool quic_enabled) { | |
246 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
247 | |
248 if (!http_network_session_) | |
249 return; | |
250 | |
251 http_network_session_->SetQuicEnabled(quic_enabled); | |
Nathan Parker
2017/01/04 20:06:04
It seems like over-coupling to have this class nee
pmarko
2017/01/04 20:18:23
Good point. I didn't want everyone need to #includ
mmenke
2017/01/04 21:36:02
Classes, in general, shouldn't be creating their o
Nathan Parker
2017/01/04 21:54:10
It may be... We do need a separate cookie jar for
mmenke
2017/01/04 21:56:56
Why do we need a separate cookie jar for safebrows
mmenke
2017/01/04 22:02:26
It stores the connections, that is, not the cookie
Nathan Parker
2017/01/04 22:57:38
I wasn't around when this code was written, but fr
| |
252 } | |
253 | |
242 SafeBrowsingURLRequestContextGetter::~SafeBrowsingURLRequestContextGetter() {} | 254 SafeBrowsingURLRequestContextGetter::~SafeBrowsingURLRequestContextGetter() {} |
243 | 255 |
244 // static | 256 // static |
245 SafeBrowsingServiceFactory* SafeBrowsingService::factory_ = NULL; | 257 SafeBrowsingServiceFactory* SafeBrowsingService::factory_ = NULL; |
246 | 258 |
247 // The default SafeBrowsingServiceFactory. Global, made a singleton so we | 259 // The default SafeBrowsingServiceFactory. Global, made a singleton so we |
248 // don't leak it. | 260 // don't leak it. |
249 class SafeBrowsingServiceFactoryImpl : public SafeBrowsingServiceFactory { | 261 class SafeBrowsingServiceFactoryImpl : public SafeBrowsingServiceFactory { |
250 public: | 262 public: |
251 SafeBrowsingService* CreateSafeBrowsingService() override { | 263 SafeBrowsingService* CreateSafeBrowsingService() override { |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
382 #else | 394 #else |
383 return false; | 395 return false; |
384 #endif | 396 #endif |
385 } | 397 } |
386 | 398 |
387 net::URLRequestContextGetter* SafeBrowsingService::url_request_context() { | 399 net::URLRequestContextGetter* SafeBrowsingService::url_request_context() { |
388 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 400 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
389 return url_request_context_getter_.get(); | 401 return url_request_context_getter_.get(); |
390 } | 402 } |
391 | 403 |
404 void SafeBrowsingService::UpdateNetParams( | |
405 NetPrefObserver::NetParamsChange net_params_change) { | |
406 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
407 | |
408 BrowserThread::PostTask( | |
409 BrowserThread::IO, FROM_HERE, | |
410 base::Bind(&SafeBrowsingURLRequestContextGetter::SetQuicEnabledOnIOThread, | |
411 url_request_context_getter_, | |
412 net_params_change.quic_enabled_new)); | |
413 } | |
414 | |
392 const scoped_refptr<SafeBrowsingUIManager>& | 415 const scoped_refptr<SafeBrowsingUIManager>& |
393 SafeBrowsingService::ui_manager() const { | 416 SafeBrowsingService::ui_manager() const { |
394 return ui_manager_; | 417 return ui_manager_; |
395 } | 418 } |
396 | 419 |
397 const scoped_refptr<SafeBrowsingDatabaseManager>& | 420 const scoped_refptr<SafeBrowsingDatabaseManager>& |
398 SafeBrowsingService::database_manager() const { | 421 SafeBrowsingService::database_manager() const { |
399 return enabled_v4_only_ ? v4_local_database_manager() : database_manager_; | 422 return enabled_v4_only_ ? v4_local_database_manager() : database_manager_; |
400 } | 423 } |
401 | 424 |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
729 ping_manager()->ReportThreatDetails(report); | 752 ping_manager()->ReportThreatDetails(report); |
730 } | 753 } |
731 | 754 |
732 void SafeBrowsingService::ProcessResourceRequest( | 755 void SafeBrowsingService::ProcessResourceRequest( |
733 const ResourceRequestInfo& request) { | 756 const ResourceRequestInfo& request) { |
734 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 757 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
735 services_delegate_->ProcessResourceRequest(&request); | 758 services_delegate_->ProcessResourceRequest(&request); |
736 } | 759 } |
737 | 760 |
738 } // namespace safe_browsing | 761 } // namespace safe_browsing |
OLD | NEW |