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

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

Issue 322983003: Rename HistoryService::NotifyRenderProcessHostDestruction (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments Created 6 years, 6 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
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 #include "chrome/browser/history/history_backend.h" 5 #include "chrome/browser/history/history_backend.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <list> 9 #include <list>
10 #include <map> 10 #include <map>
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 void HistoryBackend::Closing() { 213 void HistoryBackend::Closing() {
214 // Any scheduled commit will have a reference to us, we must make it 214 // Any scheduled commit will have a reference to us, we must make it
215 // release that reference before we can be destroyed. 215 // release that reference before we can be destroyed.
216 CancelScheduledCommit(); 216 CancelScheduledCommit();
217 217
218 // Release our reference to the delegate, this reference will be keeping the 218 // Release our reference to the delegate, this reference will be keeping the
219 // history service alive. 219 // history service alive.
220 delegate_.reset(); 220 delegate_.reset();
221 } 221 }
222 222
223 void HistoryBackend::NotifyRenderProcessHostDestruction(const void* host) { 223 void HistoryBackend::ClearCachedDataForContextID(ContextID context_id) {
224 tracker_.NotifyRenderProcessHostDestruction(host); 224 tracker_.ClearCachedDataForContextID(context_id);
225 } 225 }
226 226
227 base::FilePath HistoryBackend::GetThumbnailFileName() const { 227 base::FilePath HistoryBackend::GetThumbnailFileName() const {
228 return history_dir_.Append(chrome::kThumbnailsFilename); 228 return history_dir_.Append(chrome::kThumbnailsFilename);
229 } 229 }
230 230
231 base::FilePath HistoryBackend::GetFaviconsFileName() const { 231 base::FilePath HistoryBackend::GetFaviconsFileName() const {
232 return history_dir_.Append(chrome::kFaviconsFilename); 232 return history_dir_.Append(chrome::kFaviconsFilename);
233 } 233 }
234 234
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 } 332 }
333 333
334 // Finally, increase the counter for that segment / day. 334 // Finally, increase the counter for that segment / day.
335 if (!db_->IncreaseSegmentVisitCount(segment_id, ts, 1)) { 335 if (!db_->IncreaseSegmentVisitCount(segment_id, ts, 1)) {
336 NOTREACHED(); 336 NOTREACHED();
337 return 0; 337 return 0;
338 } 338 }
339 return segment_id; 339 return segment_id;
340 } 340 }
341 341
342 void HistoryBackend::UpdateWithPageEndTime(const void* host, 342 void HistoryBackend::UpdateWithPageEndTime(ContextID context_id,
343 int32 page_id, 343 int32 page_id,
344 const GURL& url, 344 const GURL& url,
345 Time end_ts) { 345 Time end_ts) {
346 // Will be filled with the URL ID and the visit ID of the last addition. 346 // Will be filled with the URL ID and the visit ID of the last addition.
347 VisitID visit_id = tracker_.GetLastVisit(host, page_id, url); 347 VisitID visit_id = tracker_.GetLastVisit(context_id, page_id, url);
348 UpdateVisitDuration(visit_id, end_ts); 348 UpdateVisitDuration(visit_id, end_ts);
349 } 349 }
350 350
351 void HistoryBackend::UpdateVisitDuration(VisitID visit_id, const Time end_ts) { 351 void HistoryBackend::UpdateVisitDuration(VisitID visit_id, const Time end_ts) {
352 if (!db_) 352 if (!db_)
353 return; 353 return;
354 354
355 // Get the starting visit_time for visit_id. 355 // Get the starting visit_time for visit_id.
356 VisitRow visit_row; 356 VisitRow visit_row;
357 if (db_->GetRowForVisit(visit_id, &visit_row)) { 357 if (db_->GetRowForVisit(visit_id, &visit_row)) {
358 // We should never have a negative duration time even when time is skewed. 358 // We should never have a negative duration time even when time is skewed.
359 visit_row.visit_duration = end_ts > visit_row.visit_time ? 359 visit_row.visit_duration = end_ts > visit_row.visit_time ?
360 end_ts - visit_row.visit_time : TimeDelta::FromMicroseconds(0); 360 end_ts - visit_row.visit_time : TimeDelta::FromMicroseconds(0);
361 db_->UpdateVisitRow(visit_row); 361 db_->UpdateVisitRow(visit_row);
362 } 362 }
363 } 363 }
364 364
365 void HistoryBackend::AddPage(const HistoryAddPageArgs& request) { 365 void HistoryBackend::AddPage(const HistoryAddPageArgs& request) {
366 if (!db_) 366 if (!db_)
367 return; 367 return;
368 368
369 // Will be filled with the URL ID and the visit ID of the last addition. 369 // Will be filled with the URL ID and the visit ID of the last addition.
370 std::pair<URLID, VisitID> last_ids(0, tracker_.GetLastVisit( 370 std::pair<URLID, VisitID> last_ids(0, tracker_.GetLastVisit(
371 request.id_scope, request.page_id, request.referrer)); 371 request.context_id, request.page_id, request.referrer));
372 372
373 VisitID from_visit_id = last_ids.second; 373 VisitID from_visit_id = last_ids.second;
374 374
375 // If a redirect chain is given, we expect the last item in that chain to be 375 // If a redirect chain is given, we expect the last item in that chain to be
376 // the final URL. 376 // the final URL.
377 DCHECK(request.redirects.empty() || 377 DCHECK(request.redirects.empty() ||
378 request.redirects.back() == request.url); 378 request.redirects.back() == request.url);
379 379
380 // If the user is adding older history, we need to make sure our times 380 // If the user is adding older history, we need to make sure our times
381 // are correct. 381 // are correct.
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 // TODO(brettw) bug 1140015: Add an "add page" notification so the history 524 // TODO(brettw) bug 1140015: Add an "add page" notification so the history
525 // views can keep in sync. 525 // views can keep in sync.
526 526
527 // Add the last visit to the tracker so we can get outgoing transitions. 527 // Add the last visit to the tracker so we can get outgoing transitions.
528 // TODO(evanm): Due to http://b/1194536 we lose the referrers of a subframe 528 // TODO(evanm): Due to http://b/1194536 we lose the referrers of a subframe
529 // navigation anyway, so last_visit_id is always zero for them. But adding 529 // navigation anyway, so last_visit_id is always zero for them. But adding
530 // them here confuses main frame history, so we skip them for now. 530 // them here confuses main frame history, so we skip them for now.
531 if (stripped_transition != content::PAGE_TRANSITION_AUTO_SUBFRAME && 531 if (stripped_transition != content::PAGE_TRANSITION_AUTO_SUBFRAME &&
532 stripped_transition != content::PAGE_TRANSITION_MANUAL_SUBFRAME && 532 stripped_transition != content::PAGE_TRANSITION_MANUAL_SUBFRAME &&
533 !is_keyword_generated) { 533 !is_keyword_generated) {
534 tracker_.AddVisit(request.id_scope, request.page_id, request.url, 534 tracker_.AddVisit(request.context_id, request.page_id, request.url,
535 last_ids.second); 535 last_ids.second);
536 } 536 }
537 537
538 ScheduleCommit(); 538 ScheduleCommit();
539 } 539 }
540 540
541 void HistoryBackend::InitImpl(const std::string& languages) { 541 void HistoryBackend::InitImpl(const std::string& languages) {
542 DCHECK(!db_) << "Initializing HistoryBackend twice"; 542 DCHECK(!db_) << "Initializing HistoryBackend twice";
543 // In the rare case where the db fails to initialize a dialog may get shown 543 // In the rare case where the db fails to initialize a dialog may get shown
544 // the blocks the caller, yet allows other messages through. For this reason 544 // the blocks the caller, yet allows other messages through. For this reason
(...skipping 2303 matching lines...) Expand 10 before | Expand all | Expand 10 after
2848 int rank = kPageVisitStatsMaxTopSites; 2848 int rank = kPageVisitStatsMaxTopSites;
2849 std::map<GURL, int>::const_iterator it = most_visited_urls_map_.find(url); 2849 std::map<GURL, int>::const_iterator it = most_visited_urls_map_.find(url);
2850 if (it != most_visited_urls_map_.end()) 2850 if (it != most_visited_urls_map_.end())
2851 rank = (*it).second; 2851 rank = (*it).second;
2852 UMA_HISTOGRAM_ENUMERATION("History.TopSitesVisitsByRank", 2852 UMA_HISTOGRAM_ENUMERATION("History.TopSitesVisitsByRank",
2853 rank, kPageVisitStatsMaxTopSites + 1); 2853 rank, kPageVisitStatsMaxTopSites + 1);
2854 } 2854 }
2855 #endif 2855 #endif
2856 2856
2857 } // namespace history 2857 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/history/history_backend.h ('k') | chrome/browser/history/history_backend_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698