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

Side by Side Diff: content/browser/background_sync/background_sync_manager.cc

Issue 1771743002: Move geolocation and permission mojoms into WebKit/public/platform. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "content/browser/background_sync/background_sync_manager.h" 5 #include "content/browser/background_sync/background_sync_manager.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/barrier_closure.h" 9 #include "base/barrier_closure.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 BrowserContext* browser_context = 72 BrowserContext* browser_context =
73 GetBrowserContextOnUIThread(service_worker_context); 73 GetBrowserContextOnUIThread(service_worker_context);
74 if (!browser_context) 74 if (!browser_context)
75 return nullptr; 75 return nullptr;
76 76
77 return browser_context->GetBackgroundSyncController(); 77 return browser_context->GetBackgroundSyncController();
78 } 78 }
79 79
80 // Returns PermissionStatus::DENIED if the permission manager cannot be 80 // Returns PermissionStatus::DENIED if the permission manager cannot be
81 // accessed for any reason. 81 // accessed for any reason.
82 mojom::PermissionStatus GetBackgroundSyncPermissionOnUIThread( 82 blink::mojom::PermissionStatus GetBackgroundSyncPermissionOnUIThread(
83 const scoped_refptr<ServiceWorkerContextWrapper>& service_worker_context, 83 const scoped_refptr<ServiceWorkerContextWrapper>& service_worker_context,
84 const GURL& origin) { 84 const GURL& origin) {
85 DCHECK_CURRENTLY_ON(BrowserThread::UI); 85 DCHECK_CURRENTLY_ON(BrowserThread::UI);
86 86
87 BrowserContext* browser_context = 87 BrowserContext* browser_context =
88 GetBrowserContextOnUIThread(service_worker_context); 88 GetBrowserContextOnUIThread(service_worker_context);
89 if (!browser_context) 89 if (!browser_context)
90 return mojom::PermissionStatus::DENIED; 90 return blink::mojom::PermissionStatus::DENIED;
91 91
92 PermissionManager* permission_manager = 92 PermissionManager* permission_manager =
93 browser_context->GetPermissionManager(); 93 browser_context->GetPermissionManager();
94 if (!permission_manager) 94 if (!permission_manager)
95 return mojom::PermissionStatus::DENIED; 95 return blink::mojom::PermissionStatus::DENIED;
96 96
97 // The requesting origin always matches the embedding origin. 97 // The requesting origin always matches the embedding origin.
98 return permission_manager->GetPermissionStatus( 98 return permission_manager->GetPermissionStatus(
99 PermissionType::BACKGROUND_SYNC, origin, origin); 99 PermissionType::BACKGROUND_SYNC, origin, origin);
100 } 100 }
101 101
102 void NotifyBackgroundSyncRegisteredOnUIThread( 102 void NotifyBackgroundSyncRegisteredOnUIThread(
103 const scoped_refptr<ServiceWorkerContextWrapper>& sw_context_wrapper, 103 const scoped_refptr<ServiceWorkerContextWrapper>& sw_context_wrapper,
104 const GURL& origin) { 104 const GURL& origin) {
105 DCHECK_CURRENTLY_ON(BrowserThread::UI); 105 DCHECK_CURRENTLY_ON(BrowserThread::UI);
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 sw_registration->pattern().GetOrigin()), 457 sw_registration->pattern().GetOrigin()),
458 base::Bind(&BackgroundSyncManager::RegisterDidAskForPermission, 458 base::Bind(&BackgroundSyncManager::RegisterDidAskForPermission,
459 weak_ptr_factory_.GetWeakPtr(), sw_registration_id, options, 459 weak_ptr_factory_.GetWeakPtr(), sw_registration_id, options,
460 callback)); 460 callback));
461 } 461 }
462 462
463 void BackgroundSyncManager::RegisterDidAskForPermission( 463 void BackgroundSyncManager::RegisterDidAskForPermission(
464 int64_t sw_registration_id, 464 int64_t sw_registration_id,
465 const BackgroundSyncRegistrationOptions& options, 465 const BackgroundSyncRegistrationOptions& options,
466 const StatusAndRegistrationCallback& callback, 466 const StatusAndRegistrationCallback& callback,
467 mojom::PermissionStatus permission_status) { 467 blink::mojom::PermissionStatus permission_status) {
468 DCHECK_CURRENTLY_ON(BrowserThread::IO); 468 DCHECK_CURRENTLY_ON(BrowserThread::IO);
469 469
470 if (permission_status == mojom::PermissionStatus::DENIED) { 470 if (permission_status == blink::mojom::PermissionStatus::DENIED) {
471 RecordFailureAndPostError(BACKGROUND_SYNC_STATUS_PERMISSION_DENIED, 471 RecordFailureAndPostError(BACKGROUND_SYNC_STATUS_PERMISSION_DENIED,
472 callback); 472 callback);
473 return; 473 return;
474 } 474 }
475 DCHECK(permission_status == mojom::PermissionStatus::GRANTED); 475 DCHECK(permission_status == blink::mojom::PermissionStatus::GRANTED);
476 476
477 ServiceWorkerRegistration* sw_registration = 477 ServiceWorkerRegistration* sw_registration =
478 service_worker_context_->GetLiveRegistration(sw_registration_id); 478 service_worker_context_->GetLiveRegistration(sw_registration_id);
479 if (!sw_registration || !sw_registration->active_version()) { 479 if (!sw_registration || !sw_registration->active_version()) {
480 // The service worker was shut down in the interim. 480 // The service worker was shut down in the interim.
481 RecordFailureAndPostError(BACKGROUND_SYNC_STATUS_NO_SERVICE_WORKER, 481 RecordFailureAndPostError(BACKGROUND_SYNC_STATUS_NO_SERVICE_WORKER,
482 callback); 482 callback);
483 return; 483 return;
484 } 484 }
485 485
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after
1241 BackgroundSyncManager::MakeStatusCompletion(const StatusCallback& callback) { 1241 BackgroundSyncManager::MakeStatusCompletion(const StatusCallback& callback) {
1242 DCHECK_CURRENTLY_ON(BrowserThread::IO); 1242 DCHECK_CURRENTLY_ON(BrowserThread::IO);
1243 1243
1244 return base::Bind( 1244 return base::Bind(
1245 &BackgroundSyncManager::CompleteOperationCallback<StatusCallback, 1245 &BackgroundSyncManager::CompleteOperationCallback<StatusCallback,
1246 BackgroundSyncStatus>, 1246 BackgroundSyncStatus>,
1247 weak_ptr_factory_.GetWeakPtr(), callback); 1247 weak_ptr_factory_.GetWeakPtr(), callback);
1248 } 1248 }
1249 1249
1250 } // namespace content 1250 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698