Commit 6249d0f7 authored by Brett Wilson's avatar Brett Wilson Committed by Commit Bot

Make serialized navigation entry moveable.

This class is inserted into vectors and has slow-to-copy-but-fast-to-move
members so would benefit from being moveable.

It was also assignable which was generating large implicit inline operator=
implementations. This makes operator= explicit and out-of-line.

Uses C++11 syntax for member initialization.

Change-Id: Ie4c591b716f85197f30603ebaeec27ddfc7cb2d6
Reviewed-on: https://chromium-review.googlesource.com/677058Reviewed-by: default avatarStefan Kuhne <skuhne@chromium.org>
Commit-Queue: Brett Wilson <brettw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#504173}
parent 548147b1
...@@ -22,17 +22,7 @@ const char kSearchTermsKey[] = "search_terms"; ...@@ -22,17 +22,7 @@ const char kSearchTermsKey[] = "search_terms";
// The previous referrer policy value corresponding to |Never|. // The previous referrer policy value corresponding to |Never|.
const int kObsoleteReferrerPolicyNever = 2; const int kObsoleteReferrerPolicyNever = 2;
SerializedNavigationEntry::SerializedNavigationEntry() SerializedNavigationEntry::SerializedNavigationEntry() {
: index_(-1),
unique_id_(0),
transition_type_(ui::PAGE_TRANSITION_TYPED),
has_post_data_(false),
post_id_(-1),
is_overriding_user_agent_(false),
http_status_code_(0),
is_restored_(false),
blocked_state_(STATE_INVALID),
password_state_(PASSWORD_STATE_UNKNOWN) {
referrer_policy_ = referrer_policy_ =
SerializedNavigationDriver::Get()->GetDefaultReferrerPolicy(); SerializedNavigationDriver::Get()->GetDefaultReferrerPolicy();
} }
...@@ -40,7 +30,21 @@ SerializedNavigationEntry::SerializedNavigationEntry() ...@@ -40,7 +30,21 @@ SerializedNavigationEntry::SerializedNavigationEntry()
SerializedNavigationEntry::SerializedNavigationEntry( SerializedNavigationEntry::SerializedNavigationEntry(
const SerializedNavigationEntry& other) = default; const SerializedNavigationEntry& other) = default;
SerializedNavigationEntry::~SerializedNavigationEntry() {} SerializedNavigationEntry::SerializedNavigationEntry(
SerializedNavigationEntry&& other) noexcept {
// VC 2015 can't handle "noexcept = default" constructors. We want the
// noexcept to avoid copying in a vector, but don't want to copy everything,
// by hand, so fall on the default-generated move operator=.
operator=(std::move(other));
}
SerializedNavigationEntry::~SerializedNavigationEntry() = default;
SerializedNavigationEntry& SerializedNavigationEntry::operator=(
const SerializedNavigationEntry& other) = default;
SerializedNavigationEntry& SerializedNavigationEntry::operator=(
SerializedNavigationEntry&& other) = default;
SerializedNavigationEntry SerializedNavigationEntry::FromSyncData( SerializedNavigationEntry SerializedNavigationEntry::FromSyncData(
int index, int index,
......
...@@ -60,8 +60,12 @@ class SESSIONS_EXPORT SerializedNavigationEntry { ...@@ -60,8 +60,12 @@ class SESSIONS_EXPORT SerializedNavigationEntry {
// Creates an invalid (index < 0) SerializedNavigationEntry. // Creates an invalid (index < 0) SerializedNavigationEntry.
SerializedNavigationEntry(); SerializedNavigationEntry();
SerializedNavigationEntry(const SerializedNavigationEntry& other); SerializedNavigationEntry(const SerializedNavigationEntry& other);
SerializedNavigationEntry(SerializedNavigationEntry&& other) noexcept;
~SerializedNavigationEntry(); ~SerializedNavigationEntry();
SerializedNavigationEntry& operator=(const SerializedNavigationEntry& other);
SerializedNavigationEntry& operator=(SerializedNavigationEntry&& other);
// Construct a SerializedNavigationEntry for a particular index from a sync // Construct a SerializedNavigationEntry for a particular index from a sync
// protocol buffer. Note that the sync protocol buffer doesn't contain all // protocol buffer. Note that the sync protocol buffer doesn't contain all
// SerializedNavigationEntry fields. Also, the timestamp of the returned // SerializedNavigationEntry fields. Also, the timestamp of the returned
...@@ -155,32 +159,32 @@ class SESSIONS_EXPORT SerializedNavigationEntry { ...@@ -155,32 +159,32 @@ class SESSIONS_EXPORT SerializedNavigationEntry {
friend class IOSSerializedNavigationDriver; friend class IOSSerializedNavigationDriver;
// Index in the NavigationController. // Index in the NavigationController.
int index_; int index_ = -1;
// Member variables corresponding to NavigationEntry fields. // Member variables corresponding to NavigationEntry fields.
// If you add a new field that can allocate memory, please also add // If you add a new field that can allocate memory, please also add
// it to the EstimatedMemoryUsage() implementation. // it to the EstimatedMemoryUsage() implementation.
int unique_id_; int unique_id_ = 0;
GURL referrer_url_; GURL referrer_url_;
int referrer_policy_; int referrer_policy_;
GURL virtual_url_; GURL virtual_url_;
base::string16 title_; base::string16 title_;
std::string encoded_page_state_; std::string encoded_page_state_;
ui::PageTransition transition_type_; ui::PageTransition transition_type_ = ui::PAGE_TRANSITION_TYPED;
bool has_post_data_; bool has_post_data_ = false;
int64_t post_id_; int64_t post_id_ = -1;
GURL original_request_url_; GURL original_request_url_;
bool is_overriding_user_agent_; bool is_overriding_user_agent_ = false;
base::Time timestamp_; base::Time timestamp_;
base::string16 search_terms_; base::string16 search_terms_;
GURL favicon_url_; GURL favicon_url_;
int http_status_code_; int http_status_code_ = 0;
bool is_restored_; // Not persisted. bool is_restored_ = false; // Not persisted.
std::vector<GURL> redirect_chain_; // Not persisted. std::vector<GURL> redirect_chain_; // Not persisted.
// Additional information. // Additional information.
BlockedState blocked_state_; BlockedState blocked_state_ = STATE_INVALID;
PasswordState password_state_; PasswordState password_state_ = PASSWORD_STATE_UNKNOWN;
std::set<std::string> content_pack_categories_; std::set<std::string> content_pack_categories_;
// Provides storage for arbitrary key/value pairs used by features. This // Provides storage for arbitrary key/value pairs used by features. This
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment