| 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/browser/geofencing/geofencing_manager.h" |
| 8 #include "content/browser/service_worker/service_worker_context_core.h" | 8 #include "content/browser/service_worker/service_worker_context_core.h" |
| 9 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 9 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
| 10 #include "content/browser/service_worker/service_worker_registration.h" | 10 #include "content/browser/service_worker/service_worker_registration.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 IPC_MESSAGE_UNHANDLED(handled = false) | 39 IPC_MESSAGE_UNHANDLED(handled = false) |
| 40 IPC_END_MESSAGE_MAP() | 40 IPC_END_MESSAGE_MAP() |
| 41 return handled; | 41 return handled; |
| 42 } | 42 } |
| 43 | 43 |
| 44 void GeofencingDispatcherHost::OnRegisterRegion( | 44 void GeofencingDispatcherHost::OnRegisterRegion( |
| 45 int thread_id, | 45 int thread_id, |
| 46 int request_id, | 46 int request_id, |
| 47 const std::string& region_id, | 47 const std::string& region_id, |
| 48 const blink::WebCircularGeofencingRegion& region, | 48 const blink::WebCircularGeofencingRegion& region, |
| 49 int64 service_worker_registration_id) { | 49 int64_t service_worker_registration_id) { |
| 50 // Sanity check on region_id | 50 // Sanity check on region_id |
| 51 if (region_id.length() > kMaxRegionIdLength) { | 51 if (region_id.length() > kMaxRegionIdLength) { |
| 52 Send(new GeofencingMsg_RegisterRegionComplete( | 52 Send(new GeofencingMsg_RegisterRegionComplete( |
| 53 thread_id, request_id, GeofencingStatus::GEOFENCING_STATUS_ERROR)); | 53 thread_id, request_id, GeofencingStatus::GEOFENCING_STATUS_ERROR)); |
| 54 return; | 54 return; |
| 55 } | 55 } |
| 56 | 56 |
| 57 manager_->RegisterRegion( | 57 manager_->RegisterRegion( |
| 58 service_worker_registration_id, | 58 service_worker_registration_id, |
| 59 region_id, | 59 region_id, |
| 60 region, | 60 region, |
| 61 base::Bind(&GeofencingDispatcherHost::RegisterRegionCompleted, | 61 base::Bind(&GeofencingDispatcherHost::RegisterRegionCompleted, |
| 62 weak_factory_.GetWeakPtr(), | 62 weak_factory_.GetWeakPtr(), |
| 63 thread_id, | 63 thread_id, |
| 64 request_id)); | 64 request_id)); |
| 65 } | 65 } |
| 66 | 66 |
| 67 void GeofencingDispatcherHost::OnUnregisterRegion( | 67 void GeofencingDispatcherHost::OnUnregisterRegion( |
| 68 int thread_id, | 68 int thread_id, |
| 69 int request_id, | 69 int request_id, |
| 70 const std::string& region_id, | 70 const std::string& region_id, |
| 71 int64 service_worker_registration_id) { | 71 int64_t service_worker_registration_id) { |
| 72 // Sanity check on region_id | 72 // Sanity check on region_id |
| 73 if (region_id.length() > kMaxRegionIdLength) { | 73 if (region_id.length() > kMaxRegionIdLength) { |
| 74 Send(new GeofencingMsg_UnregisterRegionComplete( | 74 Send(new GeofencingMsg_UnregisterRegionComplete( |
| 75 thread_id, request_id, GeofencingStatus::GEOFENCING_STATUS_ERROR)); | 75 thread_id, request_id, GeofencingStatus::GEOFENCING_STATUS_ERROR)); |
| 76 return; | 76 return; |
| 77 } | 77 } |
| 78 | 78 |
| 79 manager_->UnregisterRegion( | 79 manager_->UnregisterRegion( |
| 80 service_worker_registration_id, | 80 service_worker_registration_id, |
| 81 region_id, | 81 region_id, |
| 82 base::Bind(&GeofencingDispatcherHost::UnregisterRegionCompleted, | 82 base::Bind(&GeofencingDispatcherHost::UnregisterRegionCompleted, |
| 83 weak_factory_.GetWeakPtr(), | 83 weak_factory_.GetWeakPtr(), |
| 84 thread_id, | 84 thread_id, |
| 85 request_id)); | 85 request_id)); |
| 86 } | 86 } |
| 87 | 87 |
| 88 void GeofencingDispatcherHost::OnGetRegisteredRegions( | 88 void GeofencingDispatcherHost::OnGetRegisteredRegions( |
| 89 int thread_id, | 89 int thread_id, |
| 90 int request_id, | 90 int request_id, |
| 91 int64 service_worker_registration_id) { | 91 int64_t service_worker_registration_id) { |
| 92 GeofencingRegistrations result; | 92 GeofencingRegistrations result; |
| 93 | 93 |
| 94 GeofencingStatus status = | 94 GeofencingStatus status = |
| 95 manager_->GetRegisteredRegions(service_worker_registration_id, &result); | 95 manager_->GetRegisteredRegions(service_worker_registration_id, &result); |
| 96 Send(new GeofencingMsg_GetRegisteredRegionsComplete( | 96 Send(new GeofencingMsg_GetRegisteredRegionsComplete( |
| 97 thread_id, request_id, status, result)); | 97 thread_id, request_id, status, result)); |
| 98 } | 98 } |
| 99 | 99 |
| 100 void GeofencingDispatcherHost::RegisterRegionCompleted( | 100 void GeofencingDispatcherHost::RegisterRegionCompleted( |
| 101 int thread_id, | 101 int thread_id, |
| 102 int request_id, | 102 int request_id, |
| 103 GeofencingStatus status) { | 103 GeofencingStatus status) { |
| 104 Send(new GeofencingMsg_RegisterRegionComplete(thread_id, request_id, status)); | 104 Send(new GeofencingMsg_RegisterRegionComplete(thread_id, request_id, status)); |
| 105 } | 105 } |
| 106 | 106 |
| 107 void GeofencingDispatcherHost::UnregisterRegionCompleted( | 107 void GeofencingDispatcherHost::UnregisterRegionCompleted( |
| 108 int thread_id, | 108 int thread_id, |
| 109 int request_id, | 109 int request_id, |
| 110 GeofencingStatus status) { | 110 GeofencingStatus status) { |
| 111 Send(new GeofencingMsg_UnregisterRegionComplete( | 111 Send(new GeofencingMsg_UnregisterRegionComplete( |
| 112 thread_id, request_id, status)); | 112 thread_id, request_id, status)); |
| 113 } | 113 } |
| 114 | 114 |
| 115 } // namespace content | 115 } // namespace content |
| OLD | NEW |