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

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

Issue 2781263002: Some C++11 cleanup of history types. (Closed)
Patch Set: Fix Android Created 3 years, 8 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/url_row.h ('k') | components/query_parser/snippet.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/history/core/browser/url_row.h" 5 #include "components/history/core/browser/url_row.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 namespace history { 9 namespace history {
10 10
11 URLRow::URLRow() { 11 URLRow::URLRow() {
12 Initialize();
13 } 12 }
14 13
15 URLRow::URLRow(const GURL& url) : url_(url) { 14 URLRow::URLRow(const GURL& url) : url_(url) {
16 // Initialize will not set the URL, so our initialization above will stay.
17 Initialize();
18 } 15 }
19 16
20 URLRow::URLRow(const GURL& url, URLID id) : url_(url) { 17 URLRow::URLRow(const GURL& url, URLID id) : id_(id), url_(url) {}
21 // Initialize will not set the URL, so our initialization above will stay.
22 Initialize();
23 // Initialize will zero the id_, so set it here.
24 id_ = id;
25 }
26 18
27 URLRow::URLRow(const URLRow& other) = default; 19 URLRow::URLRow(const URLRow& other) = default;
28 20
21 // TODO(bug 706963) this should be implemented as "= default" when Android
22 // toolchain is updated.
23 URLRow::URLRow(URLRow&& other) noexcept
24 : id_(other.id_),
25 url_(std::move(other.url_)),
26 title_(std::move(other.title_)),
27 visit_count_(other.visit_count_),
28 typed_count_(other.typed_count_),
29 last_visit_(other.last_visit_),
30 hidden_(other.hidden_) {}
31
29 URLRow::~URLRow() { 32 URLRow::~URLRow() {
30 } 33 }
31 34
32 URLRow& URLRow::operator=(const URLRow& other) { 35 URLRow& URLRow::operator=(const URLRow& other) = default;
33 if (this == &other)
34 return *this;
35 id_ = other.id_;
36 url_ = other.url_;
37 title_ = other.title_;
38 visit_count_ = other.visit_count_;
39 typed_count_ = other.typed_count_;
40 last_visit_ = other.last_visit_;
41 hidden_ = other.hidden_;
42 return *this;
43 }
44 36
45 void URLRow::Swap(URLRow* other) { 37 void URLRow::Swap(URLRow* other) {
46 std::swap(id_, other->id_); 38 std::swap(id_, other->id_);
47 url_.Swap(&other->url_); 39 url_.Swap(&other->url_);
48 title_.swap(other->title_); 40 title_.swap(other->title_);
49 std::swap(visit_count_, other->visit_count_); 41 std::swap(visit_count_, other->visit_count_);
50 std::swap(typed_count_, other->typed_count_); 42 std::swap(typed_count_, other->typed_count_);
51 std::swap(last_visit_, other->last_visit_); 43 std::swap(last_visit_, other->last_visit_);
52 std::swap(hidden_, other->hidden_); 44 std::swap(hidden_, other->hidden_);
53 } 45 }
54 46
55 void URLRow::Initialize() { 47 URLResult::URLResult() {}
56 id_ = 0;
57 visit_count_ = 0;
58 typed_count_ = 0;
59 last_visit_ = base::Time();
60 hidden_ = false;
61 }
62
63
64 URLResult::URLResult()
65 : blocked_visit_(false) {
66 }
67 48
68 URLResult::URLResult(const GURL& url, base::Time visit_time) 49 URLResult::URLResult(const GURL& url, base::Time visit_time)
69 : URLRow(url), 50 : URLRow(url), visit_time_(visit_time) {}
70 visit_time_(visit_time),
71 blocked_visit_(false) {
72 }
73 51
74 URLResult::URLResult(const GURL& url, 52 URLResult::URLResult(const URLRow& url_row) : URLRow(url_row) {}
75 const query_parser::Snippet::MatchPositions& title_matches)
76 : URLRow(url) {
77 title_match_positions_ = title_matches;
78 }
79 URLResult::URLResult(const URLRow& url_row)
80 : URLRow(url_row),
81 blocked_visit_(false) {
82 }
83 53
84 URLResult::URLResult(const URLResult& other) = default; 54 URLResult::URLResult(const URLResult& other) = default;
85 55
56 // TODO(bug 706963) this should be implemented as "= default" when Android
57 // toolchain is updated.
58 URLResult::URLResult(URLResult&& other) noexcept
59 : URLRow(std::move(other)),
60 visit_time_(other.visit_time_),
61 snippet_(std::move(other.snippet_)),
62 title_match_positions_(std::move(other.title_match_positions_)),
63 blocked_visit_(other.blocked_visit_) {}
64
86 URLResult::~URLResult() { 65 URLResult::~URLResult() {
87 } 66 }
88 67
68 URLResult& URLResult::operator=(const URLResult&) = default;
69
89 void URLResult::SwapResult(URLResult* other) { 70 void URLResult::SwapResult(URLResult* other) {
90 URLRow::Swap(other); 71 URLRow::Swap(other);
91 std::swap(visit_time_, other->visit_time_); 72 std::swap(visit_time_, other->visit_time_);
92 snippet_.Swap(&other->snippet_); 73 snippet_.Swap(&other->snippet_);
93 title_match_positions_.swap(other->title_match_positions_); 74 title_match_positions_.swap(other->title_match_positions_);
94 std::swap(blocked_visit_, other->blocked_visit_); 75 std::swap(blocked_visit_, other->blocked_visit_);
95 } 76 }
96 77
97 // static 78 // static
98 bool URLResult::CompareVisitTime(const URLResult& lhs, const URLResult& rhs) { 79 bool URLResult::CompareVisitTime(const URLResult& lhs, const URLResult& rhs) {
99 return lhs.visit_time() > rhs.visit_time(); 80 return lhs.visit_time() > rhs.visit_time();
100 } 81 }
101 82
102 } // namespace history 83 } // namespace history
OLDNEW
« no previous file with comments | « components/history/core/browser/url_row.h ('k') | components/query_parser/snippet.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698