2 // Copyright 2015 The Chromium Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
6 #include "chrome/browser/android/history_report/usage_report_util.h"
11 #include "chrome/browser/android/proto/delta_file.pb.h"
12 #include "net/base/net_util.h"
15 namespace history_report
{
16 namespace usage_report_util
{
18 // Returns a levelDb key for a report. It's a concatenation of timestamp and id
19 // fields of a report.
20 std::string
ReportToKey(const history_report::UsageReport
& report
) {
21 std::stringstream key
;
22 key
<< std::setfill('0') << std::setw(15) << report
.timestamp_ms()
27 bool IsTypedVisit(ui::PageTransition visit_transition
) {
28 ui::PageTransition transition_type
=
29 ui::PageTransitionStripQualifier(visit_transition
);
30 return transition_type
== ui::PAGE_TRANSITION_TYPED
&&
31 !ui::PageTransitionIsRedirect(visit_transition
);
34 bool ShouldIgnoreUrl(const GURL
& url
) {
35 if (url
.spec().empty())
38 // Ignore local file URLs.
39 // TODO(nileshagrawal): Maybe we should ignore content:// urls too.
40 if (url
.SchemeIsFile())
43 // Ignore localhost URLs.
44 if (net::IsLocalhost(url
.host()))
50 } // namespace usage_report_util
51 } // namespace history_report