| 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 // 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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 // Delete the thread, which joins with the background thread. We defensively | 284 // Delete the thread, which joins with the background thread. We defensively |
| 285 // NULL the pointer before deleting it in case somebody tries to use it | 285 // NULL the pointer before deleting it in case somebody tries to use it |
| 286 // during shutdown, but this shouldn't happen. | 286 // during shutdown, but this shouldn't happen. |
| 287 base::Thread* thread = thread_; | 287 base::Thread* thread = thread_; |
| 288 thread_ = NULL; | 288 thread_ = NULL; |
| 289 delete thread; | 289 delete thread; |
| 290 } | 290 } |
| 291 | 291 |
| 292 void HistoryService::ClearCachedDataForContextID( | 292 void HistoryService::ClearCachedDataForContextID( |
| 293 history::ContextID context_id) { | 293 history::ContextID context_id) { |
| 294 DCHECK(thread_) << "History service being called after cleanup"; |
| 294 DCHECK(thread_checker_.CalledOnValidThread()); | 295 DCHECK(thread_checker_.CalledOnValidThread()); |
| 295 ScheduleAndForget(PRIORITY_NORMAL, | 296 ScheduleAndForget(PRIORITY_NORMAL, |
| 296 &HistoryBackend::ClearCachedDataForContextID, context_id); | 297 &HistoryBackend::ClearCachedDataForContextID, context_id); |
| 297 } | 298 } |
| 298 | 299 |
| 299 history::URLDatabase* HistoryService::InMemoryDatabase() { | 300 history::URLDatabase* HistoryService::InMemoryDatabase() { |
| 300 DCHECK(thread_checker_.CalledOnValidThread()); | 301 DCHECK(thread_checker_.CalledOnValidThread()); |
| 301 return in_memory_backend_ ? in_memory_backend_->db() : NULL; | 302 return in_memory_backend_ ? in_memory_backend_->db() : NULL; |
| 302 } | 303 } |
| 303 | 304 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 } | 336 } |
| 336 | 337 |
| 337 void HistoryService::Shutdown() { | 338 void HistoryService::Shutdown() { |
| 338 DCHECK(thread_checker_.CalledOnValidThread()); | 339 DCHECK(thread_checker_.CalledOnValidThread()); |
| 339 Cleanup(); | 340 Cleanup(); |
| 340 } | 341 } |
| 341 | 342 |
| 342 void HistoryService::SetKeywordSearchTermsForURL(const GURL& url, | 343 void HistoryService::SetKeywordSearchTermsForURL(const GURL& url, |
| 343 KeywordID keyword_id, | 344 KeywordID keyword_id, |
| 344 const base::string16& term) { | 345 const base::string16& term) { |
| 346 DCHECK(thread_) << "History service being called after cleanup"; |
| 345 DCHECK(thread_checker_.CalledOnValidThread()); | 347 DCHECK(thread_checker_.CalledOnValidThread()); |
| 346 ScheduleAndForget(PRIORITY_UI, | 348 ScheduleAndForget(PRIORITY_UI, |
| 347 &HistoryBackend::SetKeywordSearchTermsForURL, | 349 &HistoryBackend::SetKeywordSearchTermsForURL, |
| 348 url, keyword_id, term); | 350 url, keyword_id, term); |
| 349 } | 351 } |
| 350 | 352 |
| 351 void HistoryService::DeleteAllSearchTermsForKeyword(KeywordID keyword_id) { | 353 void HistoryService::DeleteAllSearchTermsForKeyword(KeywordID keyword_id) { |
| 354 DCHECK(thread_) << "History service being called after cleanup"; |
| 352 DCHECK(thread_checker_.CalledOnValidThread()); | 355 DCHECK(thread_checker_.CalledOnValidThread()); |
| 353 | 356 |
| 354 if (in_memory_backend_) | 357 if (in_memory_backend_) |
| 355 in_memory_backend_->DeleteAllSearchTermsForKeyword(keyword_id); | 358 in_memory_backend_->DeleteAllSearchTermsForKeyword(keyword_id); |
| 356 | 359 |
| 357 ScheduleAndForget(PRIORITY_UI, | 360 ScheduleAndForget(PRIORITY_UI, |
| 358 &HistoryBackend::DeleteAllSearchTermsForKeyword, | 361 &HistoryBackend::DeleteAllSearchTermsForKeyword, |
| 359 keyword_id); | 362 keyword_id); |
| 360 } | 363 } |
| 361 | 364 |
| 362 void HistoryService::DeleteKeywordSearchTermForURL(const GURL& url) { | 365 void HistoryService::DeleteKeywordSearchTermForURL(const GURL& url) { |
| 366 DCHECK(thread_) << "History service being called after cleanup"; |
| 363 DCHECK(thread_checker_.CalledOnValidThread()); | 367 DCHECK(thread_checker_.CalledOnValidThread()); |
| 364 ScheduleAndForget(PRIORITY_UI, &HistoryBackend::DeleteKeywordSearchTermForURL, | 368 ScheduleAndForget(PRIORITY_UI, &HistoryBackend::DeleteKeywordSearchTermForURL, |
| 365 url); | 369 url); |
| 366 } | 370 } |
| 367 | 371 |
| 368 void HistoryService::DeleteMatchingURLsForKeyword(KeywordID keyword_id, | 372 void HistoryService::DeleteMatchingURLsForKeyword(KeywordID keyword_id, |
| 369 const base::string16& term) { | 373 const base::string16& term) { |
| 374 DCHECK(thread_) << "History service being called after cleanup"; |
| 370 DCHECK(thread_checker_.CalledOnValidThread()); | 375 DCHECK(thread_checker_.CalledOnValidThread()); |
| 371 ScheduleAndForget(PRIORITY_UI, &HistoryBackend::DeleteMatchingURLsForKeyword, | 376 ScheduleAndForget(PRIORITY_UI, &HistoryBackend::DeleteMatchingURLsForKeyword, |
| 372 keyword_id, term); | 377 keyword_id, term); |
| 373 } | 378 } |
| 374 | 379 |
| 375 void HistoryService::URLsNoLongerBookmarked(const std::set<GURL>& urls) { | 380 void HistoryService::URLsNoLongerBookmarked(const std::set<GURL>& urls) { |
| 381 DCHECK(thread_) << "History service being called after cleanup"; |
| 376 DCHECK(thread_checker_.CalledOnValidThread()); | 382 DCHECK(thread_checker_.CalledOnValidThread()); |
| 377 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::URLsNoLongerBookmarked, | 383 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::URLsNoLongerBookmarked, |
| 378 urls); | 384 urls); |
| 379 } | 385 } |
| 380 | 386 |
| 381 void HistoryService::ScheduleDBTask(scoped_refptr<history::HistoryDBTask> task, | 387 void HistoryService::ScheduleDBTask(scoped_refptr<history::HistoryDBTask> task, |
| 382 base::CancelableTaskTracker* tracker) { | 388 base::CancelableTaskTracker* tracker) { |
| 389 DCHECK(thread_) << "History service being called after cleanup"; |
| 383 DCHECK(thread_checker_.CalledOnValidThread()); | 390 DCHECK(thread_checker_.CalledOnValidThread()); |
| 384 base::CancelableTaskTracker::IsCanceledCallback is_canceled; | 391 base::CancelableTaskTracker::IsCanceledCallback is_canceled; |
| 385 tracker->NewTrackedTaskId(&is_canceled); | 392 tracker->NewTrackedTaskId(&is_canceled); |
| 386 // Use base::ThreadTaskRunnerHandler::Get() to get a message loop proxy to | 393 // Use base::ThreadTaskRunnerHandler::Get() to get a message loop proxy to |
| 387 // the current message loop so that we can forward the call to the method | 394 // the current message loop so that we can forward the call to the method |
| 388 // HistoryDBTask::DoneRunOnMainThread in the correct thread. | 395 // HistoryDBTask::DoneRunOnMainThread in the correct thread. |
| 389 thread_->message_loop_proxy()->PostTask( | 396 thread_->message_loop_proxy()->PostTask( |
| 390 FROM_HERE, | 397 FROM_HERE, |
| 391 base::Bind(&HistoryBackend::ProcessDBTask, | 398 base::Bind(&HistoryBackend::ProcessDBTask, |
| 392 history_backend_.get(), | 399 history_backend_.get(), |
| 393 task, | 400 task, |
| 394 base::ThreadTaskRunnerHandle::Get(), | 401 base::ThreadTaskRunnerHandle::Get(), |
| 395 is_canceled)); | 402 is_canceled)); |
| 396 } | 403 } |
| 397 | 404 |
| 398 void HistoryService::FlushForTest(const base::Closure& flushed) { | 405 void HistoryService::FlushForTest(const base::Closure& flushed) { |
| 399 thread_->message_loop_proxy()->PostTaskAndReply( | 406 thread_->message_loop_proxy()->PostTaskAndReply( |
| 400 FROM_HERE, base::Bind(&base::DoNothing), flushed); | 407 FROM_HERE, base::Bind(&base::DoNothing), flushed); |
| 401 } | 408 } |
| 402 | 409 |
| 403 void HistoryService::SetOnBackendDestroyTask(const base::Closure& task) { | 410 void HistoryService::SetOnBackendDestroyTask(const base::Closure& task) { |
| 411 DCHECK(thread_) << "History service being called after cleanup"; |
| 404 DCHECK(thread_checker_.CalledOnValidThread()); | 412 DCHECK(thread_checker_.CalledOnValidThread()); |
| 405 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::SetOnBackendDestroyTask, | 413 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::SetOnBackendDestroyTask, |
| 406 base::MessageLoop::current(), task); | 414 base::MessageLoop::current(), task); |
| 407 } | 415 } |
| 408 | 416 |
| 409 void HistoryService::AddPage(const GURL& url, | 417 void HistoryService::AddPage(const GURL& url, |
| 410 Time time, | 418 Time time, |
| 411 history::ContextID context_id, | 419 history::ContextID context_id, |
| 412 int32 page_id, | 420 int32 page_id, |
| 413 const GURL& referrer, | 421 const GURL& referrer, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 427 history::VisitSource visit_source) { | 435 history::VisitSource visit_source) { |
| 428 DCHECK(thread_checker_.CalledOnValidThread()); | 436 DCHECK(thread_checker_.CalledOnValidThread()); |
| 429 AddPage( | 437 AddPage( |
| 430 history::HistoryAddPageArgs(url, time, NULL, 0, GURL(), | 438 history::HistoryAddPageArgs(url, time, NULL, 0, GURL(), |
| 431 history::RedirectList(), | 439 history::RedirectList(), |
| 432 content::PAGE_TRANSITION_LINK, | 440 content::PAGE_TRANSITION_LINK, |
| 433 visit_source, false)); | 441 visit_source, false)); |
| 434 } | 442 } |
| 435 | 443 |
| 436 void HistoryService::AddPage(const history::HistoryAddPageArgs& add_page_args) { | 444 void HistoryService::AddPage(const history::HistoryAddPageArgs& add_page_args) { |
| 445 DCHECK(thread_) << "History service being called after cleanup"; |
| 437 DCHECK(thread_checker_.CalledOnValidThread()); | 446 DCHECK(thread_checker_.CalledOnValidThread()); |
| 438 DCHECK(thread_) << "History service being called after cleanup"; | |
| 439 | 447 |
| 440 // Filter out unwanted URLs. We don't add auto-subframe URLs. They are a | 448 // Filter out unwanted URLs. We don't add auto-subframe URLs. They are a |
| 441 // large part of history (think iframes for ads) and we never display them in | 449 // large part of history (think iframes for ads) and we never display them in |
| 442 // history UI. We will still add manual subframes, which are ones the user | 450 // history UI. We will still add manual subframes, which are ones the user |
| 443 // has clicked on to get. | 451 // has clicked on to get. |
| 444 if (!CanAddURL(add_page_args.url)) | 452 if (!CanAddURL(add_page_args.url)) |
| 445 return; | 453 return; |
| 446 | 454 |
| 447 // Add link & all redirects to visited link list. | 455 // Add link & all redirects to visited link list. |
| 448 if (visitedlink_master_) { | 456 if (visitedlink_master_) { |
| 449 visitedlink_master_->AddURL(add_page_args.url); | 457 visitedlink_master_->AddURL(add_page_args.url); |
| 450 | 458 |
| 451 if (!add_page_args.redirects.empty()) { | 459 if (!add_page_args.redirects.empty()) { |
| 452 // We should not be asked to add a page in the middle of a redirect chain. | 460 // We should not be asked to add a page in the middle of a redirect chain. |
| 453 DCHECK_EQ(add_page_args.url, | 461 DCHECK_EQ(add_page_args.url, |
| 454 add_page_args.redirects[add_page_args.redirects.size() - 1]); | 462 add_page_args.redirects[add_page_args.redirects.size() - 1]); |
| 455 | 463 |
| 456 // We need the !redirects.empty() condition above since size_t is unsigned | 464 // We need the !redirects.empty() condition above since size_t is unsigned |
| 457 // and will wrap around when we subtract one from a 0 size. | 465 // and will wrap around when we subtract one from a 0 size. |
| 458 for (size_t i = 0; i < add_page_args.redirects.size() - 1; i++) | 466 for (size_t i = 0; i < add_page_args.redirects.size() - 1; i++) |
| 459 visitedlink_master_->AddURL(add_page_args.redirects[i]); | 467 visitedlink_master_->AddURL(add_page_args.redirects[i]); |
| 460 } | 468 } |
| 461 } | 469 } |
| 462 | 470 |
| 463 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::AddPage, add_page_args); | 471 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::AddPage, add_page_args); |
| 464 } | 472 } |
| 465 | 473 |
| 466 void HistoryService::AddPageNoVisitForBookmark(const GURL& url, | 474 void HistoryService::AddPageNoVisitForBookmark(const GURL& url, |
| 467 const base::string16& title) { | 475 const base::string16& title) { |
| 476 DCHECK(thread_) << "History service being called after cleanup"; |
| 468 DCHECK(thread_checker_.CalledOnValidThread()); | 477 DCHECK(thread_checker_.CalledOnValidThread()); |
| 469 if (!CanAddURL(url)) | 478 if (!CanAddURL(url)) |
| 470 return; | 479 return; |
| 471 | 480 |
| 472 ScheduleAndForget(PRIORITY_NORMAL, | 481 ScheduleAndForget(PRIORITY_NORMAL, |
| 473 &HistoryBackend::AddPageNoVisitForBookmark, url, title); | 482 &HistoryBackend::AddPageNoVisitForBookmark, url, title); |
| 474 } | 483 } |
| 475 | 484 |
| 476 void HistoryService::SetPageTitle(const GURL& url, | 485 void HistoryService::SetPageTitle(const GURL& url, |
| 477 const base::string16& title) { | 486 const base::string16& title) { |
| 487 DCHECK(thread_) << "History service being called after cleanup"; |
| 478 DCHECK(thread_checker_.CalledOnValidThread()); | 488 DCHECK(thread_checker_.CalledOnValidThread()); |
| 479 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::SetPageTitle, url, title); | 489 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::SetPageTitle, url, title); |
| 480 } | 490 } |
| 481 | 491 |
| 482 void HistoryService::UpdateWithPageEndTime(history::ContextID context_id, | 492 void HistoryService::UpdateWithPageEndTime(history::ContextID context_id, |
| 483 int32 page_id, | 493 int32 page_id, |
| 484 const GURL& url, | 494 const GURL& url, |
| 485 Time end_ts) { | 495 Time end_ts) { |
| 496 DCHECK(thread_) << "History service being called after cleanup"; |
| 486 DCHECK(thread_checker_.CalledOnValidThread()); | 497 DCHECK(thread_checker_.CalledOnValidThread()); |
| 487 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::UpdateWithPageEndTime, | 498 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::UpdateWithPageEndTime, |
| 488 context_id, page_id, url, end_ts); | 499 context_id, page_id, url, end_ts); |
| 489 } | 500 } |
| 490 | 501 |
| 491 void HistoryService::AddPageWithDetails(const GURL& url, | 502 void HistoryService::AddPageWithDetails(const GURL& url, |
| 492 const base::string16& title, | 503 const base::string16& title, |
| 493 int visit_count, | 504 int visit_count, |
| 494 int typed_count, | 505 int typed_count, |
| 495 Time last_visit, | 506 Time last_visit, |
| 496 bool hidden, | 507 bool hidden, |
| 497 history::VisitSource visit_source) { | 508 history::VisitSource visit_source) { |
| 509 DCHECK(thread_) << "History service being called after cleanup"; |
| 498 DCHECK(thread_checker_.CalledOnValidThread()); | 510 DCHECK(thread_checker_.CalledOnValidThread()); |
| 499 // Filter out unwanted URLs. | 511 // Filter out unwanted URLs. |
| 500 if (!CanAddURL(url)) | 512 if (!CanAddURL(url)) |
| 501 return; | 513 return; |
| 502 | 514 |
| 503 // Add to the visited links system. | 515 // Add to the visited links system. |
| 504 if (visitedlink_master_) | 516 if (visitedlink_master_) |
| 505 visitedlink_master_->AddURL(url); | 517 visitedlink_master_->AddURL(url); |
| 506 | 518 |
| 507 history::URLRow row(url); | 519 history::URLRow row(url); |
| 508 row.set_title(title); | 520 row.set_title(title); |
| 509 row.set_visit_count(visit_count); | 521 row.set_visit_count(visit_count); |
| 510 row.set_typed_count(typed_count); | 522 row.set_typed_count(typed_count); |
| 511 row.set_last_visit(last_visit); | 523 row.set_last_visit(last_visit); |
| 512 row.set_hidden(hidden); | 524 row.set_hidden(hidden); |
| 513 | 525 |
| 514 history::URLRows rows; | 526 history::URLRows rows; |
| 515 rows.push_back(row); | 527 rows.push_back(row); |
| 516 | 528 |
| 517 ScheduleAndForget(PRIORITY_NORMAL, | 529 ScheduleAndForget(PRIORITY_NORMAL, |
| 518 &HistoryBackend::AddPagesWithDetails, rows, visit_source); | 530 &HistoryBackend::AddPagesWithDetails, rows, visit_source); |
| 519 } | 531 } |
| 520 | 532 |
| 521 void HistoryService::AddPagesWithDetails(const history::URLRows& info, | 533 void HistoryService::AddPagesWithDetails(const history::URLRows& info, |
| 522 history::VisitSource visit_source) { | 534 history::VisitSource visit_source) { |
| 535 DCHECK(thread_) << "History service being called after cleanup"; |
| 523 DCHECK(thread_checker_.CalledOnValidThread()); | 536 DCHECK(thread_checker_.CalledOnValidThread()); |
| 524 // Add to the visited links system. | 537 // Add to the visited links system. |
| 525 if (visitedlink_master_) { | 538 if (visitedlink_master_) { |
| 526 std::vector<GURL> urls; | 539 std::vector<GURL> urls; |
| 527 urls.reserve(info.size()); | 540 urls.reserve(info.size()); |
| 528 for (history::URLRows::const_iterator i = info.begin(); i != info.end(); | 541 for (history::URLRows::const_iterator i = info.begin(); i != info.end(); |
| 529 ++i) | 542 ++i) |
| 530 urls.push_back(i->url()); | 543 urls.push_back(i->url()); |
| 531 | 544 |
| 532 visitedlink_master_->AddURLs(urls); | 545 visitedlink_master_->AddURLs(urls); |
| 533 } | 546 } |
| 534 | 547 |
| 535 ScheduleAndForget(PRIORITY_NORMAL, | 548 ScheduleAndForget(PRIORITY_NORMAL, |
| 536 &HistoryBackend::AddPagesWithDetails, info, visit_source); | 549 &HistoryBackend::AddPagesWithDetails, info, visit_source); |
| 537 } | 550 } |
| 538 | 551 |
| 539 base::CancelableTaskTracker::TaskId HistoryService::GetFavicons( | 552 base::CancelableTaskTracker::TaskId HistoryService::GetFavicons( |
| 540 const std::vector<GURL>& icon_urls, | 553 const std::vector<GURL>& icon_urls, |
| 541 int icon_types, | 554 int icon_types, |
| 542 const std::vector<int>& desired_sizes, | 555 const std::vector<int>& desired_sizes, |
| 543 const favicon_base::FaviconResultsCallback& callback, | 556 const favicon_base::FaviconResultsCallback& callback, |
| 544 base::CancelableTaskTracker* tracker) { | 557 base::CancelableTaskTracker* tracker) { |
| 558 DCHECK(thread_) << "History service being called after cleanup"; |
| 545 DCHECK(thread_checker_.CalledOnValidThread()); | 559 DCHECK(thread_checker_.CalledOnValidThread()); |
| 546 | |
| 547 std::vector<favicon_base::FaviconRawBitmapResult>* results = | 560 std::vector<favicon_base::FaviconRawBitmapResult>* results = |
| 548 new std::vector<favicon_base::FaviconRawBitmapResult>(); | 561 new std::vector<favicon_base::FaviconRawBitmapResult>(); |
| 549 return tracker->PostTaskAndReply( | 562 return tracker->PostTaskAndReply( |
| 550 thread_->message_loop_proxy().get(), | 563 thread_->message_loop_proxy().get(), |
| 551 FROM_HERE, | 564 FROM_HERE, |
| 552 base::Bind(&HistoryBackend::GetFavicons, | 565 base::Bind(&HistoryBackend::GetFavicons, |
| 553 history_backend_.get(), | 566 history_backend_.get(), |
| 554 icon_urls, | 567 icon_urls, |
| 555 icon_types, | 568 icon_types, |
| 556 desired_sizes, | 569 desired_sizes, |
| 557 results), | 570 results), |
| 558 base::Bind(&RunWithFaviconResults, callback, base::Owned(results))); | 571 base::Bind(&RunWithFaviconResults, callback, base::Owned(results))); |
| 559 } | 572 } |
| 560 | 573 |
| 561 base::CancelableTaskTracker::TaskId HistoryService::GetFaviconsForURL( | 574 base::CancelableTaskTracker::TaskId HistoryService::GetFaviconsForURL( |
| 562 const GURL& page_url, | 575 const GURL& page_url, |
| 563 int icon_types, | 576 int icon_types, |
| 564 const std::vector<int>& desired_sizes, | 577 const std::vector<int>& desired_sizes, |
| 565 const favicon_base::FaviconResultsCallback& callback, | 578 const favicon_base::FaviconResultsCallback& callback, |
| 566 base::CancelableTaskTracker* tracker) { | 579 base::CancelableTaskTracker* tracker) { |
| 580 DCHECK(thread_) << "History service being called after cleanup"; |
| 567 DCHECK(thread_checker_.CalledOnValidThread()); | 581 DCHECK(thread_checker_.CalledOnValidThread()); |
| 568 | |
| 569 std::vector<favicon_base::FaviconRawBitmapResult>* results = | 582 std::vector<favicon_base::FaviconRawBitmapResult>* results = |
| 570 new std::vector<favicon_base::FaviconRawBitmapResult>(); | 583 new std::vector<favicon_base::FaviconRawBitmapResult>(); |
| 571 return tracker->PostTaskAndReply( | 584 return tracker->PostTaskAndReply( |
| 572 thread_->message_loop_proxy().get(), | 585 thread_->message_loop_proxy().get(), |
| 573 FROM_HERE, | 586 FROM_HERE, |
| 574 base::Bind(&HistoryBackend::GetFaviconsForURL, | 587 base::Bind(&HistoryBackend::GetFaviconsForURL, |
| 575 history_backend_.get(), | 588 history_backend_.get(), |
| 576 page_url, | 589 page_url, |
| 577 icon_types, | 590 icon_types, |
| 578 desired_sizes, | 591 desired_sizes, |
| 579 results), | 592 results), |
| 580 base::Bind(&RunWithFaviconResults, callback, base::Owned(results))); | 593 base::Bind(&RunWithFaviconResults, callback, base::Owned(results))); |
| 581 } | 594 } |
| 582 | 595 |
| 583 base::CancelableTaskTracker::TaskId HistoryService::GetLargestFaviconForURL( | 596 base::CancelableTaskTracker::TaskId HistoryService::GetLargestFaviconForURL( |
| 584 const GURL& page_url, | 597 const GURL& page_url, |
| 585 const std::vector<int>& icon_types, | 598 const std::vector<int>& icon_types, |
| 586 int minimum_size_in_pixels, | 599 int minimum_size_in_pixels, |
| 587 const favicon_base::FaviconRawBitmapCallback& callback, | 600 const favicon_base::FaviconRawBitmapCallback& callback, |
| 588 base::CancelableTaskTracker* tracker) { | 601 base::CancelableTaskTracker* tracker) { |
| 602 DCHECK(thread_) << "History service being called after cleanup"; |
| 589 DCHECK(thread_checker_.CalledOnValidThread()); | 603 DCHECK(thread_checker_.CalledOnValidThread()); |
| 590 | |
| 591 favicon_base::FaviconRawBitmapResult* result = | 604 favicon_base::FaviconRawBitmapResult* result = |
| 592 new favicon_base::FaviconRawBitmapResult(); | 605 new favicon_base::FaviconRawBitmapResult(); |
| 593 return tracker->PostTaskAndReply( | 606 return tracker->PostTaskAndReply( |
| 594 thread_->message_loop_proxy().get(), | 607 thread_->message_loop_proxy().get(), |
| 595 FROM_HERE, | 608 FROM_HERE, |
| 596 base::Bind(&HistoryBackend::GetLargestFaviconForURL, | 609 base::Bind(&HistoryBackend::GetLargestFaviconForURL, |
| 597 history_backend_.get(), | 610 history_backend_.get(), |
| 598 page_url, | 611 page_url, |
| 599 icon_types, | 612 icon_types, |
| 600 minimum_size_in_pixels, | 613 minimum_size_in_pixels, |
| 601 result), | 614 result), |
| 602 base::Bind(&RunWithFaviconResult, callback, base::Owned(result))); | 615 base::Bind(&RunWithFaviconResult, callback, base::Owned(result))); |
| 603 } | 616 } |
| 604 | 617 |
| 605 base::CancelableTaskTracker::TaskId HistoryService::GetFaviconForID( | 618 base::CancelableTaskTracker::TaskId HistoryService::GetFaviconForID( |
| 606 favicon_base::FaviconID favicon_id, | 619 favicon_base::FaviconID favicon_id, |
| 607 int desired_size, | 620 int desired_size, |
| 608 const favicon_base::FaviconResultsCallback& callback, | 621 const favicon_base::FaviconResultsCallback& callback, |
| 609 base::CancelableTaskTracker* tracker) { | 622 base::CancelableTaskTracker* tracker) { |
| 623 DCHECK(thread_) << "History service being called after cleanup"; |
| 610 DCHECK(thread_checker_.CalledOnValidThread()); | 624 DCHECK(thread_checker_.CalledOnValidThread()); |
| 611 | |
| 612 std::vector<favicon_base::FaviconRawBitmapResult>* results = | 625 std::vector<favicon_base::FaviconRawBitmapResult>* results = |
| 613 new std::vector<favicon_base::FaviconRawBitmapResult>(); | 626 new std::vector<favicon_base::FaviconRawBitmapResult>(); |
| 614 return tracker->PostTaskAndReply( | 627 return tracker->PostTaskAndReply( |
| 615 thread_->message_loop_proxy().get(), | 628 thread_->message_loop_proxy().get(), |
| 616 FROM_HERE, | 629 FROM_HERE, |
| 617 base::Bind(&HistoryBackend::GetFaviconForID, | 630 base::Bind(&HistoryBackend::GetFaviconForID, |
| 618 history_backend_.get(), | 631 history_backend_.get(), |
| 619 favicon_id, | 632 favicon_id, |
| 620 desired_size, | 633 desired_size, |
| 621 results), | 634 results), |
| 622 base::Bind(&RunWithFaviconResults, callback, base::Owned(results))); | 635 base::Bind(&RunWithFaviconResults, callback, base::Owned(results))); |
| 623 } | 636 } |
| 624 | 637 |
| 625 base::CancelableTaskTracker::TaskId | 638 base::CancelableTaskTracker::TaskId |
| 626 HistoryService::UpdateFaviconMappingsAndFetch( | 639 HistoryService::UpdateFaviconMappingsAndFetch( |
| 627 const GURL& page_url, | 640 const GURL& page_url, |
| 628 const std::vector<GURL>& icon_urls, | 641 const std::vector<GURL>& icon_urls, |
| 629 int icon_types, | 642 int icon_types, |
| 630 const std::vector<int>& desired_sizes, | 643 const std::vector<int>& desired_sizes, |
| 631 const favicon_base::FaviconResultsCallback& callback, | 644 const favicon_base::FaviconResultsCallback& callback, |
| 632 base::CancelableTaskTracker* tracker) { | 645 base::CancelableTaskTracker* tracker) { |
| 646 DCHECK(thread_) << "History service being called after cleanup"; |
| 633 DCHECK(thread_checker_.CalledOnValidThread()); | 647 DCHECK(thread_checker_.CalledOnValidThread()); |
| 634 | |
| 635 std::vector<favicon_base::FaviconRawBitmapResult>* results = | 648 std::vector<favicon_base::FaviconRawBitmapResult>* results = |
| 636 new std::vector<favicon_base::FaviconRawBitmapResult>(); | 649 new std::vector<favicon_base::FaviconRawBitmapResult>(); |
| 637 return tracker->PostTaskAndReply( | 650 return tracker->PostTaskAndReply( |
| 638 thread_->message_loop_proxy().get(), | 651 thread_->message_loop_proxy().get(), |
| 639 FROM_HERE, | 652 FROM_HERE, |
| 640 base::Bind(&HistoryBackend::UpdateFaviconMappingsAndFetch, | 653 base::Bind(&HistoryBackend::UpdateFaviconMappingsAndFetch, |
| 641 history_backend_.get(), | 654 history_backend_.get(), |
| 642 page_url, | 655 page_url, |
| 643 icon_urls, | 656 icon_urls, |
| 644 icon_types, | 657 icon_types, |
| 645 desired_sizes, | 658 desired_sizes, |
| 646 results), | 659 results), |
| 647 base::Bind(&RunWithFaviconResults, callback, base::Owned(results))); | 660 base::Bind(&RunWithFaviconResults, callback, base::Owned(results))); |
| 648 } | 661 } |
| 649 | 662 |
| 650 void HistoryService::MergeFavicon( | 663 void HistoryService::MergeFavicon( |
| 651 const GURL& page_url, | 664 const GURL& page_url, |
| 652 const GURL& icon_url, | 665 const GURL& icon_url, |
| 653 favicon_base::IconType icon_type, | 666 favicon_base::IconType icon_type, |
| 654 scoped_refptr<base::RefCountedMemory> bitmap_data, | 667 scoped_refptr<base::RefCountedMemory> bitmap_data, |
| 655 const gfx::Size& pixel_size) { | 668 const gfx::Size& pixel_size) { |
| 669 DCHECK(thread_) << "History service being called after cleanup"; |
| 656 DCHECK(thread_checker_.CalledOnValidThread()); | 670 DCHECK(thread_checker_.CalledOnValidThread()); |
| 657 if (!CanAddURL(page_url)) | 671 if (!CanAddURL(page_url)) |
| 658 return; | 672 return; |
| 659 | 673 |
| 660 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::MergeFavicon, page_url, | 674 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::MergeFavicon, page_url, |
| 661 icon_url, icon_type, bitmap_data, pixel_size); | 675 icon_url, icon_type, bitmap_data, pixel_size); |
| 662 } | 676 } |
| 663 | 677 |
| 664 void HistoryService::SetFavicons( | 678 void HistoryService::SetFavicons( |
| 665 const GURL& page_url, | 679 const GURL& page_url, |
| 666 favicon_base::IconType icon_type, | 680 favicon_base::IconType icon_type, |
| 667 const std::vector<favicon_base::FaviconRawBitmapData>& | 681 const std::vector<favicon_base::FaviconRawBitmapData>& |
| 668 favicon_bitmap_data) { | 682 favicon_bitmap_data) { |
| 683 DCHECK(thread_) << "History service being called after cleanup"; |
| 669 DCHECK(thread_checker_.CalledOnValidThread()); | 684 DCHECK(thread_checker_.CalledOnValidThread()); |
| 670 if (!CanAddURL(page_url)) | 685 if (!CanAddURL(page_url)) |
| 671 return; | 686 return; |
| 672 | 687 |
| 673 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::SetFavicons, page_url, | 688 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::SetFavicons, page_url, |
| 674 icon_type, favicon_bitmap_data); | 689 icon_type, favicon_bitmap_data); |
| 675 } | 690 } |
| 676 | 691 |
| 677 void HistoryService::SetFaviconsOutOfDateForPage(const GURL& page_url) { | 692 void HistoryService::SetFaviconsOutOfDateForPage(const GURL& page_url) { |
| 693 DCHECK(thread_) << "History service being called after cleanup"; |
| 678 DCHECK(thread_checker_.CalledOnValidThread()); | 694 DCHECK(thread_checker_.CalledOnValidThread()); |
| 679 ScheduleAndForget(PRIORITY_NORMAL, | 695 ScheduleAndForget(PRIORITY_NORMAL, |
| 680 &HistoryBackend::SetFaviconsOutOfDateForPage, page_url); | 696 &HistoryBackend::SetFaviconsOutOfDateForPage, page_url); |
| 681 } | 697 } |
| 682 | 698 |
| 683 void HistoryService::CloneFavicons(const GURL& old_page_url, | 699 void HistoryService::CloneFavicons(const GURL& old_page_url, |
| 684 const GURL& new_page_url) { | 700 const GURL& new_page_url) { |
| 701 DCHECK(thread_) << "History service being called after cleanup"; |
| 685 DCHECK(thread_checker_.CalledOnValidThread()); | 702 DCHECK(thread_checker_.CalledOnValidThread()); |
| 686 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::CloneFavicons, | 703 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::CloneFavicons, |
| 687 old_page_url, new_page_url); | 704 old_page_url, new_page_url); |
| 688 } | 705 } |
| 689 | 706 |
| 690 void HistoryService::SetImportedFavicons( | 707 void HistoryService::SetImportedFavicons( |
| 691 const std::vector<ImportedFaviconUsage>& favicon_usage) { | 708 const std::vector<ImportedFaviconUsage>& favicon_usage) { |
| 709 DCHECK(thread_) << "History service being called after cleanup"; |
| 692 DCHECK(thread_checker_.CalledOnValidThread()); | 710 DCHECK(thread_checker_.CalledOnValidThread()); |
| 693 ScheduleAndForget(PRIORITY_NORMAL, | 711 ScheduleAndForget(PRIORITY_NORMAL, |
| 694 &HistoryBackend::SetImportedFavicons, favicon_usage); | 712 &HistoryBackend::SetImportedFavicons, favicon_usage); |
| 695 } | 713 } |
| 696 | 714 |
| 697 base::CancelableTaskTracker::TaskId HistoryService::QueryURL( | 715 base::CancelableTaskTracker::TaskId HistoryService::QueryURL( |
| 698 const GURL& url, | 716 const GURL& url, |
| 699 bool want_visits, | 717 bool want_visits, |
| 700 const QueryURLCallback& callback, | 718 const QueryURLCallback& callback, |
| 701 base::CancelableTaskTracker* tracker) { | 719 base::CancelableTaskTracker* tracker) { |
| 720 DCHECK(thread_) << "History service being called after cleanup"; |
| 702 DCHECK(thread_checker_.CalledOnValidThread()); | 721 DCHECK(thread_checker_.CalledOnValidThread()); |
| 703 history::QueryURLResult* query_url_result = new history::QueryURLResult(); | 722 history::QueryURLResult* query_url_result = new history::QueryURLResult(); |
| 704 return tracker->PostTaskAndReply( | 723 return tracker->PostTaskAndReply( |
| 705 thread_->message_loop_proxy().get(), | 724 thread_->message_loop_proxy().get(), |
| 706 FROM_HERE, | 725 FROM_HERE, |
| 707 base::Bind(&HistoryBackend::QueryURL, | 726 base::Bind(&HistoryBackend::QueryURL, |
| 708 history_backend_.get(), | 727 history_backend_.get(), |
| 709 url, | 728 url, |
| 710 want_visits, | 729 want_visits, |
| 711 base::Unretained(query_url_result)), | 730 base::Unretained(query_url_result)), |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 // Bind's arguments. | 773 // Bind's arguments. |
| 755 thread_->message_loop_proxy()->PostTaskAndReply( | 774 thread_->message_loop_proxy()->PostTaskAndReply( |
| 756 FROM_HERE, | 775 FROM_HERE, |
| 757 base::Bind(&HistoryBackend::QueryDownloads, history_backend_.get(), rows), | 776 base::Bind(&HistoryBackend::QueryDownloads, history_backend_.get(), rows), |
| 758 base::Bind(callback, base::Passed(&scoped_rows))); | 777 base::Bind(callback, base::Passed(&scoped_rows))); |
| 759 } | 778 } |
| 760 | 779 |
| 761 // Handle updates for a particular download. This is a 'fire and forget' | 780 // Handle updates for a particular download. This is a 'fire and forget' |
| 762 // operation, so we don't need to be called back. | 781 // operation, so we don't need to be called back. |
| 763 void HistoryService::UpdateDownload(const history::DownloadRow& data) { | 782 void HistoryService::UpdateDownload(const history::DownloadRow& data) { |
| 783 DCHECK(thread_) << "History service being called after cleanup"; |
| 764 DCHECK(thread_checker_.CalledOnValidThread()); | 784 DCHECK(thread_checker_.CalledOnValidThread()); |
| 765 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::UpdateDownload, data); | 785 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::UpdateDownload, data); |
| 766 } | 786 } |
| 767 | 787 |
| 768 void HistoryService::RemoveDownloads(const std::set<uint32>& ids) { | 788 void HistoryService::RemoveDownloads(const std::set<uint32>& ids) { |
| 789 DCHECK(thread_) << "History service being called after cleanup"; |
| 769 DCHECK(thread_checker_.CalledOnValidThread()); | 790 DCHECK(thread_checker_.CalledOnValidThread()); |
| 770 ScheduleAndForget(PRIORITY_NORMAL, | 791 ScheduleAndForget(PRIORITY_NORMAL, |
| 771 &HistoryBackend::RemoveDownloads, ids); | 792 &HistoryBackend::RemoveDownloads, ids); |
| 772 } | 793 } |
| 773 | 794 |
| 774 base::CancelableTaskTracker::TaskId HistoryService::QueryHistory( | 795 base::CancelableTaskTracker::TaskId HistoryService::QueryHistory( |
| 775 const base::string16& text_query, | 796 const base::string16& text_query, |
| 776 const history::QueryOptions& options, | 797 const history::QueryOptions& options, |
| 777 const QueryHistoryCallback& callback, | 798 const QueryHistoryCallback& callback, |
| 778 base::CancelableTaskTracker* tracker) { | 799 base::CancelableTaskTracker* tracker) { |
| 800 DCHECK(thread_) << "History service being called after cleanup"; |
| 779 DCHECK(thread_checker_.CalledOnValidThread()); | 801 DCHECK(thread_checker_.CalledOnValidThread()); |
| 780 history::QueryResults* query_results = new history::QueryResults(); | 802 history::QueryResults* query_results = new history::QueryResults(); |
| 781 return tracker->PostTaskAndReply( | 803 return tracker->PostTaskAndReply( |
| 782 thread_->message_loop_proxy().get(), | 804 thread_->message_loop_proxy().get(), |
| 783 FROM_HERE, | 805 FROM_HERE, |
| 784 base::Bind(&HistoryBackend::QueryHistory, | 806 base::Bind(&HistoryBackend::QueryHistory, |
| 785 history_backend_.get(), | 807 history_backend_.get(), |
| 786 text_query, | 808 text_query, |
| 787 options, | 809 options, |
| 788 base::Unretained(query_results)), | 810 base::Unretained(query_results)), |
| 789 base::Bind(callback, base::Owned(query_results))); | 811 base::Bind(callback, base::Owned(query_results))); |
| 790 } | 812 } |
| 791 | 813 |
| 792 base::CancelableTaskTracker::TaskId HistoryService::QueryRedirectsFrom( | 814 base::CancelableTaskTracker::TaskId HistoryService::QueryRedirectsFrom( |
| 793 const GURL& from_url, | 815 const GURL& from_url, |
| 794 const QueryRedirectsCallback& callback, | 816 const QueryRedirectsCallback& callback, |
| 795 base::CancelableTaskTracker* tracker) { | 817 base::CancelableTaskTracker* tracker) { |
| 818 DCHECK(thread_) << "History service being called after cleanup"; |
| 796 DCHECK(thread_checker_.CalledOnValidThread()); | 819 DCHECK(thread_checker_.CalledOnValidThread()); |
| 797 history::RedirectList* result = new history::RedirectList(); | 820 history::RedirectList* result = new history::RedirectList(); |
| 798 return tracker->PostTaskAndReply( | 821 return tracker->PostTaskAndReply( |
| 799 thread_->message_loop_proxy().get(), | 822 thread_->message_loop_proxy().get(), |
| 800 FROM_HERE, | 823 FROM_HERE, |
| 801 base::Bind(&HistoryBackend::QueryRedirectsFrom, | 824 base::Bind(&HistoryBackend::QueryRedirectsFrom, |
| 802 history_backend_.get(), | 825 history_backend_.get(), |
| 803 from_url, | 826 from_url, |
| 804 base::Unretained(result)), | 827 base::Unretained(result)), |
| 805 base::Bind(callback, base::Owned(result))); | 828 base::Bind(callback, base::Owned(result))); |
| 806 } | 829 } |
| 807 | 830 |
| 808 base::CancelableTaskTracker::TaskId HistoryService::QueryRedirectsTo( | 831 base::CancelableTaskTracker::TaskId HistoryService::QueryRedirectsTo( |
| 809 const GURL& to_url, | 832 const GURL& to_url, |
| 810 const QueryRedirectsCallback& callback, | 833 const QueryRedirectsCallback& callback, |
| 811 base::CancelableTaskTracker* tracker) { | 834 base::CancelableTaskTracker* tracker) { |
| 835 DCHECK(thread_) << "History service being called after cleanup"; |
| 812 DCHECK(thread_checker_.CalledOnValidThread()); | 836 DCHECK(thread_checker_.CalledOnValidThread()); |
| 813 history::RedirectList* result = new history::RedirectList(); | 837 history::RedirectList* result = new history::RedirectList(); |
| 814 return tracker->PostTaskAndReply(thread_->message_loop_proxy().get(), | 838 return tracker->PostTaskAndReply(thread_->message_loop_proxy().get(), |
| 815 FROM_HERE, | 839 FROM_HERE, |
| 816 base::Bind(&HistoryBackend::QueryRedirectsTo, | 840 base::Bind(&HistoryBackend::QueryRedirectsTo, |
| 817 history_backend_.get(), | 841 history_backend_.get(), |
| 818 to_url, | 842 to_url, |
| 819 base::Unretained(result)), | 843 base::Unretained(result)), |
| 820 base::Bind(callback, base::Owned(result))); | 844 base::Bind(callback, base::Owned(result))); |
| 821 } | 845 } |
| 822 | 846 |
| 823 base::CancelableTaskTracker::TaskId HistoryService::GetVisibleVisitCountToHost( | 847 base::CancelableTaskTracker::TaskId HistoryService::GetVisibleVisitCountToHost( |
| 824 const GURL& url, | 848 const GURL& url, |
| 825 const GetVisibleVisitCountToHostCallback& callback, | 849 const GetVisibleVisitCountToHostCallback& callback, |
| 826 base::CancelableTaskTracker* tracker) { | 850 base::CancelableTaskTracker* tracker) { |
| 851 DCHECK(thread_) << "History service being called after cleanup"; |
| 827 DCHECK(thread_checker_.CalledOnValidThread()); | 852 DCHECK(thread_checker_.CalledOnValidThread()); |
| 828 history::VisibleVisitCountToHostResult* result = | 853 history::VisibleVisitCountToHostResult* result = |
| 829 new history::VisibleVisitCountToHostResult(); | 854 new history::VisibleVisitCountToHostResult(); |
| 830 return tracker->PostTaskAndReply( | 855 return tracker->PostTaskAndReply( |
| 831 thread_->message_loop_proxy().get(), | 856 thread_->message_loop_proxy().get(), |
| 832 FROM_HERE, | 857 FROM_HERE, |
| 833 base::Bind(&HistoryBackend::GetVisibleVisitCountToHost, | 858 base::Bind(&HistoryBackend::GetVisibleVisitCountToHost, |
| 834 history_backend_.get(), | 859 history_backend_.get(), |
| 835 url, | 860 url, |
| 836 base::Unretained(result)), | 861 base::Unretained(result)), |
| 837 base::Bind(&RunWithVisibleVisitCountToHostResult, | 862 base::Bind(&RunWithVisibleVisitCountToHostResult, |
| 838 callback, | 863 callback, |
| 839 base::Owned(result))); | 864 base::Owned(result))); |
| 840 } | 865 } |
| 841 | 866 |
| 842 base::CancelableTaskTracker::TaskId HistoryService::QueryMostVisitedURLs( | 867 base::CancelableTaskTracker::TaskId HistoryService::QueryMostVisitedURLs( |
| 843 int result_count, | 868 int result_count, |
| 844 int days_back, | 869 int days_back, |
| 845 const QueryMostVisitedURLsCallback& callback, | 870 const QueryMostVisitedURLsCallback& callback, |
| 846 base::CancelableTaskTracker* tracker) { | 871 base::CancelableTaskTracker* tracker) { |
| 872 DCHECK(thread_) << "History service being called after cleanup"; |
| 847 DCHECK(thread_checker_.CalledOnValidThread()); | 873 DCHECK(thread_checker_.CalledOnValidThread()); |
| 848 history::MostVisitedURLList* result = new history::MostVisitedURLList(); | 874 history::MostVisitedURLList* result = new history::MostVisitedURLList(); |
| 849 return tracker->PostTaskAndReply( | 875 return tracker->PostTaskAndReply( |
| 850 thread_->message_loop_proxy().get(), | 876 thread_->message_loop_proxy().get(), |
| 851 FROM_HERE, | 877 FROM_HERE, |
| 852 base::Bind(&HistoryBackend::QueryMostVisitedURLs, | 878 base::Bind(&HistoryBackend::QueryMostVisitedURLs, |
| 853 history_backend_.get(), | 879 history_backend_.get(), |
| 854 result_count, | 880 result_count, |
| 855 days_back, | 881 days_back, |
| 856 base::Unretained(result)), | 882 base::Unretained(result)), |
| 857 base::Bind(callback, base::Owned(result))); | 883 base::Bind(callback, base::Owned(result))); |
| 858 } | 884 } |
| 859 | 885 |
| 860 base::CancelableTaskTracker::TaskId HistoryService::QueryFilteredURLs( | 886 base::CancelableTaskTracker::TaskId HistoryService::QueryFilteredURLs( |
| 861 int result_count, | 887 int result_count, |
| 862 const history::VisitFilter& filter, | 888 const history::VisitFilter& filter, |
| 863 bool extended_info, | 889 bool extended_info, |
| 864 const QueryFilteredURLsCallback& callback, | 890 const QueryFilteredURLsCallback& callback, |
| 865 base::CancelableTaskTracker* tracker) { | 891 base::CancelableTaskTracker* tracker) { |
| 892 DCHECK(thread_) << "History service being called after cleanup"; |
| 866 DCHECK(thread_checker_.CalledOnValidThread()); | 893 DCHECK(thread_checker_.CalledOnValidThread()); |
| 867 history::FilteredURLList* result = new history::FilteredURLList(); | 894 history::FilteredURLList* result = new history::FilteredURLList(); |
| 868 return tracker->PostTaskAndReply( | 895 return tracker->PostTaskAndReply( |
| 869 thread_->message_loop_proxy().get(), | 896 thread_->message_loop_proxy().get(), |
| 870 FROM_HERE, | 897 FROM_HERE, |
| 871 base::Bind(&HistoryBackend::QueryFilteredURLs, | 898 base::Bind(&HistoryBackend::QueryFilteredURLs, |
| 872 history_backend_.get(), | 899 history_backend_.get(), |
| 873 result_count, | 900 result_count, |
| 874 filter, | 901 filter, |
| 875 extended_info, | 902 extended_info, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 908 break; | 935 break; |
| 909 } | 936 } |
| 910 | 937 |
| 911 default: | 938 default: |
| 912 NOTREACHED(); | 939 NOTREACHED(); |
| 913 } | 940 } |
| 914 } | 941 } |
| 915 | 942 |
| 916 void HistoryService::RebuildTable( | 943 void HistoryService::RebuildTable( |
| 917 const scoped_refptr<URLEnumerator>& enumerator) { | 944 const scoped_refptr<URLEnumerator>& enumerator) { |
| 945 DCHECK(thread_) << "History service being called after cleanup"; |
| 918 DCHECK(thread_checker_.CalledOnValidThread()); | 946 DCHECK(thread_checker_.CalledOnValidThread()); |
| 919 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::IterateURLs, enumerator); | 947 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::IterateURLs, enumerator); |
| 920 } | 948 } |
| 921 | 949 |
| 922 bool HistoryService::Init(const base::FilePath& history_dir, bool no_db) { | 950 bool HistoryService::Init(const base::FilePath& history_dir, bool no_db) { |
| 951 DCHECK(thread_) << "History service being called after cleanup"; |
| 923 DCHECK(thread_checker_.CalledOnValidThread()); | 952 DCHECK(thread_checker_.CalledOnValidThread()); |
| 924 base::Thread::Options options; | 953 base::Thread::Options options; |
| 925 options.timer_slack = base::TIMER_SLACK_MAXIMUM; | 954 options.timer_slack = base::TIMER_SLACK_MAXIMUM; |
| 926 if (!thread_->StartWithOptions(options)) { | 955 if (!thread_->StartWithOptions(options)) { |
| 927 Cleanup(); | 956 Cleanup(); |
| 928 return false; | 957 return false; |
| 929 } | 958 } |
| 930 | 959 |
| 931 history_dir_ = history_dir; | 960 history_dir_ = history_dir; |
| 932 no_db_ = no_db; | 961 no_db_ = no_db; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1061 in_memory_backend_->AttachToHistoryService(profile_); | 1090 in_memory_backend_->AttachToHistoryService(profile_); |
| 1062 } | 1091 } |
| 1063 | 1092 |
| 1064 void HistoryService::NotifyProfileError(sql::InitStatus init_status) { | 1093 void HistoryService::NotifyProfileError(sql::InitStatus init_status) { |
| 1065 DCHECK(thread_checker_.CalledOnValidThread()); | 1094 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1066 if (history_client_) | 1095 if (history_client_) |
| 1067 history_client_->NotifyProfileError(init_status); | 1096 history_client_->NotifyProfileError(init_status); |
| 1068 } | 1097 } |
| 1069 | 1098 |
| 1070 void HistoryService::DeleteURL(const GURL& url) { | 1099 void HistoryService::DeleteURL(const GURL& url) { |
| 1100 DCHECK(thread_) << "History service being called after cleanup"; |
| 1071 DCHECK(thread_checker_.CalledOnValidThread()); | 1101 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1072 // We will update the visited links when we observe the delete notifications. | 1102 // We will update the visited links when we observe the delete notifications. |
| 1073 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::DeleteURL, url); | 1103 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::DeleteURL, url); |
| 1074 } | 1104 } |
| 1075 | 1105 |
| 1076 void HistoryService::DeleteURLsForTest(const std::vector<GURL>& urls) { | 1106 void HistoryService::DeleteURLsForTest(const std::vector<GURL>& urls) { |
| 1107 DCHECK(thread_) << "History service being called after cleanup"; |
| 1077 DCHECK(thread_checker_.CalledOnValidThread()); | 1108 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1078 // We will update the visited links when we observe the delete | 1109 // We will update the visited links when we observe the delete |
| 1079 // notifications. | 1110 // notifications. |
| 1080 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::DeleteURLs, urls); | 1111 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::DeleteURLs, urls); |
| 1081 } | 1112 } |
| 1082 | 1113 |
| 1083 void HistoryService::ExpireHistoryBetween( | 1114 void HistoryService::ExpireHistoryBetween( |
| 1084 const std::set<GURL>& restrict_urls, | 1115 const std::set<GURL>& restrict_urls, |
| 1085 Time begin_time, | 1116 Time begin_time, |
| 1086 Time end_time, | 1117 Time end_time, |
| 1087 const base::Closure& callback, | 1118 const base::Closure& callback, |
| 1088 base::CancelableTaskTracker* tracker) { | 1119 base::CancelableTaskTracker* tracker) { |
| 1089 DCHECK(thread_); | 1120 DCHECK(thread_) << "History service being called after cleanup"; |
| 1090 DCHECK(thread_checker_.CalledOnValidThread()); | 1121 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1091 DCHECK(history_backend_.get()); | |
| 1092 tracker->PostTaskAndReply(thread_->message_loop_proxy().get(), | 1122 tracker->PostTaskAndReply(thread_->message_loop_proxy().get(), |
| 1093 FROM_HERE, | 1123 FROM_HERE, |
| 1094 base::Bind(&HistoryBackend::ExpireHistoryBetween, | 1124 base::Bind(&HistoryBackend::ExpireHistoryBetween, |
| 1095 history_backend_, | 1125 history_backend_, |
| 1096 restrict_urls, | 1126 restrict_urls, |
| 1097 begin_time, | 1127 begin_time, |
| 1098 end_time), | 1128 end_time), |
| 1099 callback); | 1129 callback); |
| 1100 } | 1130 } |
| 1101 | 1131 |
| 1102 void HistoryService::ExpireHistory( | 1132 void HistoryService::ExpireHistory( |
| 1103 const std::vector<history::ExpireHistoryArgs>& expire_list, | 1133 const std::vector<history::ExpireHistoryArgs>& expire_list, |
| 1104 const base::Closure& callback, | 1134 const base::Closure& callback, |
| 1105 base::CancelableTaskTracker* tracker) { | 1135 base::CancelableTaskTracker* tracker) { |
| 1106 DCHECK(thread_); | 1136 DCHECK(thread_) << "History service being called after cleanup"; |
| 1107 DCHECK(thread_checker_.CalledOnValidThread()); | 1137 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1108 DCHECK(history_backend_.get()); | |
| 1109 tracker->PostTaskAndReply( | 1138 tracker->PostTaskAndReply( |
| 1110 thread_->message_loop_proxy().get(), | 1139 thread_->message_loop_proxy().get(), |
| 1111 FROM_HERE, | 1140 FROM_HERE, |
| 1112 base::Bind(&HistoryBackend::ExpireHistory, history_backend_, expire_list), | 1141 base::Bind(&HistoryBackend::ExpireHistory, history_backend_, expire_list), |
| 1113 callback); | 1142 callback); |
| 1114 } | 1143 } |
| 1115 | 1144 |
| 1116 void HistoryService::ExpireLocalAndRemoteHistoryBetween( | 1145 void HistoryService::ExpireLocalAndRemoteHistoryBetween( |
| 1117 const std::set<GURL>& restrict_urls, | 1146 const std::set<GURL>& restrict_urls, |
| 1118 Time begin_time, | 1147 Time begin_time, |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1194 DCHECK(thread_checker_.CalledOnValidThread()); | 1223 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1195 visit_database_observers_.RemoveObserver(observer); | 1224 visit_database_observers_.RemoveObserver(observer); |
| 1196 } | 1225 } |
| 1197 | 1226 |
| 1198 void HistoryService::NotifyVisitDBObserversOnAddVisit( | 1227 void HistoryService::NotifyVisitDBObserversOnAddVisit( |
| 1199 const history::BriefVisitInfo& info) { | 1228 const history::BriefVisitInfo& info) { |
| 1200 DCHECK(thread_checker_.CalledOnValidThread()); | 1229 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1201 FOR_EACH_OBSERVER(history::VisitDatabaseObserver, visit_database_observers_, | 1230 FOR_EACH_OBSERVER(history::VisitDatabaseObserver, visit_database_observers_, |
| 1202 OnAddVisit(info)); | 1231 OnAddVisit(info)); |
| 1203 } | 1232 } |
| OLD | NEW |