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

Side by Side Diff: chrome/browser/browser_process_impl.cc

Issue 2731283009: Swap ownership of RulesetService and the content delegate (Closed)
Patch Set: Swap ownership of RulesetService and the content delegate Created 3 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 (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/browser_process_impl.h" 5 #include "chrome/browser/browser_process_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <map> 10 #include <map>
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 } 896 }
897 897
898 safe_browsing::ClientSideDetectionService* 898 safe_browsing::ClientSideDetectionService*
899 BrowserProcessImpl::safe_browsing_detection_service() { 899 BrowserProcessImpl::safe_browsing_detection_service() {
900 DCHECK(CalledOnValidThread()); 900 DCHECK(CalledOnValidThread());
901 if (safe_browsing_service()) 901 if (safe_browsing_service())
902 return safe_browsing_service()->safe_browsing_detection_service(); 902 return safe_browsing_service()->safe_browsing_detection_service();
903 return NULL; 903 return NULL;
904 } 904 }
905 905
906 subresource_filter::RulesetService* 906 subresource_filter::ContentRulesetServiceDelegate*
907 BrowserProcessImpl::subresource_filter_ruleset_service() { 907 BrowserProcessImpl::subresource_filter_ruleset_service_delegate() {
908 DCHECK(CalledOnValidThread()); 908 DCHECK(CalledOnValidThread());
909 if (!created_subresource_filter_ruleset_service_) 909 if (!created_subresource_filter_ruleset_service_)
910 CreateSubresourceFilterRulesetService(); 910 CreateSubresourceFilterRulesetService();
911 return subresource_filter_ruleset_service_.get(); 911 return subresource_filter_ruleset_service_delegate_.get();
912 } 912 }
913 913
914 #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) 914 #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
915 void BrowserProcessImpl::StartAutoupdateTimer() { 915 void BrowserProcessImpl::StartAutoupdateTimer() {
916 autoupdate_timer_.Start(FROM_HERE, 916 autoupdate_timer_.Start(FROM_HERE,
917 base::TimeDelta::FromHours(kUpdateCheckIntervalHours), 917 base::TimeDelta::FromHours(kUpdateCheckIntervalHours),
918 this, 918 this,
919 &BrowserProcessImpl::OnAutoupdateTimer); 919 &BrowserProcessImpl::OnAutoupdateTimer);
920 } 920 }
921 #endif 921 #endif
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
1197 DCHECK(!safe_browsing_service_); 1197 DCHECK(!safe_browsing_service_);
1198 // Set this flag to true so that we don't retry indefinitely to 1198 // Set this flag to true so that we don't retry indefinitely to
1199 // create the service class if there was an error. 1199 // create the service class if there was an error.
1200 created_safe_browsing_service_ = true; 1200 created_safe_browsing_service_ = true;
1201 safe_browsing_service_ = 1201 safe_browsing_service_ =
1202 safe_browsing::SafeBrowsingService::CreateSafeBrowsingService(); 1202 safe_browsing::SafeBrowsingService::CreateSafeBrowsingService();
1203 safe_browsing_service_->Initialize(); 1203 safe_browsing_service_->Initialize();
1204 } 1204 }
1205 1205
1206 void BrowserProcessImpl::CreateSubresourceFilterRulesetService() { 1206 void BrowserProcessImpl::CreateSubresourceFilterRulesetService() {
1207 DCHECK(!subresource_filter_ruleset_service_); 1207 DCHECK(!subresource_filter_ruleset_service_delegate_);
1208 created_subresource_filter_ruleset_service_ = true; 1208 created_subresource_filter_ruleset_service_ = true;
1209 1209
1210 if (!base::FeatureList::IsEnabled( 1210 if (!base::FeatureList::IsEnabled(
1211 subresource_filter::kSafeBrowsingSubresourceFilter)) { 1211 subresource_filter::kSafeBrowsingSubresourceFilter)) {
1212 return; 1212 return;
1213 } 1213 }
1214 1214
1215 base::SequencedWorkerPool* blocking_pool = 1215 base::SequencedWorkerPool* blocking_pool =
1216 content::BrowserThread::GetBlockingPool(); 1216 content::BrowserThread::GetBlockingPool();
1217 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner( 1217 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner(
1218 blocking_pool->GetSequencedTaskRunnerWithShutdownBehavior( 1218 blocking_pool->GetSequencedTaskRunnerWithShutdownBehavior(
1219 blocking_pool->GetSequenceToken(), 1219 blocking_pool->GetSequenceToken(),
1220 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); 1220 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN));
1221 1221
1222 base::FilePath user_data_dir; 1222 base::FilePath user_data_dir;
1223 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); 1223 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
1224 base::FilePath indexed_ruleset_base_dir = 1224 base::FilePath indexed_ruleset_base_dir =
1225 user_data_dir.Append(subresource_filter::kTopLevelDirectoryName) 1225 user_data_dir.Append(subresource_filter::kTopLevelDirectoryName)
1226 .Append(subresource_filter::kIndexedRulesetBaseDirectoryName); 1226 .Append(subresource_filter::kIndexedRulesetBaseDirectoryName);
1227 subresource_filter_ruleset_service_.reset( 1227 subresource_filter_ruleset_service_delegate_ =
1228 new subresource_filter::RulesetService( 1228 base::MakeUnique<subresource_filter::ContentRulesetServiceDelegate>();
1229 subresource_filter_ruleset_service_delegate_->set_ruleset_service(
1230 base::MakeUnique<subresource_filter::RulesetService>(
1229 local_state(), blocking_task_runner, 1231 local_state(), blocking_task_runner,
1230 base::MakeUnique<subresource_filter::ContentRulesetServiceDelegate>(), 1232 subresource_filter_ruleset_service_delegate_.get(),
1231 indexed_ruleset_base_dir)); 1233 indexed_ruleset_base_dir));
1232 } 1234 }
1233 1235
1234 void BrowserProcessImpl::CreateGCMDriver() { 1236 void BrowserProcessImpl::CreateGCMDriver() {
1235 DCHECK(!gcm_driver_); 1237 DCHECK(!gcm_driver_);
1236 1238
1237 #if defined(OS_ANDROID) 1239 #if defined(OS_ANDROID)
1238 // Android's GCMDriver currently makes the assumption that it's a singleton. 1240 // Android's GCMDriver currently makes the assumption that it's a singleton.
1239 // Until this gets fixed, instantiating multiple Java GCMDrivers will throw 1241 // Until this gets fixed, instantiating multiple Java GCMDrivers will throw
1240 // an exception, but because they're only initialized on demand these crashes 1242 // an exception, but because they're only initialized on demand these crashes
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
1413 } 1415 }
1414 1416
1415 void BrowserProcessImpl::OnAutoupdateTimer() { 1417 void BrowserProcessImpl::OnAutoupdateTimer() {
1416 if (CanAutorestartForUpdate()) { 1418 if (CanAutorestartForUpdate()) {
1417 DLOG(WARNING) << "Detected update. Restarting browser."; 1419 DLOG(WARNING) << "Detected update. Restarting browser.";
1418 RestartBackgroundInstance(); 1420 RestartBackgroundInstance();
1419 } 1421 }
1420 } 1422 }
1421 1423
1422 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) 1424 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698