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/predictors/autocomplete_action_predictor.h" | 5 #include "chrome/browser/predictors/autocomplete_action_predictor.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
435 const DBCacheKey key = { it->user_text, it->url }; | 435 const DBCacheKey key = { it->user_text, it->url }; |
436 const DBCacheValue value = { it->number_of_hits, it->number_of_misses }; | 436 const DBCacheValue value = { it->number_of_hits, it->number_of_misses }; |
437 db_cache_[key] = value; | 437 db_cache_[key] = value; |
438 db_id_cache_[key] = it->id; | 438 db_id_cache_[key] = it->id; |
439 } | 439 } |
440 | 440 |
441 // If the history service is ready, delete any old or invalid entries. | 441 // If the history service is ready, delete any old or invalid entries. |
442 history::HistoryService* history_service = | 442 history::HistoryService* history_service = |
443 HistoryServiceFactory::GetForProfile(profile_, | 443 HistoryServiceFactory::GetForProfile(profile_, |
444 ServiceAccessType::EXPLICIT_ACCESS); | 444 ServiceAccessType::EXPLICIT_ACCESS); |
445 if (!TryDeleteOldEntries(history_service)) { | 445 TryDeleteOldEntries(history_service); |
pasko
2016/11/29 18:01:00
after this change the return value is never checke
dullweber
2016/11/30 11:49:21
Done.
| |
446 // Wait for the notification that the history service is ready and the URL | 446 if (history_service) |
447 // DB is loaded. | 447 history_service_observer_.Add(history_service); |
pasko
2016/11/29 18:01:00
what if the history service is not ready by the ti
dullweber
2016/11/30 11:49:21
I think I handled the following cases:
1. history_
pasko
2016/12/01 17:26:41
I think calling TryDeleteOldEntries twice is not s
dullweber
2016/12/05 13:07:57
OnHistoryServiceLoaded() and OnURLsDeleted() are b
| |
448 if (history_service) | |
449 history_service_observer_.Add(history_service); | |
450 } | |
451 } | 448 } |
452 | 449 |
453 bool AutocompleteActionPredictor::TryDeleteOldEntries( | 450 bool AutocompleteActionPredictor::TryDeleteOldEntries( |
454 history::HistoryService* service) { | 451 history::HistoryService* service) { |
455 CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 452 CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
456 DCHECK(!profile_->IsOffTheRecord()); | 453 DCHECK(!profile_->IsOffTheRecord()); |
457 DCHECK(!initialized_); | 454 DCHECK(!initialized_); |
458 | 455 |
459 if (!service) | 456 if (!service) |
460 return false; | 457 return false; |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
563 history_service_observer_.RemoveAll(); | 560 history_service_observer_.RemoveAll(); |
564 } | 561 } |
565 | 562 |
566 void AutocompleteActionPredictor::OnURLsDeleted( | 563 void AutocompleteActionPredictor::OnURLsDeleted( |
567 history::HistoryService* history_service, | 564 history::HistoryService* history_service, |
568 bool all_history, | 565 bool all_history, |
569 bool expired, | 566 bool expired, |
570 const history::URLRows& deleted_rows, | 567 const history::URLRows& deleted_rows, |
571 const std::set<GURL>& favicon_urls) { | 568 const std::set<GURL>& favicon_urls) { |
572 if (!initialized_) | 569 if (!initialized_) |
573 return; | 570 return; |
pasko
2016/11/29 18:01:00
In other words: if we've got a request to delete U
dullweber
2016/11/30 11:49:21
That's true. This is normally called when the user
pasko
2016/12/01 17:26:41
ah, right, we cannot get into OnURLsDeleted() with
dullweber
2016/12/05 13:07:57
That should be right. I changed it to a DCHECK her
| |
574 | 571 |
575 if (all_history) | 572 if (all_history) |
576 DeleteAllRows(); | 573 DeleteAllRows(); |
577 else | 574 else |
578 DeleteRowsWithURLs(deleted_rows); | 575 DeleteRowsWithURLs(deleted_rows); |
579 } | 576 } |
580 | 577 |
581 void AutocompleteActionPredictor::OnHistoryServiceLoaded( | 578 void AutocompleteActionPredictor::OnHistoryServiceLoaded( |
582 history::HistoryService* history_service) { | 579 history::HistoryService* history_service) { |
583 TryDeleteOldEntries(history_service); | 580 if (!initialized_) |
pasko
2016/11/29 18:01:00
would it break something if we try to delete old e
dullweber
2016/11/30 11:49:21
I don't think anything would break but TryDeleteOl
| |
584 history_service_observer_.Remove(history_service); | 581 TryDeleteOldEntries(history_service); |
585 } | 582 } |
586 | 583 |
587 AutocompleteActionPredictor::TransitionalMatch::TransitionalMatch() { | 584 AutocompleteActionPredictor::TransitionalMatch::TransitionalMatch() { |
588 } | 585 } |
589 | 586 |
590 AutocompleteActionPredictor::TransitionalMatch::TransitionalMatch( | 587 AutocompleteActionPredictor::TransitionalMatch::TransitionalMatch( |
591 const TransitionalMatch& other) = default; | 588 const TransitionalMatch& other) = default; |
592 | 589 |
593 AutocompleteActionPredictor::TransitionalMatch::~TransitionalMatch() { | 590 AutocompleteActionPredictor::TransitionalMatch::~TransitionalMatch() { |
594 } | 591 } |
595 | 592 |
596 } // namespace predictors | 593 } // namespace predictors |
OLD | NEW |