Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/search/instant_service.h" | 5 #include "chrome/browser/search/instant_service.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/feature_list.h" | 10 #include "base/feature_list.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 96 registrar_.Add(this, | 96 registrar_.Add(this, |
| 97 content::NOTIFICATION_RENDERER_PROCESS_CREATED, | 97 content::NOTIFICATION_RENDERER_PROCESS_CREATED, |
| 98 content::NotificationService::AllSources()); | 98 content::NotificationService::AllSources()); |
| 99 registrar_.Add(this, | 99 registrar_.Add(this, |
| 100 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, | 100 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, |
| 101 content::NotificationService::AllSources()); | 101 content::NotificationService::AllSources()); |
| 102 | 102 |
| 103 if (base::FeatureList::IsEnabled(kNtpTilesFeature)) { | 103 if (base::FeatureList::IsEnabled(kNtpTilesFeature)) { |
| 104 most_visited_sites_ = | 104 most_visited_sites_ = |
| 105 ChromeMostVisitedSitesFactory::NewForProfile(profile_); | 105 ChromeMostVisitedSitesFactory::NewForProfile(profile_); |
| 106 most_visited_sites_->SetMostVisitedURLsObserver(this, 8); | 106 most_visited_sites_->AddObserver(this); |
|
sfiera
2017/01/18 09:58:33
Here, you're not doing any filtering to produce 8
| |
| 107 } else { | 107 } else { |
| 108 top_sites_ = TopSitesFactory::GetForProfile(profile_); | 108 top_sites_ = TopSitesFactory::GetForProfile(profile_); |
| 109 if (top_sites_) { | 109 if (top_sites_) { |
| 110 top_sites_->AddObserver(this); | 110 top_sites_->AddObserver(this); |
| 111 // Immediately query the TopSites state. | 111 // Immediately query the TopSites state. |
| 112 TopSitesChanged(top_sites_.get(), | 112 TopSitesChanged(top_sites_.get(), |
| 113 history::TopSitesObserver::ChangeReason::MOST_VISITED); | 113 history::TopSitesObserver::ChangeReason::MOST_VISITED); |
| 114 } | 114 } |
| 115 } | 115 } |
| 116 | 116 |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 144 content::URLDataSource::Add( | 144 content::URLDataSource::Add( |
| 145 profile_, new FallbackIconSource(fallback_icon_service)); | 145 profile_, new FallbackIconSource(fallback_icon_service)); |
| 146 content::URLDataSource::Add( | 146 content::URLDataSource::Add( |
| 147 profile_, new FaviconSource(profile_, FaviconSource::FAVICON)); | 147 profile_, new FaviconSource(profile_, FaviconSource::FAVICON)); |
| 148 content::URLDataSource::Add( | 148 content::URLDataSource::Add( |
| 149 profile_, new LargeIconSource(fallback_icon_service, large_icon_service)); | 149 profile_, new LargeIconSource(fallback_icon_service, large_icon_service)); |
| 150 content::URLDataSource::Add(profile_, new MostVisitedIframeSource()); | 150 content::URLDataSource::Add(profile_, new MostVisitedIframeSource()); |
| 151 } | 151 } |
| 152 | 152 |
| 153 InstantService::~InstantService() { | 153 InstantService::~InstantService() { |
| 154 if (most_visited_sites_) | |
| 155 most_visited_sites_->RemoveObserver(this); | |
| 154 if (template_url_service_) | 156 if (template_url_service_) |
| 155 template_url_service_->RemoveObserver(this); | 157 template_url_service_->RemoveObserver(this); |
| 156 } | 158 } |
| 157 | 159 |
| 158 void InstantService::AddInstantProcess(int process_id) { | 160 void InstantService::AddInstantProcess(int process_id) { |
| 159 process_ids_.insert(process_id); | 161 process_ids_.insert(process_id); |
| 160 | 162 |
| 161 if (instant_io_context_.get()) { | 163 if (instant_io_context_.get()) { |
| 162 content::BrowserThread::PostTask( | 164 content::BrowserThread::PostTask( |
| 163 content::BrowserThread::IO, FROM_HERE, | 165 content::BrowserThread::IO, FROM_HERE, |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 504 void InstantService::ResetInstantSearchPrerendererIfNecessary() { | 506 void InstantService::ResetInstantSearchPrerendererIfNecessary() { |
| 505 if (!search::ShouldPrefetchSearchResults()) | 507 if (!search::ShouldPrefetchSearchResults()) |
| 506 return; | 508 return; |
| 507 | 509 |
| 508 GURL url(search::GetSearchResultPrefetchBaseURL(profile_)); | 510 GURL url(search::GetSearchResultPrefetchBaseURL(profile_)); |
| 509 if (!instant_prerenderer_ || instant_prerenderer_->prerender_url() != url) { | 511 if (!instant_prerenderer_ || instant_prerenderer_->prerender_url() != url) { |
| 510 instant_prerenderer_.reset( | 512 instant_prerenderer_.reset( |
| 511 url.is_valid() ? new InstantSearchPrerenderer(profile_, url) : nullptr); | 513 url.is_valid() ? new InstantSearchPrerenderer(profile_, url) : nullptr); |
| 512 } | 514 } |
| 513 } | 515 } |
| OLD | NEW |