| OLD | NEW |
| 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 "content/browser/geofencing/geofencing_manager.h" | 5 #include "content/browser/geofencing/geofencing_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "content/browser/geofencing/geofencing_service.h" | 10 #include "content/browser/geofencing/geofencing_service.h" |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 } | 388 } |
| 389 | 389 |
| 390 ServiceWorkerVersion* active_version = | 390 ServiceWorkerVersion* active_version = |
| 391 service_worker_registration->active_version(); | 391 service_worker_registration->active_version(); |
| 392 DCHECK(active_version); | 392 DCHECK(active_version); |
| 393 | 393 |
| 394 // Hold on to the service worker registration in the callback to keep it alive | 394 // Hold on to the service worker registration in the callback to keep it alive |
| 395 // until the callback dies. Otherwise the registration could be released when | 395 // until the callback dies. Otherwise the registration could be released when |
| 396 // this method returns - before the event is delivered to the service worker. | 396 // this method returns - before the event is delivered to the service worker. |
| 397 active_version->RunAfterStartWorker( | 397 active_version->RunAfterStartWorker( |
| 398 base::Bind(&GeofencingManager::OnEventError, this), | |
| 399 base::Bind(&GeofencingManager::DeliverEventToRunningWorker, this, | 398 base::Bind(&GeofencingManager::DeliverEventToRunningWorker, this, |
| 400 service_worker_registration, event_type, | 399 service_worker_registration, event_type, |
| 401 registration->region_id, registration->region, | 400 registration->region_id, registration->region, |
| 402 make_scoped_refptr(active_version))); | 401 make_scoped_refptr(active_version)), |
| 402 base::Bind(&GeofencingManager::OnEventError, this)); |
| 403 } | 403 } |
| 404 | 404 |
| 405 void GeofencingManager::DeliverEventToRunningWorker( | 405 void GeofencingManager::DeliverEventToRunningWorker( |
| 406 const scoped_refptr<ServiceWorkerRegistration>& service_worker_registration, | 406 const scoped_refptr<ServiceWorkerRegistration>& service_worker_registration, |
| 407 blink::WebGeofencingEventType event_type, | 407 blink::WebGeofencingEventType event_type, |
| 408 const std::string& region_id, | 408 const std::string& region_id, |
| 409 const blink::WebCircularGeofencingRegion& region, | 409 const blink::WebCircularGeofencingRegion& region, |
| 410 const scoped_refptr<ServiceWorkerVersion>& worker) { | 410 const scoped_refptr<ServiceWorkerVersion>& worker) { |
| 411 int request_id = | 411 int request_id = |
| 412 worker->StartRequest(ServiceWorkerMetrics::EventType::GEOFENCING, | 412 worker->StartRequest(ServiceWorkerMetrics::EventType::GEOFENCING, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 431 // TODO(mek): log/check result. | 431 // TODO(mek): log/check result. |
| 432 } | 432 } |
| 433 | 433 |
| 434 void GeofencingManager::OnEventError( | 434 void GeofencingManager::OnEventError( |
| 435 ServiceWorkerStatusCode service_worker_status) { | 435 ServiceWorkerStatusCode service_worker_status) { |
| 436 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 436 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 437 // TODO(mek): log/check errors. | 437 // TODO(mek): log/check errors. |
| 438 } | 438 } |
| 439 | 439 |
| 440 } // namespace content | 440 } // namespace content |
| OLD | NEW |