Skip to content

Commit

Permalink
Pass some args as const ref.
Browse files Browse the repository at this point in the history
  • Loading branch information
goodov committed Apr 12, 2021
1 parent 1a0dc91 commit 076f42b
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
6 changes: 3 additions & 3 deletions browser/ephemeral_storage/ephemeral_storage_tab_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ void EphemeralStorageTabHelper::ReadyToCommitNavigation(
if (new_domain == previous_domain)
return;

CreateEphemeralStorageAreasForDomainAndURL(std::move(new_domain), new_url);
CreateEphemeralStorageAreasForDomainAndURL(new_domain, new_url);
}

void EphemeralStorageTabHelper::CreateEphemeralStorageAreasForDomainAndURL(
std::string new_domain,
const std::string& new_domain,
const GURL& new_url) {
if (new_url.is_empty())
return;
Expand Down Expand Up @@ -145,7 +145,7 @@ void EphemeralStorageTabHelper::CreateEphemeralStorageAreasForDomainAndURL(
}

tld_ephemeral_lifetime_ = content::TLDEphemeralLifetime::GetOrCreate(
browser_context, partition, std::move(new_domain));
browser_context, partition, new_domain);
}

// static
Expand Down
2 changes: 1 addition & 1 deletion browser/ephemeral_storage/ephemeral_storage_tab_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class EphemeralStorageTabHelper
content::NavigationHandle* navigation_handle) override;

private:
void CreateEphemeralStorageAreasForDomainAndURL(std::string new_domain,
void CreateEphemeralStorageAreasForDomainAndURL(const std::string& new_domain,
const GURL& new_url);

friend class content::WebContentsUserData<EphemeralStorageTabHelper>;
Expand Down
18 changes: 9 additions & 9 deletions chromium_src/content/browser/tld_ephemeral_lifetime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ TLDEphemeralLifetimeMap& active_tld_storage_areas() {

} // namespace

TLDEphemeralLifetime::TLDEphemeralLifetime(TLDEphemeralLifetimeKey key,
TLDEphemeralLifetime::TLDEphemeralLifetime(const TLDEphemeralLifetimeKey& key,
StoragePartition* storage_partition)
: key_(std::move(key)), storage_partition_(storage_partition) {
: key_(key), storage_partition_(storage_partition) {
DCHECK(active_tld_storage_areas().find(key_) ==
active_tld_storage_areas().end());
DCHECK(storage_partition_);
Expand All @@ -54,24 +54,24 @@ TLDEphemeralLifetime::~TLDEphemeralLifetime() {
}

// static
TLDEphemeralLifetime* TLDEphemeralLifetime::Get(BrowserContext* browser_context,
std::string storage_domain) {
const TLDEphemeralLifetimeKey key(browser_context, std::move(storage_domain));
TLDEphemeralLifetime* TLDEphemeralLifetime::Get(
BrowserContext* browser_context,
const std::string& storage_domain) {
const TLDEphemeralLifetimeKey key(browser_context, storage_domain);
return Get(key);
}

// static
scoped_refptr<TLDEphemeralLifetime> TLDEphemeralLifetime::GetOrCreate(
BrowserContext* browser_context,
StoragePartition* storage_partition,
std::string storage_domain) {
TLDEphemeralLifetimeKey key(browser_context, std::move(storage_domain));
const std::string& storage_domain) {
const TLDEphemeralLifetimeKey key(browser_context, storage_domain);
if (scoped_refptr<TLDEphemeralLifetime> existing = Get(key)) {
return existing;
}

return base::MakeRefCounted<TLDEphemeralLifetime>(std::move(key),
storage_partition);
return base::MakeRefCounted<TLDEphemeralLifetime>(key, storage_partition);
}

// static
Expand Down
6 changes: 3 additions & 3 deletions chromium_src/content/public/browser/tld_ephemeral_lifetime.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ class CONTENT_EXPORT TLDEphemeralLifetime
public:
using OnDestroyCallback = base::OnceCallback<void(const std::string&)>;

TLDEphemeralLifetime(TLDEphemeralLifetimeKey key,
TLDEphemeralLifetime(const TLDEphemeralLifetimeKey& key,
StoragePartition* storage_partition);
static TLDEphemeralLifetime* Get(BrowserContext* browser_context,
std::string storage_domain);
const std::string& storage_domain);
static scoped_refptr<TLDEphemeralLifetime> GetOrCreate(
BrowserContext* browser_context,
StoragePartition* storage_partition,
std::string storage_domain);
const std::string& storage_domain);

// Add a callback to a callback list to be called on destruction.
void RegisterOnDestroyCallback(OnDestroyCallback callback);
Expand Down
4 changes: 2 additions & 2 deletions components/permissions/permission_expirations.cc
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@ PermissionExpirations::RemoveExpiredPermissions(base::Time current_time) {
}

PermissionExpirations::ExpiredPermissions
PermissionExpirations::RemoveExpiredPermissions(std::string domain) {
PermissionExpirations::RemoveExpiredPermissions(const std::string& domain) {
return RemoveExpiredPermissionsImpl(base::BindRepeating(
[](const PermissionExpirationKey& expiration_key,
const PermissionExpirations::KeyExpirationsMap& key_expirations) {
return key_expirations.equal_range(expiration_key);
},
PermissionExpirationKey(std::move(domain))));
PermissionExpirationKey(domain)));
}

PermissionExpirations::ExpiredPermissions
Expand Down
2 changes: 1 addition & 1 deletion components/permissions/permission_expirations.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class PermissionExpirations {
// Remove expired permissions with expiration_time >= |current_time|.
ExpiredPermissions RemoveExpiredPermissions(base::Time current_time);
// Remove expired permissions with exact |domain|.
ExpiredPermissions RemoveExpiredPermissions(std::string domain);
ExpiredPermissions RemoveExpiredPermissions(const std::string& domain);
// Remove expired permissions with a domain as a key.
ExpiredPermissions RemoveAllDomainPermissions();

Expand Down

0 comments on commit 076f42b

Please sign in to comment.