Chromium Code Reviews| 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_dispatcher_host.h" | 5 #include "content/browser/geofencing/geofencing_dispatcher_host.h" |
| 6 | 6 |
| 7 #include "content/browser/geofencing/geofencing_manager.h" | |
| 7 #include "content/common/geofencing_messages.h" | 8 #include "content/common/geofencing_messages.h" |
| 8 #include "content/common/geofencing_status.h" | |
| 9 #include "third_party/WebKit/public/platform/WebCircularGeofencingRegion.h" | 9 #include "third_party/WebKit/public/platform/WebCircularGeofencingRegion.h" |
| 10 | 10 |
| 11 namespace content { | 11 namespace content { |
| 12 | 12 |
| 13 static const int kMaxRegionIdLength = 200; | 13 static const int kMaxRegionIdLength = 200; |
| 14 | 14 |
| 15 GeofencingDispatcherHost::GeofencingDispatcherHost() | 15 GeofencingDispatcherHost::GeofencingDispatcherHost() |
| 16 : BrowserMessageFilter(GeofencingMsgStart) { | 16 : BrowserMessageFilter(GeofencingMsgStart) { |
| 17 } | 17 } |
| 18 | 18 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 35 int thread_id, | 35 int thread_id, |
| 36 int request_id, | 36 int request_id, |
| 37 const std::string& region_id, | 37 const std::string& region_id, |
| 38 const blink::WebCircularGeofencingRegion& region) { | 38 const blink::WebCircularGeofencingRegion& region) { |
| 39 // Sanity check on region_id | 39 // Sanity check on region_id |
| 40 if (region_id.length() > kMaxRegionIdLength) { | 40 if (region_id.length() > kMaxRegionIdLength) { |
| 41 Send(new GeofencingMsg_RegisterRegionComplete( | 41 Send(new GeofencingMsg_RegisterRegionComplete( |
| 42 thread_id, request_id, GeofencingStatus::GEOFENCING_STATUS_ERROR)); | 42 thread_id, request_id, GeofencingStatus::GEOFENCING_STATUS_ERROR)); |
| 43 return; | 43 return; |
| 44 } | 44 } |
| 45 // TODO(mek): Handle registration request. | 45 GeofencingManager::GetInstance()->RegisterRegion( |
| 46 Send(new GeofencingMsg_RegisterRegionComplete( | 46 0, /* service_worker_registration_id */ |
|
Michael van Ouwerkerk
2014/10/06 16:43:42
I assume you need a TODO here? And below.
Marijn Kruisselbrink
2014/10/06 19:14:11
Sure, I can add more TODO's here as well, although
Michael van Ouwerkerk
2014/10/08 16:59:01
TODO's are not just reminders for your future self
| |
| 47 thread_id, | 47 region_id, |
| 48 request_id, | 48 region, |
| 49 GeofencingStatus:: | 49 base::Bind(&GeofencingDispatcherHost::RegisterRegionCompleted, |
| 50 GEOFENCING_STATUS_OPERATION_FAILED_SERVICE_NOT_AVAILABLE)); | 50 this, |
|
Michael van Ouwerkerk
2014/10/06 16:43:41
Should this be a weak pointer?
Marijn Kruisselbrink
2014/10/06 19:14:11
Yes, that's probably better. Done.
| |
| 51 thread_id, | |
| 52 request_id)); | |
| 51 } | 53 } |
| 52 | 54 |
| 53 void GeofencingDispatcherHost::OnUnregisterRegion( | 55 void GeofencingDispatcherHost::OnUnregisterRegion( |
| 54 int thread_id, | 56 int thread_id, |
| 55 int request_id, | 57 int request_id, |
| 56 const std::string& region_id) { | 58 const std::string& region_id) { |
| 57 // Sanity check on region_id | 59 // Sanity check on region_id |
| 58 if (region_id.length() > kMaxRegionIdLength) { | 60 if (region_id.length() > kMaxRegionIdLength) { |
| 59 Send(new GeofencingMsg_UnregisterRegionComplete( | 61 Send(new GeofencingMsg_UnregisterRegionComplete( |
| 60 thread_id, request_id, GeofencingStatus::GEOFENCING_STATUS_ERROR)); | 62 thread_id, request_id, GeofencingStatus::GEOFENCING_STATUS_ERROR)); |
| 61 return; | 63 return; |
| 62 } | 64 } |
| 63 // TODO(mek): Handle unregistration request. | 65 GeofencingManager::GetInstance()->UnregisterRegion( |
| 64 Send(new GeofencingMsg_UnregisterRegionComplete( | 66 0, /* service_worker_registration_id */ |
| 65 thread_id, | 67 region_id, |
| 66 request_id, | 68 base::Bind(&GeofencingDispatcherHost::UnregisterRegionCompleted, |
| 67 GeofencingStatus:: | 69 this, |
| 68 GEOFENCING_STATUS_OPERATION_FAILED_SERVICE_NOT_AVAILABLE)); | 70 thread_id, |
| 71 request_id)); | |
| 69 } | 72 } |
| 70 | 73 |
| 71 void GeofencingDispatcherHost::OnGetRegisteredRegions(int thread_id, | 74 void GeofencingDispatcherHost::OnGetRegisteredRegions(int thread_id, |
| 72 int request_id) { | 75 int request_id) { |
| 73 GeofencingRegistrations result; | 76 GeofencingRegistrations result; |
| 77 GeofencingStatus status = | |
| 78 GeofencingManager::GetInstance()->GetRegisteredRegions( | |
| 79 0, /* service_worker_registration_id */ | |
| 80 &result); | |
| 74 Send(new GeofencingMsg_GetRegisteredRegionsComplete( | 81 Send(new GeofencingMsg_GetRegisteredRegionsComplete( |
| 75 thread_id, | 82 thread_id, request_id, status, result)); |
| 76 request_id, | 83 } |
| 77 GeofencingStatus:: | 84 |
| 78 GEOFENCING_STATUS_OPERATION_FAILED_SERVICE_NOT_AVAILABLE, | 85 void GeofencingDispatcherHost::RegisterRegionCompleted( |
| 79 result)); | 86 int thread_id, |
| 87 int request_id, | |
| 88 GeofencingStatus result) { | |
|
Michael van Ouwerkerk
2014/10/06 16:43:41
Let's call this status as you use result for other
Marijn Kruisselbrink
2014/10/06 19:14:11
Done.
| |
| 89 Send(new GeofencingMsg_RegisterRegionComplete(thread_id, request_id, result)); | |
| 90 } | |
| 91 | |
| 92 void GeofencingDispatcherHost::UnregisterRegionCompleted( | |
| 93 int thread_id, | |
| 94 int request_id, | |
| 95 GeofencingStatus result) { | |
| 96 Send(new GeofencingMsg_UnregisterRegionComplete( | |
| 97 thread_id, request_id, result)); | |
| 80 } | 98 } |
| 81 | 99 |
| 82 } // namespace content | 100 } // namespace content |
| OLD | NEW |