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

Side by Side Diff: components/search_engines/template_url_service.cc

Issue 686963002: Switching profiler instrumentations from ScopedProfile to ScopedTracker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 "components/search_engines/template_url_service.h" 5 #include "components/search_engines/template_url_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/guid.h" 13 #include "base/guid.h"
14 #include "base/i18n/case_conversion.h" 14 #include "base/i18n/case_conversion.h"
15 #include "base/memory/scoped_vector.h" 15 #include "base/memory/scoped_vector.h"
16 #include "base/metrics/histogram.h" 16 #include "base/metrics/histogram.h"
17 #include "base/prefs/pref_service.h" 17 #include "base/prefs/pref_service.h"
18 #include "base/profiler/scoped_profile.h" 18 #include "base/profiler/scoped_tracker.h"
19 #include "base/stl_util.h" 19 #include "base/stl_util.h"
20 #include "base/strings/string_number_conversions.h" 20 #include "base/strings/string_number_conversions.h"
21 #include "base/strings/string_split.h" 21 #include "base/strings/string_split.h"
22 #include "base/strings/string_util.h" 22 #include "base/strings/string_util.h"
23 #include "base/strings/utf_string_conversions.h" 23 #include "base/strings/utf_string_conversions.h"
24 #include "base/time/time.h" 24 #include "base/time/time.h"
25 #include "components/rappor/rappor_service.h" 25 #include "components/rappor/rappor_service.h"
26 #include "components/search_engines/search_engines_pref_names.h" 26 #include "components/search_engines/search_engines_pref_names.h"
27 #include "components/search_engines/search_host_to_urls_map.h" 27 #include "components/search_engines/search_host_to_urls_map.h"
28 #include "components/search_engines/search_terms_data.h" 28 #include "components/search_engines/search_terms_data.h"
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 TemplateURLService::RegisterOnLoadedCallback( 819 TemplateURLService::RegisterOnLoadedCallback(
820 const base::Closure& callback) { 820 const base::Closure& callback) {
821 return loaded_ ? 821 return loaded_ ?
822 scoped_ptr<TemplateURLService::Subscription>() : 822 scoped_ptr<TemplateURLService::Subscription>() :
823 on_loaded_callbacks_.Add(callback); 823 on_loaded_callbacks_.Add(callback);
824 } 824 }
825 825
826 void TemplateURLService::OnWebDataServiceRequestDone( 826 void TemplateURLService::OnWebDataServiceRequestDone(
827 KeywordWebDataService::Handle h, 827 KeywordWebDataService::Handle h,
828 const WDTypedResult* result) { 828 const WDTypedResult* result) {
829 // TODO(vadimt): Remove ScopedProfile below once crbug.com/422460 is fixed. 829 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422460 is fixed.
830 tracked_objects::ScopedProfile tracking_profile( 830 tracked_objects::ScopedTracker tracking_profile(
831 FROM_HERE_WITH_EXPLICIT_FUNCTION( 831 FROM_HERE_WITH_EXPLICIT_FUNCTION(
832 "422460 TemplateURLService::OnWebDataServiceRequestDone")); 832 "422460 TemplateURLService::OnWebDataServiceRequestDone"));
833 833
834 // Reset the load_handle so that we don't try and cancel the load in 834 // Reset the load_handle so that we don't try and cancel the load in
835 // the destructor. 835 // the destructor.
836 load_handle_ = 0; 836 load_handle_ = 0;
837 837
838 if (!result) { 838 if (!result) {
839 // TODO(vadimt): Remove ScopedProfile below once crbug.com/422460 is fixed. 839 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422460 is fixed.
840 tracked_objects::ScopedProfile tracking_profile1( 840 tracked_objects::ScopedTracker tracking_profile1(
841 FROM_HERE_WITH_EXPLICIT_FUNCTION( 841 FROM_HERE_WITH_EXPLICIT_FUNCTION(
842 "422460 TemplateURLService::OnWebDataServiceRequestDone 1")); 842 "422460 TemplateURLService::OnWebDataServiceRequestDone 1"));
843 843
844 // Results are null if the database went away or (most likely) wasn't 844 // Results are null if the database went away or (most likely) wasn't
845 // loaded. 845 // loaded.
846 load_failed_ = true; 846 load_failed_ = true;
847 web_data_service_ = NULL; 847 web_data_service_ = NULL;
848 ChangeToLoadedState(); 848 ChangeToLoadedState();
849 return; 849 return;
850 } 850 }
851 851
852 TemplateURLVector template_urls; 852 TemplateURLVector template_urls;
853 int new_resource_keyword_version = 0; 853 int new_resource_keyword_version = 0;
854 { 854 {
855 // TODO(vadimt): Remove ScopedProfile below once crbug.com/422460 is fixed. 855 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422460 is fixed.
856 tracked_objects::ScopedProfile tracking_profile2( 856 tracked_objects::ScopedTracker tracking_profile2(
857 FROM_HERE_WITH_EXPLICIT_FUNCTION( 857 FROM_HERE_WITH_EXPLICIT_FUNCTION(
858 "422460 TemplateURLService::OnWebDataServiceRequestDone 2")); 858 "422460 TemplateURLService::OnWebDataServiceRequestDone 2"));
859 859
860 GetSearchProvidersUsingKeywordResult( 860 GetSearchProvidersUsingKeywordResult(
861 *result, 861 *result,
862 web_data_service_.get(), 862 web_data_service_.get(),
863 prefs_, 863 prefs_,
864 &template_urls, 864 &template_urls,
865 (default_search_provider_source_ == DefaultSearchManager::FROM_USER) 865 (default_search_provider_source_ == DefaultSearchManager::FROM_USER)
866 ? initial_default_search_provider_.get() 866 ? initial_default_search_provider_.get()
867 : NULL, 867 : NULL,
868 search_terms_data(), 868 search_terms_data(),
869 &new_resource_keyword_version, 869 &new_resource_keyword_version,
870 &pre_sync_deletes_); 870 &pre_sync_deletes_);
871 } 871 }
872 872
873 if (client_) { 873 if (client_) {
874 // TODO(vadimt): Remove ScopedProfile below once crbug.com/422460 is fixed. 874 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422460 is fixed.
875 tracked_objects::ScopedProfile tracking_profile3( 875 tracked_objects::ScopedTracker tracking_profile3(
876 FROM_HERE_WITH_EXPLICIT_FUNCTION( 876 FROM_HERE_WITH_EXPLICIT_FUNCTION(
877 "422460 TemplateURLService::OnWebDataServiceRequestDone 3")); 877 "422460 TemplateURLService::OnWebDataServiceRequestDone 3"));
878 878
879 // Restore extension info of loaded TemplateURLs. 879 // Restore extension info of loaded TemplateURLs.
880 for (size_t i = 0; i < template_urls.size(); ++i) { 880 for (size_t i = 0; i < template_urls.size(); ++i) {
881 DCHECK(!template_urls[i]->extension_info_); 881 DCHECK(!template_urls[i]->extension_info_);
882 client_->RestoreExtensionInfoIfNecessary(template_urls[i]); 882 client_->RestoreExtensionInfoIfNecessary(template_urls[i]);
883 } 883 }
884 } 884 }
885 885
886 KeywordWebDataService::BatchModeScoper scoper(web_data_service_.get()); 886 KeywordWebDataService::BatchModeScoper scoper(web_data_service_.get());
887 887
888 { 888 {
889 // TODO(vadimt): Remove ScopedProfile below once crbug.com/422460 is fixed. 889 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422460 is fixed.
890 tracked_objects::ScopedProfile tracking_profile4( 890 tracked_objects::ScopedTracker tracking_profile4(
891 FROM_HERE_WITH_EXPLICIT_FUNCTION( 891 FROM_HERE_WITH_EXPLICIT_FUNCTION(
892 "422460 TemplateURLService::OnWebDataServiceRequestDone 4")); 892 "422460 TemplateURLService::OnWebDataServiceRequestDone 4"));
893 893
894 PatchMissingSyncGUIDs(&template_urls); 894 PatchMissingSyncGUIDs(&template_urls);
895 895
896 // TODO(vadimt): Remove ScopedProfile below once crbug.com/422460 is fixed. 896 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422460 is fixed.
897 tracked_objects::ScopedProfile tracking_profile41( 897 tracked_objects::ScopedTracker tracking_profile41(
898 FROM_HERE_WITH_EXPLICIT_FUNCTION( 898 FROM_HERE_WITH_EXPLICIT_FUNCTION(
899 "422460 TemplateURLService::OnWebDataServiceRequestDone 41")); 899 "422460 TemplateURLService::OnWebDataServiceRequestDone 41"));
900 900
901 SetTemplateURLs(&template_urls); 901 SetTemplateURLs(&template_urls);
902 902
903 // TODO(vadimt): Remove ScopedProfile below once crbug.com/422460 is fixed. 903 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422460 is fixed.
904 tracked_objects::ScopedProfile tracking_profile42( 904 tracked_objects::ScopedTracker tracking_profile42(
905 FROM_HERE_WITH_EXPLICIT_FUNCTION( 905 FROM_HERE_WITH_EXPLICIT_FUNCTION(
906 "422460 TemplateURLService::OnWebDataServiceRequestDone 42")); 906 "422460 TemplateURLService::OnWebDataServiceRequestDone 42"));
907 907
908 // This initializes provider_map_ which should be done before 908 // This initializes provider_map_ which should be done before
909 // calling UpdateKeywordSearchTermsForURL. 909 // calling UpdateKeywordSearchTermsForURL.
910 // This also calls NotifyObservers. 910 // This also calls NotifyObservers.
911 ChangeToLoadedState(); 911 ChangeToLoadedState();
912 912
913 // TODO(vadimt): Remove ScopedProfile below once crbug.com/422460 is fixed. 913 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422460 is fixed.
914 tracked_objects::ScopedProfile tracking_profile43( 914 tracked_objects::ScopedTracker tracking_profile43(
915 FROM_HERE_WITH_EXPLICIT_FUNCTION( 915 FROM_HERE_WITH_EXPLICIT_FUNCTION(
916 "422460 TemplateURLService::OnWebDataServiceRequestDone 43")); 916 "422460 TemplateURLService::OnWebDataServiceRequestDone 43"));
917 917
918 // Index any visits that occurred before we finished loading. 918 // Index any visits that occurred before we finished loading.
919 for (size_t i = 0; i < visits_to_add_.size(); ++i) 919 for (size_t i = 0; i < visits_to_add_.size(); ++i)
920 UpdateKeywordSearchTermsForURL(visits_to_add_[i]); 920 UpdateKeywordSearchTermsForURL(visits_to_add_[i]);
921 visits_to_add_.clear(); 921 visits_to_add_.clear();
922 922
923 // TODO(vadimt): Remove ScopedProfile below once crbug.com/422460 is fixed. 923 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422460 is fixed.
924 tracked_objects::ScopedProfile tracking_profile44( 924 tracked_objects::ScopedTracker tracking_profile44(
925 FROM_HERE_WITH_EXPLICIT_FUNCTION( 925 FROM_HERE_WITH_EXPLICIT_FUNCTION(
926 "422460 TemplateURLService::OnWebDataServiceRequestDone 44")); 926 "422460 TemplateURLService::OnWebDataServiceRequestDone 44"));
927 927
928 if (new_resource_keyword_version) 928 if (new_resource_keyword_version)
929 web_data_service_->SetBuiltinKeywordVersion(new_resource_keyword_version); 929 web_data_service_->SetBuiltinKeywordVersion(new_resource_keyword_version);
930 } 930 }
931 931
932 if (default_search_provider_) { 932 if (default_search_provider_) {
933 // TODO(vadimt): Remove ScopedProfile below once crbug.com/422460 is fixed. 933 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422460 is fixed.
934 tracked_objects::ScopedProfile tracking_profile5( 934 tracked_objects::ScopedTracker tracking_profile5(
935 FROM_HERE_WITH_EXPLICIT_FUNCTION( 935 FROM_HERE_WITH_EXPLICIT_FUNCTION(
936 "422460 TemplateURLService::OnWebDataServiceRequestDone 5")); 936 "422460 TemplateURLService::OnWebDataServiceRequestDone 5"));
937 937
938 UMA_HISTOGRAM_ENUMERATION( 938 UMA_HISTOGRAM_ENUMERATION(
939 "Search.DefaultSearchProviderType", 939 "Search.DefaultSearchProviderType",
940 TemplateURLPrepopulateData::GetEngineType( 940 TemplateURLPrepopulateData::GetEngineType(
941 *default_search_provider_, search_terms_data()), 941 *default_search_provider_, search_terms_data()),
942 SEARCH_ENGINE_MAX); 942 SEARCH_ENGINE_MAX);
943 943
944 if (rappor_service_) { 944 if (rappor_service_) {
(...skipping 1478 matching lines...) Expand 10 before | Expand all | Expand 10 after
2423 2423
2424 if (most_recently_intalled_default) { 2424 if (most_recently_intalled_default) {
2425 base::AutoReset<DefaultSearchChangeOrigin> change_origin( 2425 base::AutoReset<DefaultSearchChangeOrigin> change_origin(
2426 &dsp_change_origin_, DSP_CHANGE_OVERRIDE_SETTINGS_EXTENSION); 2426 &dsp_change_origin_, DSP_CHANGE_OVERRIDE_SETTINGS_EXTENSION);
2427 default_search_manager_.SetExtensionControlledDefaultSearchEngine( 2427 default_search_manager_.SetExtensionControlledDefaultSearchEngine(
2428 most_recently_intalled_default->data()); 2428 most_recently_intalled_default->data());
2429 } else { 2429 } else {
2430 default_search_manager_.ClearExtensionControlledDefaultSearchEngine(); 2430 default_search_manager_.ClearExtensionControlledDefaultSearchEngine();
2431 } 2431 }
2432 } 2432 }
OLDNEW
« no previous file with comments | « components/policy/core/common/policy_loader_win.cc ('k') | components/signin/core/browser/account_tracker_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698