Index: content/browser/geofencing/geofencing_dispatcher_host.cc |
diff --git a/content/browser/geofencing/geofencing_dispatcher_host.cc b/content/browser/geofencing/geofencing_dispatcher_host.cc |
index 43e5037cea3c0bd1371f5a5d243084fef62c4831..077485b38f6a31407c7dc2400408c09bce9bcd31 100644 |
--- a/content/browser/geofencing/geofencing_dispatcher_host.cc |
+++ b/content/browser/geofencing/geofencing_dispatcher_host.cc |
@@ -4,16 +4,20 @@ |
#include "content/browser/geofencing/geofencing_dispatcher_host.h" |
+#include "content/browser/geofencing/geofencing_manager.h" |
#include "content/common/geofencing_messages.h" |
-#include "content/common/geofencing_status.h" |
#include "third_party/WebKit/public/platform/WebCircularGeofencingRegion.h" |
+#include "url/gurl.h" |
namespace content { |
static const int kMaxRegionIdLength = 200; |
-GeofencingDispatcherHost::GeofencingDispatcherHost() |
- : BrowserMessageFilter(GeofencingMsgStart) { |
+GeofencingDispatcherHost::GeofencingDispatcherHost( |
+ BrowserContext* browser_context) |
+ : BrowserMessageFilter(GeofencingMsgStart), |
+ browser_context_(browser_context), |
+ weak_factory_(this) { |
} |
GeofencingDispatcherHost::~GeofencingDispatcherHost() { |
@@ -42,12 +46,17 @@ void GeofencingDispatcherHost::OnRegisterRegion( |
thread_id, request_id, GeofencingStatus::GEOFENCING_STATUS_ERROR)); |
return; |
} |
- // TODO(mek): Handle registration request. |
- Send(new GeofencingMsg_RegisterRegionComplete( |
- thread_id, |
- request_id, |
- GeofencingStatus:: |
- GEOFENCING_STATUS_OPERATION_FAILED_SERVICE_NOT_AVAILABLE)); |
+ // TODO(mek): Actually pass service worker information to manager. |
+ GeofencingManager::GetInstance()->RegisterRegion( |
+ browser_context_, |
+ 0, /* service_worker_registration_id */ |
+ GURL(), /* service_worker_origin */ |
+ region_id, |
+ region, |
+ base::Bind(&GeofencingDispatcherHost::RegisterRegionCompleted, |
+ weak_factory_.GetWeakPtr(), |
+ thread_id, |
+ request_id)); |
} |
void GeofencingDispatcherHost::OnUnregisterRegion( |
@@ -60,23 +69,45 @@ void GeofencingDispatcherHost::OnUnregisterRegion( |
thread_id, request_id, GeofencingStatus::GEOFENCING_STATUS_ERROR)); |
return; |
} |
- // TODO(mek): Handle unregistration request. |
- Send(new GeofencingMsg_UnregisterRegionComplete( |
- thread_id, |
- request_id, |
- GeofencingStatus:: |
- GEOFENCING_STATUS_OPERATION_FAILED_SERVICE_NOT_AVAILABLE)); |
+ // TODO(mek): Actually pass service worker information to manager. |
+ GeofencingManager::GetInstance()->UnregisterRegion( |
+ browser_context_, |
+ 0, /* service_worker_registration_id */ |
+ GURL(), /* service_worker_origin */ |
+ region_id, |
+ base::Bind(&GeofencingDispatcherHost::UnregisterRegionCompleted, |
+ weak_factory_.GetWeakPtr(), |
+ thread_id, |
+ request_id)); |
} |
void GeofencingDispatcherHost::OnGetRegisteredRegions(int thread_id, |
int request_id) { |
GeofencingRegistrations result; |
+ // TODO(mek): Actually pass service worker information to manager. |
+ GeofencingStatus status = |
+ GeofencingManager::GetInstance()->GetRegisteredRegions( |
+ browser_context_, |
+ 0, /* service_worker_registration_id */ |
+ GURL(), /* service_worker_origin */ |
+ &result); |
Send(new GeofencingMsg_GetRegisteredRegionsComplete( |
- thread_id, |
- request_id, |
- GeofencingStatus:: |
- GEOFENCING_STATUS_OPERATION_FAILED_SERVICE_NOT_AVAILABLE, |
- result)); |
+ thread_id, request_id, status, result)); |
+} |
+ |
+void GeofencingDispatcherHost::RegisterRegionCompleted( |
+ int thread_id, |
+ int request_id, |
+ GeofencingStatus status) { |
+ Send(new GeofencingMsg_RegisterRegionComplete(thread_id, request_id, status)); |
+} |
+ |
+void GeofencingDispatcherHost::UnregisterRegionCompleted( |
+ int thread_id, |
+ int request_id, |
+ GeofencingStatus status) { |
+ Send(new GeofencingMsg_UnregisterRegionComplete( |
+ thread_id, request_id, status)); |
} |
} // namespace content |