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

Side by Side Diff: components/history/core/browser/history_service.cc

Issue 2732653002: Add favicon integration tests for FaviconDriverImpl (Closed)
Patch Set: Added verification of color Created 3 years, 9 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 | « components/history/core/browser/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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 // Use base::ThreadTaskRunnerHandler::Get() to get a task runner for 311 // Use base::ThreadTaskRunnerHandler::Get() to get a task runner for
312 // the current message loop so that we can forward the call to the method 312 // the current message loop so that we can forward the call to the method
313 // HistoryDBTask::DoneRunOnMainThread() in the correct thread. 313 // HistoryDBTask::DoneRunOnMainThread() in the correct thread.
314 backend_task_runner_->PostTask( 314 backend_task_runner_->PostTask(
315 FROM_HERE, base::Bind(&HistoryBackend::ProcessDBTask, history_backend_, 315 FROM_HERE, base::Bind(&HistoryBackend::ProcessDBTask, history_backend_,
316 base::Passed(&task), 316 base::Passed(&task),
317 base::ThreadTaskRunnerHandle::Get(), is_canceled)); 317 base::ThreadTaskRunnerHandle::Get(), is_canceled));
318 return task_id; 318 return task_id;
319 } 319 }
320 320
321 bool HistoryService::InitForTest(
322 const HistoryDatabaseParams& history_database_params,
323 scoped_refptr<base::SequencedTaskRunner> task_runner) {
324 return InitWithTaskRunner(/*no_db=*/false, history_database_params,
325 task_runner);
326 }
327
321 void HistoryService::FlushForTest(const base::Closure& flushed) { 328 void HistoryService::FlushForTest(const base::Closure& flushed) {
322 backend_task_runner_->PostTaskAndReply(FROM_HERE, 329 backend_task_runner_->PostTaskAndReply(FROM_HERE,
323 base::Bind(&base::DoNothing), flushed); 330 base::Bind(&base::DoNothing), flushed);
324 } 331 }
325 332
326 void HistoryService::SetOnBackendDestroyTask(const base::Closure& task) { 333 void HistoryService::SetOnBackendDestroyTask(const base::Closure& task) {
327 DCHECK(backend_task_runner_) << "History service being called after cleanup"; 334 DCHECK(backend_task_runner_) << "History service being called after cleanup";
328 DCHECK(thread_checker_.CalledOnValidThread()); 335 DCHECK(thread_checker_.CalledOnValidThread());
329 ScheduleTask( 336 ScheduleTask(
330 PRIORITY_NORMAL, 337 PRIORITY_NORMAL,
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 870
864 // Join the background thread, if any. 871 // Join the background thread, if any.
865 thread_.reset(); 872 thread_.reset();
866 } 873 }
867 874
868 bool HistoryService::Init( 875 bool HistoryService::Init(
869 bool no_db, 876 bool no_db,
870 const HistoryDatabaseParams& history_database_params) { 877 const HistoryDatabaseParams& history_database_params) {
871 TRACE_EVENT0("browser,startup", "HistoryService::Init") 878 TRACE_EVENT0("browser,startup", "HistoryService::Init")
872 SCOPED_UMA_HISTOGRAM_TIMER("History.HistoryServiceInitTime"); 879 SCOPED_UMA_HISTOGRAM_TIMER("History.HistoryServiceInitTime");
873 DCHECK(thread_checker_.CalledOnValidThread());
874 DCHECK(!backend_task_runner_);
875 880
876 if (thread_) { 881 if (thread_) {
877 base::Thread::Options options; 882 base::Thread::Options options;
878 options.timer_slack = base::TIMER_SLACK_MAXIMUM; 883 options.timer_slack = base::TIMER_SLACK_MAXIMUM;
879 if (!thread_->StartWithOptions(options)) { 884 if (!thread_->StartWithOptions(options)) {
880 Cleanup(); 885 Cleanup();
881 return false; 886 return false;
882 } 887 }
883 backend_task_runner_ = thread_->task_runner(); 888 return InitWithTaskRunner(no_db, history_database_params,
889 thread_->task_runner());
884 } else { 890 } else {
885 backend_task_runner_ = base::CreateSequencedTaskRunnerWithTraits( 891 return InitWithTaskRunner(
886 base::TaskTraits() 892 no_db, history_database_params,
887 .WithPriority(base::TaskPriority::USER_BLOCKING) 893 base::CreateSequencedTaskRunnerWithTraits(
888 .WithShutdownBehavior(base::TaskShutdownBehavior::BLOCK_SHUTDOWN) 894 base::TaskTraits()
889 .MayBlock() 895 .WithPriority(base::TaskPriority::USER_BLOCKING)
890 .WithBaseSyncPrimitives()); 896 .WithShutdownBehavior(
897 base::TaskShutdownBehavior::BLOCK_SHUTDOWN)
898 .MayBlock()
899 .WithBaseSyncPrimitives()));
891 } 900 }
901 }
902
903 bool HistoryService::InitWithTaskRunner(
904 bool no_db,
905 const HistoryDatabaseParams& history_database_params,
906 scoped_refptr<base::SequencedTaskRunner> task_runner) {
907 DCHECK(thread_checker_.CalledOnValidThread());
908 DCHECK(!backend_task_runner_);
909
910 backend_task_runner_ = task_runner;
892 911
893 // Create the history backend. 912 // Create the history backend.
894 scoped_refptr<HistoryBackend> backend(new HistoryBackend( 913 scoped_refptr<HistoryBackend> backend(new HistoryBackend(
895 new BackendDelegate(weak_ptr_factory_.GetWeakPtr(), 914 new BackendDelegate(weak_ptr_factory_.GetWeakPtr(),
896 base::ThreadTaskRunnerHandle::Get()), 915 base::ThreadTaskRunnerHandle::Get()),
897 history_client_ ? history_client_->CreateBackendClient() : nullptr, 916 history_client_ ? history_client_->CreateBackendClient() : nullptr,
898 backend_task_runner_)); 917 backend_task_runner_));
899 history_backend_.swap(backend); 918 history_backend_.swap(backend);
900 919
901 ScheduleTask(PRIORITY_UI, 920 ScheduleTask(PRIORITY_UI,
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
1149 return favicon_changed_callback_list_.Add(callback); 1168 return favicon_changed_callback_list_.Add(callback);
1150 } 1169 }
1151 1170
1152 void HistoryService::NotifyFaviconsChanged(const std::set<GURL>& page_urls, 1171 void HistoryService::NotifyFaviconsChanged(const std::set<GURL>& page_urls,
1153 const GURL& icon_url) { 1172 const GURL& icon_url) {
1154 DCHECK(thread_checker_.CalledOnValidThread()); 1173 DCHECK(thread_checker_.CalledOnValidThread());
1155 favicon_changed_callback_list_.Notify(page_urls, icon_url); 1174 favicon_changed_callback_list_.Notify(page_urls, icon_url);
1156 } 1175 }
1157 1176
1158 } // namespace history 1177 } // namespace history
OLDNEW
« no previous file with comments | « components/history/core/browser/history_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698