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

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

Issue 10963018: Rework arguments of HistoryService::AddPage() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Windows compile Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/history/history.h ('k') | chrome/browser/history/history_backend.h » ('j') | 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 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 consumer, new history::QuerySegmentUsageRequest(callback), 337 consumer, new history::QuerySegmentUsageRequest(callback),
338 from_time, max_result_count); 338 from_time, max_result_count);
339 } 339 }
340 340
341 void HistoryService::SetOnBackendDestroyTask(const base::Closure& task) { 341 void HistoryService::SetOnBackendDestroyTask(const base::Closure& task) {
342 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::SetOnBackendDestroyTask, 342 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::SetOnBackendDestroyTask,
343 MessageLoop::current(), task); 343 MessageLoop::current(), task);
344 } 344 }
345 345
346 void HistoryService::AddPage(const GURL& url, 346 void HistoryService::AddPage(const GURL& url,
347 const void* id_scope,
348 int32 page_id,
349 const GURL& referrer,
350 content::PageTransition transition,
351 const history::RedirectList& redirects,
352 history::VisitSource visit_source,
353 bool did_replace_entry) {
354 AddPage(url, Time::Now(), id_scope, page_id, referrer, transition, redirects,
355 visit_source, did_replace_entry);
356 }
357
358 void HistoryService::AddPage(const GURL& url,
359 Time time, 347 Time time,
360 const void* id_scope, 348 const void* id_scope,
361 int32 page_id, 349 int32 page_id,
362 const GURL& referrer, 350 const GURL& referrer,
351 const history::RedirectList& redirects,
363 content::PageTransition transition, 352 content::PageTransition transition,
364 const history::RedirectList& redirects,
365 history::VisitSource visit_source, 353 history::VisitSource visit_source,
366 bool did_replace_entry) { 354 bool did_replace_entry) {
367 scoped_refptr<history::HistoryAddPageArgs> request( 355 AddPage(
368 new history::HistoryAddPageArgs(url, time, id_scope, page_id, referrer, 356 history::HistoryAddPageArgs(url, time, id_scope, page_id, referrer,
369 redirects, transition, visit_source, 357 redirects, transition, visit_source,
370 did_replace_entry)); 358 did_replace_entry));
371 AddPage(*request); 359 }
360
361 void HistoryService::AddPage(const GURL& url,
362 base::Time time,
363 history::VisitSource visit_source) {
364 AddPage(
365 history::HistoryAddPageArgs(url, time, NULL, 0, GURL(),
366 history::RedirectList(),
367 content::PAGE_TRANSITION_LINK,
368 visit_source, false));
372 } 369 }
373 370
374 void HistoryService::AddPage(const history::HistoryAddPageArgs& add_page_args) { 371 void HistoryService::AddPage(const history::HistoryAddPageArgs& add_page_args) {
375 DCHECK(thread_) << "History service being called after cleanup"; 372 DCHECK(thread_) << "History service being called after cleanup";
376 373
377 // Filter out unwanted URLs. We don't add auto-subframe URLs. They are a 374 // Filter out unwanted URLs. We don't add auto-subframe URLs. They are a
378 // large part of history (think iframes for ads) and we never display them in 375 // large part of history (think iframes for ads) and we never display them in
379 // history UI. We will still add manual subframes, which are ones the user 376 // history UI. We will still add manual subframes, which are ones the user
380 // has clicked on to get. 377 // has clicked on to get.
381 if (!CanAddURL(add_page_args.url)) 378 if (!CanAddURL(add_page_args.url))
382 return; 379 return;
383 380
384 // Add link & all redirects to visited link list. 381 // Add link & all redirects to visited link list.
385 VisitedLinkMaster* visited_links; 382 VisitedLinkMaster* visited_links;
386 if (profile_ && (visited_links = profile_->GetVisitedLinkMaster())) { 383 if (profile_ && (visited_links = profile_->GetVisitedLinkMaster())) {
387 visited_links->AddURL(add_page_args.url); 384 visited_links->AddURL(add_page_args.url);
388 385
389 if (!add_page_args.redirects.empty()) { 386 if (!add_page_args.redirects.empty()) {
390 // We should not be asked to add a page in the middle of a redirect chain. 387 // We should not be asked to add a page in the middle of a redirect chain.
391 DCHECK_EQ(add_page_args.url, 388 DCHECK_EQ(add_page_args.url,
392 add_page_args.redirects[add_page_args.redirects.size() - 1]); 389 add_page_args.redirects[add_page_args.redirects.size() - 1]);
393 390
394 // We need the !redirects.empty() condition above since size_t is unsigned 391 // We need the !redirects.empty() condition above since size_t is unsigned
395 // and will wrap around when we subtract one from a 0 size. 392 // and will wrap around when we subtract one from a 0 size.
396 for (size_t i = 0; i < add_page_args.redirects.size() - 1; i++) 393 for (size_t i = 0; i < add_page_args.redirects.size() - 1; i++)
397 visited_links->AddURL(add_page_args.redirects[i]); 394 visited_links->AddURL(add_page_args.redirects[i]);
398 } 395 }
399 } 396 }
400 397
401 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::AddPage, 398 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::AddPage, add_page_args);
402 scoped_refptr<history::HistoryAddPageArgs>(
403 add_page_args.Clone()));
404 } 399 }
405 400
406 void HistoryService::AddPageNoVisitForBookmark(const GURL& url, 401 void HistoryService::AddPageNoVisitForBookmark(const GURL& url,
407 const string16& title) { 402 const string16& title) {
408 if (!CanAddURL(url)) 403 if (!CanAddURL(url))
409 return; 404 return;
410 405
411 ScheduleAndForget(PRIORITY_NORMAL, 406 ScheduleAndForget(PRIORITY_NORMAL,
412 &HistoryBackend::AddPageNoVisitForBookmark, url, title); 407 &HistoryBackend::AddPageNoVisitForBookmark, url, title);
413 } 408 }
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 void HistoryService::RemoveVisitDatabaseObserver( 950 void HistoryService::RemoveVisitDatabaseObserver(
956 history::VisitDatabaseObserver* observer) { 951 history::VisitDatabaseObserver* observer) {
957 visit_database_observers_->RemoveObserver(observer); 952 visit_database_observers_->RemoveObserver(observer);
958 } 953 }
959 954
960 void HistoryService::NotifyVisitDBObserversOnAddVisit( 955 void HistoryService::NotifyVisitDBObserversOnAddVisit(
961 const history::BriefVisitInfo& info) { 956 const history::BriefVisitInfo& info) {
962 visit_database_observers_->Notify( 957 visit_database_observers_->Notify(
963 &history::VisitDatabaseObserver::OnAddVisit, info); 958 &history::VisitDatabaseObserver::OnAddVisit, info);
964 } 959 }
OLDNEW
« no previous file with comments | « chrome/browser/history/history.h ('k') | chrome/browser/history/history_backend.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698