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

Unified Diff: content/browser/geofencing/geofencing_dispatcher_host.cc

Issue 586163003: Basic implementation of GeofencingManager class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@geofencing5
Patch Set: fix this on the branch I'm uploading from Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698