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

Side by Side Diff: chrome/browser/android/history_report/historic_visits_migration_task.cc

Issue 1141283003: Upstream oodles of Chrome for Android code into Chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: final patch? Created 5 years, 7 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
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/android/history_report/historic_visits_migration_task.h "
6
7 #include "chrome/browser/android/history_report/delta_file_commons.h"
8 #include "chrome/browser/android/history_report/usage_report_util.h"
9 #include "chrome/browser/android/history_report/usage_reports_buffer_service.h"
10 #include "components/history/core/browser/android/android_history_types.h"
11 #include "components/history/core/browser/history_backend.h"
12 #include "components/history/core/browser/history_database.h"
13
14 namespace {
15 // The number of recent visits to fetch for a typed url.
16 // Older visits are ignored.
17 static const int kMaxTypedUrlVisits = 1000;
18 }
19
20 namespace history_report {
21
22 HistoricVisitsMigrationTask::HistoricVisitsMigrationTask(
23 base::WaitableEvent* event,
24 UsageReportsBufferService* report_buffer_service)
25 : wait_event_(event), usage_reports_buffer_service_(report_buffer_service) {
26 }
27
28 bool HistoricVisitsMigrationTask::RunOnDBThread(
29 history::HistoryBackend* backend,
30 history::HistoryDatabase* db) {
31 history::URLRows typed_urls;
32 backend->GetAllTypedURLs(&typed_urls);
33
34 for (history::URLRows::const_iterator typed_url = typed_urls.begin();
35 typed_url != typed_urls.end();
36 ++typed_url) {
37 std::string url_id =
38 DeltaFileEntryWithData::UrlToId(typed_url->url().spec());
39 history::VisitVector url_visits;
40
41 if (usage_report_util::ShouldIgnoreUrl(typed_url->url())) {
42 continue;
43 }
44 backend->GetMostRecentVisitsForURL(
45 typed_url->id(), kMaxTypedUrlVisits, &url_visits);
46
47 for (history::VisitVector::const_iterator visit = url_visits.begin();
48 visit != url_visits.end();
49 ++visit) {
50 usage_reports_buffer_service_->AddVisit(
51 url_id,
52 visit->visit_time.ToJavaTime(),
53 usage_report_util::IsTypedVisit(visit->transition));
54 }
55 }
56 wait_event_->Signal();
57 return true;
58 }
59
60 } // namespace history_report
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698