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 UpdateNetParamsOnIOThread( | |
143 net::HttpNetworkSession::ParamsUpdate params_update); | |
144 | |
142 protected: | 145 protected: |
143 ~SafeBrowsingURLRequestContextGetter() override; | 146 ~SafeBrowsingURLRequestContextGetter() override; |
144 | 147 |
145 private: | 148 private: |
146 bool shut_down_; | 149 bool shut_down_; |
147 | 150 |
148 scoped_refptr<net::URLRequestContextGetter> system_context_getter_; | 151 scoped_refptr<net::URLRequestContextGetter> system_context_getter_; |
149 | 152 |
150 std::unique_ptr<net::CookieStore> safe_browsing_cookie_store_; | 153 std::unique_ptr<net::CookieStore> safe_browsing_cookie_store_; |
151 | 154 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
232 } | 235 } |
233 | 236 |
234 void SafeBrowsingURLRequestContextGetter::ServiceShuttingDown() { | 237 void SafeBrowsingURLRequestContextGetter::ServiceShuttingDown() { |
235 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 238 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
236 | 239 |
237 shut_down_ = true; | 240 shut_down_ = true; |
238 URLRequestContextGetter::NotifyContextShuttingDown(); | 241 URLRequestContextGetter::NotifyContextShuttingDown(); |
239 safe_browsing_request_context_.reset(); | 242 safe_browsing_request_context_.reset(); |
240 } | 243 } |
241 | 244 |
245 void SafeBrowsingURLRequestContextGetter::UpdateNetParamsOnIOThread( | |
246 net::HttpNetworkSession::ParamsUpdate params_update) { | |
247 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
248 | |
249 if (!http_network_session_) | |
Nathan Parker
2017/01/05 17:30:18
nit: could be
if (http_network_session_)
http_ne
pmarko
2017/01/08 20:51:48
Done.
| |
250 return; | |
251 | |
252 http_network_session_->UpdateParams(params_update); | |
253 } | |
254 | |
242 SafeBrowsingURLRequestContextGetter::~SafeBrowsingURLRequestContextGetter() {} | 255 SafeBrowsingURLRequestContextGetter::~SafeBrowsingURLRequestContextGetter() {} |
243 | 256 |
244 // static | 257 // static |
245 SafeBrowsingServiceFactory* SafeBrowsingService::factory_ = NULL; | 258 SafeBrowsingServiceFactory* SafeBrowsingService::factory_ = NULL; |
246 | 259 |
247 // The default SafeBrowsingServiceFactory. Global, made a singleton so we | 260 // The default SafeBrowsingServiceFactory. Global, made a singleton so we |
248 // don't leak it. | 261 // don't leak it. |
249 class SafeBrowsingServiceFactoryImpl : public SafeBrowsingServiceFactory { | 262 class SafeBrowsingServiceFactoryImpl : public SafeBrowsingServiceFactory { |
250 public: | 263 public: |
251 SafeBrowsingService* CreateSafeBrowsingService() override { | 264 SafeBrowsingService* CreateSafeBrowsingService() override { |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
385 return false; | 398 return false; |
386 #endif | 399 #endif |
387 } | 400 } |
388 | 401 |
389 scoped_refptr<net::URLRequestContextGetter> | 402 scoped_refptr<net::URLRequestContextGetter> |
390 SafeBrowsingService::url_request_context() { | 403 SafeBrowsingService::url_request_context() { |
391 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 404 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
392 return url_request_context_getter_; | 405 return url_request_context_getter_; |
393 } | 406 } |
394 | 407 |
408 void SafeBrowsingService::UpdateNetParamsOnIOThread( | |
409 net::HttpNetworkSession::ParamsUpdate params_update) { | |
410 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
mmenke
2017/01/06 16:18:43
Suggest making this method be called on the UI thr
pmarko
2017/01/08 20:51:48
Done.
| |
411 | |
412 url_request_context_getter_->UpdateNetParamsOnIOThread(params_update); | |
413 } | |
414 | |
395 // TODO(ntfschr): componentize this once BaseSafeBrowsingUIManager contains a | 415 // TODO(ntfschr): componentize this once BaseSafeBrowsingUIManager contains a |
396 // SafeBrowsingService | 416 // SafeBrowsingService |
397 const scoped_refptr<SafeBrowsingUIManager>& | 417 const scoped_refptr<SafeBrowsingUIManager>& |
398 SafeBrowsingService::ui_manager() const { | 418 SafeBrowsingService::ui_manager() const { |
399 return ui_manager_; | 419 return ui_manager_; |
400 } | 420 } |
401 | 421 |
402 const scoped_refptr<SafeBrowsingDatabaseManager>& | 422 const scoped_refptr<SafeBrowsingDatabaseManager>& |
403 SafeBrowsingService::database_manager() const { | 423 SafeBrowsingService::database_manager() const { |
404 return enabled_v4_only_ ? v4_local_database_manager() : database_manager_; | 424 return enabled_v4_only_ ? v4_local_database_manager() : database_manager_; |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
743 ping_manager()->ReportThreatDetails(report); | 763 ping_manager()->ReportThreatDetails(report); |
744 } | 764 } |
745 | 765 |
746 void SafeBrowsingService::ProcessResourceRequest( | 766 void SafeBrowsingService::ProcessResourceRequest( |
747 const ResourceRequestInfo& request) { | 767 const ResourceRequestInfo& request) { |
748 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 768 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
749 services_delegate_->ProcessResourceRequest(&request); | 769 services_delegate_->ProcessResourceRequest(&request); |
750 } | 770 } |
751 | 771 |
752 } // namespace safe_browsing | 772 } // namespace safe_browsing |
OLD | NEW |