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

Side by Side Diff: chrome/browser/history/history_service.cc

Issue 865443005: Inline ScheduleAndForget implementation in HistoryService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « chrome/browser/history/history_service.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // The history system runs on a background thread so that potentially slow 5 // The history system runs on a background thread so that potentially slow
6 // database operations don't delay the browser. This backend processing is 6 // database operations don't delay the browser. This backend processing is
7 // represented by HistoryBackend. The HistoryService's job is to dispatch to 7 // represented by HistoryBackend. The HistoryService's job is to dispatch to
8 // that thread. 8 // that thread.
9 // 9 //
10 // Main thread History thread 10 // Main thread History thread
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 248
249 bool HistoryService::BackendLoaded() { 249 bool HistoryService::BackendLoaded() {
250 DCHECK(thread_checker_.CalledOnValidThread()); 250 DCHECK(thread_checker_.CalledOnValidThread());
251 return backend_loaded_; 251 return backend_loaded_;
252 } 252 }
253 253
254 void HistoryService::ClearCachedDataForContextID( 254 void HistoryService::ClearCachedDataForContextID(
255 history::ContextID context_id) { 255 history::ContextID context_id) {
256 DCHECK(thread_) << "History service being called after cleanup"; 256 DCHECK(thread_) << "History service being called after cleanup";
257 DCHECK(thread_checker_.CalledOnValidThread()); 257 DCHECK(thread_checker_.CalledOnValidThread());
258 ScheduleAndForget(PRIORITY_NORMAL, 258 ScheduleTask(PRIORITY_NORMAL,
259 &HistoryBackend::ClearCachedDataForContextID, context_id); 259 base::Bind(&HistoryBackend::ClearCachedDataForContextID,
260 history_backend_.get(), context_id));
260 } 261 }
261 262
262 history::URLDatabase* HistoryService::InMemoryDatabase() { 263 history::URLDatabase* HistoryService::InMemoryDatabase() {
263 DCHECK(thread_checker_.CalledOnValidThread()); 264 DCHECK(thread_checker_.CalledOnValidThread());
264 return in_memory_backend_ ? in_memory_backend_->db() : NULL; 265 return in_memory_backend_ ? in_memory_backend_->db() : NULL;
265 } 266 }
266 267
267 bool HistoryService::GetTypedCountForURL(const GURL& url, int* typed_count) { 268 bool HistoryService::GetTypedCountForURL(const GURL& url, int* typed_count) {
268 DCHECK(thread_checker_.CalledOnValidThread()); 269 DCHECK(thread_checker_.CalledOnValidThread());
269 history::URLRow url_row; 270 history::URLRow url_row;
(...skipping 30 matching lines...) Expand all
300 void HistoryService::Shutdown() { 301 void HistoryService::Shutdown() {
301 DCHECK(thread_checker_.CalledOnValidThread()); 302 DCHECK(thread_checker_.CalledOnValidThread());
302 Cleanup(); 303 Cleanup();
303 } 304 }
304 305
305 void HistoryService::SetKeywordSearchTermsForURL(const GURL& url, 306 void HistoryService::SetKeywordSearchTermsForURL(const GURL& url,
306 KeywordID keyword_id, 307 KeywordID keyword_id,
307 const base::string16& term) { 308 const base::string16& term) {
308 DCHECK(thread_) << "History service being called after cleanup"; 309 DCHECK(thread_) << "History service being called after cleanup";
309 DCHECK(thread_checker_.CalledOnValidThread()); 310 DCHECK(thread_checker_.CalledOnValidThread());
310 ScheduleAndForget(PRIORITY_UI, 311 ScheduleTask(PRIORITY_UI,
311 &HistoryBackend::SetKeywordSearchTermsForURL, 312 base::Bind(&HistoryBackend::SetKeywordSearchTermsForURL,
312 url, keyword_id, term); 313 history_backend_.get(), url, keyword_id, term));
313 } 314 }
314 315
315 void HistoryService::DeleteAllSearchTermsForKeyword(KeywordID keyword_id) { 316 void HistoryService::DeleteAllSearchTermsForKeyword(KeywordID keyword_id) {
316 DCHECK(thread_) << "History service being called after cleanup"; 317 DCHECK(thread_) << "History service being called after cleanup";
317 DCHECK(thread_checker_.CalledOnValidThread()); 318 DCHECK(thread_checker_.CalledOnValidThread());
318 319
319 if (in_memory_backend_) 320 if (in_memory_backend_)
320 in_memory_backend_->DeleteAllSearchTermsForKeyword(keyword_id); 321 in_memory_backend_->DeleteAllSearchTermsForKeyword(keyword_id);
321 322
322 ScheduleAndForget(PRIORITY_UI, 323 ScheduleTask(PRIORITY_UI,
323 &HistoryBackend::DeleteAllSearchTermsForKeyword, 324 base::Bind(&HistoryBackend::DeleteAllSearchTermsForKeyword,
324 keyword_id); 325 history_backend_.get(), keyword_id));
325 } 326 }
326 327
327 void HistoryService::DeleteKeywordSearchTermForURL(const GURL& url) { 328 void HistoryService::DeleteKeywordSearchTermForURL(const GURL& url) {
328 DCHECK(thread_) << "History service being called after cleanup"; 329 DCHECK(thread_) << "History service being called after cleanup";
329 DCHECK(thread_checker_.CalledOnValidThread()); 330 DCHECK(thread_checker_.CalledOnValidThread());
330 ScheduleAndForget(PRIORITY_UI, &HistoryBackend::DeleteKeywordSearchTermForURL, 331 ScheduleTask(PRIORITY_UI,
331 url); 332 base::Bind(&HistoryBackend::DeleteKeywordSearchTermForURL,
333 history_backend_.get(), url));
332 } 334 }
333 335
334 void HistoryService::DeleteMatchingURLsForKeyword(KeywordID keyword_id, 336 void HistoryService::DeleteMatchingURLsForKeyword(KeywordID keyword_id,
335 const base::string16& term) { 337 const base::string16& term) {
336 DCHECK(thread_) << "History service being called after cleanup"; 338 DCHECK(thread_) << "History service being called after cleanup";
337 DCHECK(thread_checker_.CalledOnValidThread()); 339 DCHECK(thread_checker_.CalledOnValidThread());
338 ScheduleAndForget(PRIORITY_UI, &HistoryBackend::DeleteMatchingURLsForKeyword, 340 ScheduleTask(PRIORITY_UI,
339 keyword_id, term); 341 base::Bind(&HistoryBackend::DeleteMatchingURLsForKeyword,
342 history_backend_.get(), keyword_id, term));
340 } 343 }
341 344
342 void HistoryService::URLsNoLongerBookmarked(const std::set<GURL>& urls) { 345 void HistoryService::URLsNoLongerBookmarked(const std::set<GURL>& urls) {
343 DCHECK(thread_) << "History service being called after cleanup"; 346 DCHECK(thread_) << "History service being called after cleanup";
344 DCHECK(thread_checker_.CalledOnValidThread()); 347 DCHECK(thread_checker_.CalledOnValidThread());
345 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::URLsNoLongerBookmarked, 348 ScheduleTask(PRIORITY_NORMAL,
346 urls); 349 base::Bind(&HistoryBackend::URLsNoLongerBookmarked,
350 history_backend_.get(), urls));
347 } 351 }
348 352
349 void HistoryService::AddObserver(history::HistoryServiceObserver* observer) { 353 void HistoryService::AddObserver(history::HistoryServiceObserver* observer) {
350 DCHECK(thread_checker_.CalledOnValidThread()); 354 DCHECK(thread_checker_.CalledOnValidThread());
351 observers_.AddObserver(observer); 355 observers_.AddObserver(observer);
352 } 356 }
353 357
354 void HistoryService::RemoveObserver(history::HistoryServiceObserver* observer) { 358 void HistoryService::RemoveObserver(history::HistoryServiceObserver* observer) {
355 DCHECK(thread_checker_.CalledOnValidThread()); 359 DCHECK(thread_checker_.CalledOnValidThread());
356 observers_.RemoveObserver(observer); 360 observers_.RemoveObserver(observer);
(...skipping 18 matching lines...) Expand all
375 } 379 }
376 380
377 void HistoryService::FlushForTest(const base::Closure& flushed) { 381 void HistoryService::FlushForTest(const base::Closure& flushed) {
378 thread_->message_loop_proxy()->PostTaskAndReply( 382 thread_->message_loop_proxy()->PostTaskAndReply(
379 FROM_HERE, base::Bind(&base::DoNothing), flushed); 383 FROM_HERE, base::Bind(&base::DoNothing), flushed);
380 } 384 }
381 385
382 void HistoryService::SetOnBackendDestroyTask(const base::Closure& task) { 386 void HistoryService::SetOnBackendDestroyTask(const base::Closure& task) {
383 DCHECK(thread_) << "History service being called after cleanup"; 387 DCHECK(thread_) << "History service being called after cleanup";
384 DCHECK(thread_checker_.CalledOnValidThread()); 388 DCHECK(thread_checker_.CalledOnValidThread());
385 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::SetOnBackendDestroyTask, 389 ScheduleTask(
386 base::MessageLoop::current(), task); 390 PRIORITY_NORMAL,
391 base::Bind(&HistoryBackend::SetOnBackendDestroyTask,
392 history_backend_.get(), base::MessageLoop::current(), task));
387 } 393 }
388 394
389 void HistoryService::AddPage(const GURL& url, 395 void HistoryService::AddPage(const GURL& url,
390 Time time, 396 Time time,
391 history::ContextID context_id, 397 history::ContextID context_id,
392 int nav_entry_id, 398 int nav_entry_id,
393 const GURL& referrer, 399 const GURL& referrer,
394 const history::RedirectList& redirects, 400 const history::RedirectList& redirects,
395 ui::PageTransition transition, 401 ui::PageTransition transition,
396 history::VisitSource visit_source, 402 history::VisitSource visit_source,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 DCHECK_EQ(add_page_args.url, 439 DCHECK_EQ(add_page_args.url,
434 add_page_args.redirects[add_page_args.redirects.size() - 1]); 440 add_page_args.redirects[add_page_args.redirects.size() - 1]);
435 441
436 // We need the !redirects.empty() condition above since size_t is unsigned 442 // We need the !redirects.empty() condition above since size_t is unsigned
437 // and will wrap around when we subtract one from a 0 size. 443 // and will wrap around when we subtract one from a 0 size.
438 for (size_t i = 0; i < add_page_args.redirects.size() - 1; i++) 444 for (size_t i = 0; i < add_page_args.redirects.size() - 1; i++)
439 visitedlink_master_->AddURL(add_page_args.redirects[i]); 445 visitedlink_master_->AddURL(add_page_args.redirects[i]);
440 } 446 }
441 } 447 }
442 448
443 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::AddPage, add_page_args); 449 ScheduleTask(PRIORITY_NORMAL,
450 base::Bind(&HistoryBackend::AddPage, history_backend_.get(),
451 add_page_args));
444 } 452 }
445 453
446 void HistoryService::AddPageNoVisitForBookmark(const GURL& url, 454 void HistoryService::AddPageNoVisitForBookmark(const GURL& url,
447 const base::string16& title) { 455 const base::string16& title) {
448 DCHECK(thread_) << "History service being called after cleanup"; 456 DCHECK(thread_) << "History service being called after cleanup";
449 DCHECK(thread_checker_.CalledOnValidThread()); 457 DCHECK(thread_checker_.CalledOnValidThread());
450 if (!CanAddURL(url)) 458 if (!CanAddURL(url))
451 return; 459 return;
452 460
453 ScheduleAndForget(PRIORITY_NORMAL, 461 ScheduleTask(PRIORITY_NORMAL,
454 &HistoryBackend::AddPageNoVisitForBookmark, url, title); 462 base::Bind(&HistoryBackend::AddPageNoVisitForBookmark,
463 history_backend_.get(), url, title));
455 } 464 }
456 465
457 void HistoryService::SetPageTitle(const GURL& url, 466 void HistoryService::SetPageTitle(const GURL& url,
458 const base::string16& title) { 467 const base::string16& title) {
459 DCHECK(thread_) << "History service being called after cleanup"; 468 DCHECK(thread_) << "History service being called after cleanup";
460 DCHECK(thread_checker_.CalledOnValidThread()); 469 DCHECK(thread_checker_.CalledOnValidThread());
461 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::SetPageTitle, url, title); 470 ScheduleTask(PRIORITY_NORMAL, base::Bind(&HistoryBackend::SetPageTitle,
471 history_backend_.get(), url, title));
462 } 472 }
463 473
464 void HistoryService::UpdateWithPageEndTime(history::ContextID context_id, 474 void HistoryService::UpdateWithPageEndTime(history::ContextID context_id,
465 int nav_entry_id, 475 int nav_entry_id,
466 const GURL& url, 476 const GURL& url,
467 Time end_ts) { 477 Time end_ts) {
468 DCHECK(thread_) << "History service being called after cleanup"; 478 DCHECK(thread_) << "History service being called after cleanup";
469 DCHECK(thread_checker_.CalledOnValidThread()); 479 DCHECK(thread_checker_.CalledOnValidThread());
470 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::UpdateWithPageEndTime, 480 ScheduleTask(
471 context_id, nav_entry_id, url, end_ts); 481 PRIORITY_NORMAL,
482 base::Bind(&HistoryBackend::UpdateWithPageEndTime, history_backend_.get(),
483 context_id, nav_entry_id, url, end_ts));
472 } 484 }
473 485
474 void HistoryService::AddPageWithDetails(const GURL& url, 486 void HistoryService::AddPageWithDetails(const GURL& url,
475 const base::string16& title, 487 const base::string16& title,
476 int visit_count, 488 int visit_count,
477 int typed_count, 489 int typed_count,
478 Time last_visit, 490 Time last_visit,
479 bool hidden, 491 bool hidden,
480 history::VisitSource visit_source) { 492 history::VisitSource visit_source) {
481 DCHECK(thread_) << "History service being called after cleanup"; 493 DCHECK(thread_) << "History service being called after cleanup";
482 DCHECK(thread_checker_.CalledOnValidThread()); 494 DCHECK(thread_checker_.CalledOnValidThread());
483 // Filter out unwanted URLs. 495 // Filter out unwanted URLs.
484 if (!CanAddURL(url)) 496 if (!CanAddURL(url))
485 return; 497 return;
486 498
487 // Add to the visited links system. 499 // Add to the visited links system.
488 if (visitedlink_master_) 500 if (visitedlink_master_)
489 visitedlink_master_->AddURL(url); 501 visitedlink_master_->AddURL(url);
490 502
491 history::URLRow row(url); 503 history::URLRow row(url);
492 row.set_title(title); 504 row.set_title(title);
493 row.set_visit_count(visit_count); 505 row.set_visit_count(visit_count);
494 row.set_typed_count(typed_count); 506 row.set_typed_count(typed_count);
495 row.set_last_visit(last_visit); 507 row.set_last_visit(last_visit);
496 row.set_hidden(hidden); 508 row.set_hidden(hidden);
497 509
498 history::URLRows rows; 510 history::URLRows rows;
499 rows.push_back(row); 511 rows.push_back(row);
500 512
501 ScheduleAndForget(PRIORITY_NORMAL, 513 ScheduleTask(PRIORITY_NORMAL,
502 &HistoryBackend::AddPagesWithDetails, rows, visit_source); 514 base::Bind(&HistoryBackend::AddPagesWithDetails,
515 history_backend_.get(), rows, visit_source));
503 } 516 }
504 517
505 void HistoryService::AddPagesWithDetails(const history::URLRows& info, 518 void HistoryService::AddPagesWithDetails(const history::URLRows& info,
506 history::VisitSource visit_source) { 519 history::VisitSource visit_source) {
507 DCHECK(thread_) << "History service being called after cleanup"; 520 DCHECK(thread_) << "History service being called after cleanup";
508 DCHECK(thread_checker_.CalledOnValidThread()); 521 DCHECK(thread_checker_.CalledOnValidThread());
509 // Add to the visited links system. 522 // Add to the visited links system.
510 if (visitedlink_master_) { 523 if (visitedlink_master_) {
511 std::vector<GURL> urls; 524 std::vector<GURL> urls;
512 urls.reserve(info.size()); 525 urls.reserve(info.size());
513 for (history::URLRows::const_iterator i = info.begin(); i != info.end(); 526 for (history::URLRows::const_iterator i = info.begin(); i != info.end();
514 ++i) 527 ++i)
515 urls.push_back(i->url()); 528 urls.push_back(i->url());
516 529
517 visitedlink_master_->AddURLs(urls); 530 visitedlink_master_->AddURLs(urls);
518 } 531 }
519 532
520 ScheduleAndForget(PRIORITY_NORMAL, 533 ScheduleTask(PRIORITY_NORMAL,
521 &HistoryBackend::AddPagesWithDetails, info, visit_source); 534 base::Bind(&HistoryBackend::AddPagesWithDetails,
535 history_backend_.get(), info, visit_source));
522 } 536 }
523 537
524 base::CancelableTaskTracker::TaskId HistoryService::GetFavicons( 538 base::CancelableTaskTracker::TaskId HistoryService::GetFavicons(
525 const std::vector<GURL>& icon_urls, 539 const std::vector<GURL>& icon_urls,
526 int icon_types, 540 int icon_types,
527 const std::vector<int>& desired_sizes, 541 const std::vector<int>& desired_sizes,
528 const favicon_base::FaviconResultsCallback& callback, 542 const favicon_base::FaviconResultsCallback& callback,
529 base::CancelableTaskTracker* tracker) { 543 base::CancelableTaskTracker* tracker) {
530 DCHECK(thread_) << "History service being called after cleanup"; 544 DCHECK(thread_) << "History service being called after cleanup";
531 DCHECK(thread_checker_.CalledOnValidThread()); 545 DCHECK(thread_checker_.CalledOnValidThread());
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 const GURL& page_url, 650 const GURL& page_url,
637 const GURL& icon_url, 651 const GURL& icon_url,
638 favicon_base::IconType icon_type, 652 favicon_base::IconType icon_type,
639 scoped_refptr<base::RefCountedMemory> bitmap_data, 653 scoped_refptr<base::RefCountedMemory> bitmap_data,
640 const gfx::Size& pixel_size) { 654 const gfx::Size& pixel_size) {
641 DCHECK(thread_) << "History service being called after cleanup"; 655 DCHECK(thread_) << "History service being called after cleanup";
642 DCHECK(thread_checker_.CalledOnValidThread()); 656 DCHECK(thread_checker_.CalledOnValidThread());
643 if (!CanAddURL(page_url)) 657 if (!CanAddURL(page_url))
644 return; 658 return;
645 659
646 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::MergeFavicon, page_url, 660 ScheduleTask(
647 icon_url, icon_type, bitmap_data, pixel_size); 661 PRIORITY_NORMAL,
662 base::Bind(&HistoryBackend::MergeFavicon, history_backend_.get(),
663 page_url, icon_url, icon_type, bitmap_data, pixel_size));
648 } 664 }
649 665
650 void HistoryService::SetFavicons( 666 void HistoryService::SetFavicons(
651 const GURL& page_url, 667 const GURL& page_url,
652 favicon_base::IconType icon_type, 668 favicon_base::IconType icon_type,
653 const GURL& icon_url, 669 const GURL& icon_url,
654 const std::vector<SkBitmap>& bitmaps) { 670 const std::vector<SkBitmap>& bitmaps) {
655 DCHECK(thread_) << "History service being called after cleanup"; 671 DCHECK(thread_) << "History service being called after cleanup";
656 DCHECK(thread_checker_.CalledOnValidThread()); 672 DCHECK(thread_checker_.CalledOnValidThread());
657 if (!CanAddURL(page_url)) 673 if (!CanAddURL(page_url))
658 return; 674 return;
659 675
660 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::SetFavicons, page_url, 676 ScheduleTask(PRIORITY_NORMAL,
661 icon_type, icon_url, bitmaps); 677 base::Bind(&HistoryBackend::SetFavicons, history_backend_.get(),
678 page_url, icon_type, icon_url, bitmaps));
662 } 679 }
663 680
664 void HistoryService::SetFaviconsOutOfDateForPage(const GURL& page_url) { 681 void HistoryService::SetFaviconsOutOfDateForPage(const GURL& page_url) {
665 DCHECK(thread_) << "History service being called after cleanup"; 682 DCHECK(thread_) << "History service being called after cleanup";
666 DCHECK(thread_checker_.CalledOnValidThread()); 683 DCHECK(thread_checker_.CalledOnValidThread());
667 ScheduleAndForget(PRIORITY_NORMAL, 684 ScheduleTask(PRIORITY_NORMAL,
668 &HistoryBackend::SetFaviconsOutOfDateForPage, page_url); 685 base::Bind(&HistoryBackend::SetFaviconsOutOfDateForPage,
686 history_backend_.get(), page_url));
669 } 687 }
670 688
671 void HistoryService::CloneFavicons(const GURL& old_page_url, 689 void HistoryService::CloneFavicons(const GURL& old_page_url,
672 const GURL& new_page_url) { 690 const GURL& new_page_url) {
673 DCHECK(thread_) << "History service being called after cleanup"; 691 DCHECK(thread_) << "History service being called after cleanup";
674 DCHECK(thread_checker_.CalledOnValidThread()); 692 DCHECK(thread_checker_.CalledOnValidThread());
675 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::CloneFavicons, 693 ScheduleTask(PRIORITY_NORMAL,
676 old_page_url, new_page_url); 694 base::Bind(&HistoryBackend::CloneFavicons,
695 history_backend_.get(), old_page_url, new_page_url));
677 } 696 }
678 697
679 void HistoryService::SetImportedFavicons( 698 void HistoryService::SetImportedFavicons(
680 const std::vector<ImportedFaviconUsage>& favicon_usage) { 699 const std::vector<ImportedFaviconUsage>& favicon_usage) {
681 DCHECK(thread_) << "History service being called after cleanup"; 700 DCHECK(thread_) << "History service being called after cleanup";
682 DCHECK(thread_checker_.CalledOnValidThread()); 701 DCHECK(thread_checker_.CalledOnValidThread());
683 ScheduleAndForget(PRIORITY_NORMAL, 702 ScheduleTask(PRIORITY_NORMAL,
684 &HistoryBackend::SetImportedFavicons, favicon_usage); 703 base::Bind(&HistoryBackend::SetImportedFavicons,
704 history_backend_.get(), favicon_usage));
685 } 705 }
686 706
687 base::CancelableTaskTracker::TaskId HistoryService::QueryURL( 707 base::CancelableTaskTracker::TaskId HistoryService::QueryURL(
688 const GURL& url, 708 const GURL& url,
689 bool want_visits, 709 bool want_visits,
690 const QueryURLCallback& callback, 710 const QueryURLCallback& callback,
691 base::CancelableTaskTracker* tracker) { 711 base::CancelableTaskTracker* tracker) {
692 DCHECK(thread_) << "History service being called after cleanup"; 712 DCHECK(thread_) << "History service being called after cleanup";
693 DCHECK(thread_checker_.CalledOnValidThread()); 713 DCHECK(thread_checker_.CalledOnValidThread());
694 history::QueryURLResult* query_url_result = new history::QueryURLResult(); 714 history::QueryURLResult* query_url_result = new history::QueryURLResult();
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 FROM_HERE, 769 FROM_HERE,
750 base::Bind(&HistoryBackend::QueryDownloads, history_backend_.get(), rows), 770 base::Bind(&HistoryBackend::QueryDownloads, history_backend_.get(), rows),
751 base::Bind(callback, base::Passed(&scoped_rows))); 771 base::Bind(callback, base::Passed(&scoped_rows)));
752 } 772 }
753 773
754 // Handle updates for a particular download. This is a 'fire and forget' 774 // Handle updates for a particular download. This is a 'fire and forget'
755 // operation, so we don't need to be called back. 775 // operation, so we don't need to be called back.
756 void HistoryService::UpdateDownload(const history::DownloadRow& data) { 776 void HistoryService::UpdateDownload(const history::DownloadRow& data) {
757 DCHECK(thread_) << "History service being called after cleanup"; 777 DCHECK(thread_) << "History service being called after cleanup";
758 DCHECK(thread_checker_.CalledOnValidThread()); 778 DCHECK(thread_checker_.CalledOnValidThread());
759 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::UpdateDownload, data); 779 ScheduleTask(PRIORITY_NORMAL, base::Bind(&HistoryBackend::UpdateDownload,
780 history_backend_.get(), data));
760 } 781 }
761 782
762 void HistoryService::RemoveDownloads(const std::set<uint32>& ids) { 783 void HistoryService::RemoveDownloads(const std::set<uint32>& ids) {
763 DCHECK(thread_) << "History service being called after cleanup"; 784 DCHECK(thread_) << "History service being called after cleanup";
764 DCHECK(thread_checker_.CalledOnValidThread()); 785 DCHECK(thread_checker_.CalledOnValidThread());
765 ScheduleAndForget(PRIORITY_NORMAL, 786 ScheduleTask(PRIORITY_NORMAL, base::Bind(&HistoryBackend::RemoveDownloads,
766 &HistoryBackend::RemoveDownloads, ids); 787 history_backend_.get(), ids));
767 } 788 }
768 789
769 base::CancelableTaskTracker::TaskId HistoryService::QueryHistory( 790 base::CancelableTaskTracker::TaskId HistoryService::QueryHistory(
770 const base::string16& text_query, 791 const base::string16& text_query,
771 const history::QueryOptions& options, 792 const history::QueryOptions& options,
772 const QueryHistoryCallback& callback, 793 const QueryHistoryCallback& callback,
773 base::CancelableTaskTracker* tracker) { 794 base::CancelableTaskTracker* tracker) {
774 DCHECK(thread_) << "History service being called after cleanup"; 795 DCHECK(thread_) << "History service being called after cleanup";
775 DCHECK(thread_checker_.CalledOnValidThread()); 796 DCHECK(thread_checker_.CalledOnValidThread());
776 history::QueryResults* query_results = new history::QueryResults(); 797 history::QueryResults* query_results = new history::QueryResults();
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 // during shutdown, but this shouldn't happen. 955 // during shutdown, but this shouldn't happen.
935 base::Thread* thread = thread_; 956 base::Thread* thread = thread_;
936 thread_ = NULL; 957 thread_ = NULL;
937 delete thread; 958 delete thread;
938 } 959 }
939 960
940 void HistoryService::RebuildTable( 961 void HistoryService::RebuildTable(
941 const scoped_refptr<URLEnumerator>& enumerator) { 962 const scoped_refptr<URLEnumerator>& enumerator) {
942 DCHECK(thread_) << "History service being called after cleanup"; 963 DCHECK(thread_) << "History service being called after cleanup";
943 DCHECK(thread_checker_.CalledOnValidThread()); 964 DCHECK(thread_checker_.CalledOnValidThread());
944 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::IterateURLs, enumerator); 965 ScheduleTask(PRIORITY_NORMAL, base::Bind(&HistoryBackend::IterateURLs,
966 history_backend_.get(), enumerator));
945 } 967 }
946 968
947 bool HistoryService::Init( 969 bool HistoryService::Init(
948 bool no_db, 970 bool no_db,
949 const history::HistoryDatabaseParams& history_database_params) { 971 const history::HistoryDatabaseParams& history_database_params) {
950 DCHECK(thread_) << "History service being called after cleanup"; 972 DCHECK(thread_) << "History service being called after cleanup";
951 DCHECK(thread_checker_.CalledOnValidThread()); 973 DCHECK(thread_checker_.CalledOnValidThread());
952 base::Thread::Options options; 974 base::Thread::Options options;
953 options.timer_slack = base::TIMER_SLACK_MAXIMUM; 975 options.timer_slack = base::TIMER_SLACK_MAXIMUM;
954 if (!thread_->StartWithOptions(options)) { 976 if (!thread_->StartWithOptions(options)) {
(...skipping 19 matching lines...) Expand all
974 history_client_)); 996 history_client_));
975 history_backend_.swap(backend); 997 history_backend_.swap(backend);
976 998
977 // There may not be a profile when unit testing. 999 // There may not be a profile when unit testing.
978 std::string languages; 1000 std::string languages;
979 if (profile_) { 1001 if (profile_) {
980 PrefService* prefs = profile_->GetPrefs(); 1002 PrefService* prefs = profile_->GetPrefs();
981 languages = prefs->GetString(prefs::kAcceptLanguages); 1003 languages = prefs->GetString(prefs::kAcceptLanguages);
982 } 1004 }
983 1005
984 ScheduleAndForget(PRIORITY_UI, &HistoryBackend::Init, languages, no_db_, 1006 ScheduleTask(PRIORITY_UI,
985 history_database_params); 1007 base::Bind(&HistoryBackend::Init, history_backend_.get(),
1008 languages, no_db_, history_database_params));
986 1009
987 if (visitedlink_master_) { 1010 if (visitedlink_master_) {
988 bool result = visitedlink_master_->Init(); 1011 bool result = visitedlink_master_->Init();
989 DCHECK(result); 1012 DCHECK(result);
990 } 1013 }
991 1014
992 return true; 1015 return true;
993 } 1016 }
994 1017
995 void HistoryService::ScheduleAutocomplete(const base::Callback< 1018 void HistoryService::ScheduleAutocomplete(const base::Callback<
996 void(history::HistoryBackend*, history::URLDatabase*)>& callback) { 1019 void(history::HistoryBackend*, history::URLDatabase*)>& callback) {
997 DCHECK(thread_checker_.CalledOnValidThread()); 1020 DCHECK(thread_checker_.CalledOnValidThread());
998 ScheduleAndForget( 1021 ScheduleTask(PRIORITY_UI, base::Bind(&HistoryBackend::ScheduleAutocomplete,
999 PRIORITY_UI, &HistoryBackend::ScheduleAutocomplete, callback); 1022 history_backend_.get(), callback));
1000 } 1023 }
1001 1024
1002 void HistoryService::ScheduleTask(SchedulePriority priority, 1025 void HistoryService::ScheduleTask(SchedulePriority priority,
1003 const base::Closure& task) { 1026 const base::Closure& task) {
1027 DCHECK(thread_) << "History service being called after cleanup";
droger 2015/01/30 16:40:37 Not sure if this CHECK should be changed in DCHECK
sdefresne 2015/01/30 21:17:01 Changed back to CHECK, thank you.
1004 DCHECK(thread_checker_.CalledOnValidThread()); 1028 DCHECK(thread_checker_.CalledOnValidThread());
1005 CHECK(thread_); 1029 DCHECK(thread_->message_loop());
1006 CHECK(thread_->message_loop());
1007 // TODO(brettw): Do prioritization. 1030 // TODO(brettw): Do prioritization.
1008 thread_->message_loop()->PostTask(FROM_HERE, task); 1031 thread_->message_loop()->PostTask(FROM_HERE, task);
1009 } 1032 }
1010 1033
1011 // static 1034 // static
1012 bool HistoryService::CanAddURL(const GURL& url) { 1035 bool HistoryService::CanAddURL(const GURL& url) {
1013 if (!url.is_valid()) 1036 if (!url.is_valid())
1014 return false; 1037 return false;
1015 1038
1016 // TODO: We should allow kChromeUIScheme URLs if they have been explicitly 1039 // TODO: We should allow kChromeUIScheme URLs if they have been explicitly
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 void HistoryService::NotifyProfileError(sql::InitStatus init_status) { 1114 void HistoryService::NotifyProfileError(sql::InitStatus init_status) {
1092 DCHECK(thread_checker_.CalledOnValidThread()); 1115 DCHECK(thread_checker_.CalledOnValidThread());
1093 if (history_client_) 1116 if (history_client_)
1094 history_client_->NotifyProfileError(init_status); 1117 history_client_->NotifyProfileError(init_status);
1095 } 1118 }
1096 1119
1097 void HistoryService::DeleteURL(const GURL& url) { 1120 void HistoryService::DeleteURL(const GURL& url) {
1098 DCHECK(thread_) << "History service being called after cleanup"; 1121 DCHECK(thread_) << "History service being called after cleanup";
1099 DCHECK(thread_checker_.CalledOnValidThread()); 1122 DCHECK(thread_checker_.CalledOnValidThread());
1100 // We will update the visited links when we observe the delete notifications. 1123 // We will update the visited links when we observe the delete notifications.
1101 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::DeleteURL, url); 1124 ScheduleTask(PRIORITY_NORMAL, base::Bind(&HistoryBackend::DeleteURL,
1125 history_backend_.get(), url));
1102 } 1126 }
1103 1127
1104 void HistoryService::DeleteURLsForTest(const std::vector<GURL>& urls) { 1128 void HistoryService::DeleteURLsForTest(const std::vector<GURL>& urls) {
1105 DCHECK(thread_) << "History service being called after cleanup"; 1129 DCHECK(thread_) << "History service being called after cleanup";
1106 DCHECK(thread_checker_.CalledOnValidThread()); 1130 DCHECK(thread_checker_.CalledOnValidThread());
1107 // We will update the visited links when we observe the delete 1131 // We will update the visited links when we observe the delete
1108 // notifications. 1132 // notifications.
1109 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::DeleteURLs, urls); 1133 ScheduleTask(PRIORITY_NORMAL, base::Bind(&HistoryBackend::DeleteURLs,
1134 history_backend_.get(), urls));
1110 } 1135 }
1111 1136
1112 void HistoryService::ExpireHistoryBetween( 1137 void HistoryService::ExpireHistoryBetween(
1113 const std::set<GURL>& restrict_urls, 1138 const std::set<GURL>& restrict_urls,
1114 Time begin_time, 1139 Time begin_time,
1115 Time end_time, 1140 Time end_time,
1116 const base::Closure& callback, 1141 const base::Closure& callback,
1117 base::CancelableTaskTracker* tracker) { 1142 base::CancelableTaskTracker* tracker) {
1118 DCHECK(thread_) << "History service being called after cleanup"; 1143 DCHECK(thread_) << "History service being called after cleanup";
1119 DCHECK(thread_checker_.CalledOnValidThread()); 1144 DCHECK(thread_checker_.CalledOnValidThread());
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1268 const HistoryService::OnFaviconChangedCallback& callback) { 1293 const HistoryService::OnFaviconChangedCallback& callback) {
1269 DCHECK(thread_checker_.CalledOnValidThread()); 1294 DCHECK(thread_checker_.CalledOnValidThread());
1270 return favicon_changed_callback_list_.Add(callback); 1295 return favicon_changed_callback_list_.Add(callback);
1271 } 1296 }
1272 1297
1273 void HistoryService::NotifyFaviconChanged( 1298 void HistoryService::NotifyFaviconChanged(
1274 const std::set<GURL>& changed_favicons) { 1299 const std::set<GURL>& changed_favicons) {
1275 DCHECK(thread_checker_.CalledOnValidThread()); 1300 DCHECK(thread_checker_.CalledOnValidThread());
1276 favicon_changed_callback_list_.Notify(changed_favicons); 1301 favicon_changed_callback_list_.Notify(changed_favicons);
1277 } 1302 }
OLDNEW
« no previous file with comments | « chrome/browser/history/history_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698