Skip to content

Commit

Permalink
PushMessagingNotificationManager: utility function to get StoragePart…
Browse files Browse the repository at this point in the history
…ition.

BUG=558402

Review URL: https://codereview.chromium.org/1462923002

Cr-Commit-Position: refs/heads/master@{#360619}
  • Loading branch information
mvano authored and Commit bot committed Nov 19, 2015
1 parent d8a4b46 commit 2a285c5
Showing 1 changed file with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ void RecordUserVisibleStatus(content::PushUserVisibleStatus status) {
content::PUSH_USER_VISIBLE_STATUS_LAST + 1);
}

content::StoragePartition* GetStoragePartition(Profile* profile,
const GURL& origin) {
return content::BrowserContext::GetStoragePartitionForSite(profile, origin);
}

} // namespace

PushMessagingNotificationManager::PushMessagingNotificationManager(
Expand All @@ -63,8 +68,8 @@ void PushMessagingNotificationManager::EnforceUserVisibleOnlyRequirements(
DCHECK_CURRENTLY_ON(BrowserThread::UI);
// TODO(johnme): Relax this heuristic slightly.
scoped_refptr<content::PlatformNotificationContext> notification_context =
content::BrowserContext::GetStoragePartitionForSite(
profile_, requesting_origin)->GetPlatformNotificationContext();
GetStoragePartition(profile_, requesting_origin)
->GetPlatformNotificationContext();
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(
Expand Down Expand Up @@ -181,8 +186,8 @@ void PushMessagingNotificationManager::DidGetNotificationsFromDatabase(
// from needing to do so.
if (notification_shown || notification_needed) {
content::ServiceWorkerContext* service_worker_context =
content::BrowserContext::GetStoragePartitionForSite(
profile_, requesting_origin)->GetServiceWorkerContext();
GetStoragePartition(profile_, requesting_origin)
->GetServiceWorkerContext();

content::PushMessagingService::GetNotificationsShownByLastFewPushes(
service_worker_context, service_worker_registration_id,
Expand All @@ -209,8 +214,8 @@ void PushMessagingNotificationManager::DidGetNotificationsShownAndNeeded(
const std::string& data, bool success, bool not_found) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
content::ServiceWorkerContext* service_worker_context =
content::BrowserContext::GetStoragePartitionForSite(
profile_, requesting_origin)->GetServiceWorkerContext();
GetStoragePartition(profile_, requesting_origin)
->GetServiceWorkerContext();

// We remember whether the last (up to) 10 pushes showed notifications.
const size_t MISSED_NOTIFICATIONS_LENGTH = 10;
Expand Down Expand Up @@ -278,8 +283,8 @@ void PushMessagingNotificationManager::DidGetNotificationsShownAndNeeded(
database_data.notification_data = notification_data;

scoped_refptr<content::PlatformNotificationContext> notification_context =
content::BrowserContext::GetStoragePartitionForSite(
profile_, requesting_origin)->GetPlatformNotificationContext();
GetStoragePartition(profile_, requesting_origin)
->GetPlatformNotificationContext();
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(
Expand Down

0 comments on commit 2a285c5

Please sign in to comment.