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/child/geofencing/geofencing_dispatcher.h" | 5 #include "content/child/geofencing/geofencing_dispatcher.h" |
6 | 6 |
| 7 #include <stddef.h> |
| 8 #include <stdint.h> |
| 9 |
7 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
8 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
10 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
11 #include "content/child/service_worker/web_service_worker_registration_impl.h" | 14 #include "content/child/service_worker/web_service_worker_registration_impl.h" |
12 #include "content/child/thread_safe_sender.h" | 15 #include "content/child/thread_safe_sender.h" |
13 #include "content/common/geofencing_messages.h" | 16 #include "content/common/geofencing_messages.h" |
14 #include "content/common/service_worker/service_worker_types.h" | 17 #include "content/common/service_worker/service_worker_types.h" |
15 #include "third_party/WebKit/public/platform/WebCircularGeofencingRegion.h" | 18 #include "third_party/WebKit/public/platform/WebCircularGeofencingRegion.h" |
16 #include "third_party/WebKit/public/platform/WebGeofencingError.h" | 19 #include "third_party/WebKit/public/platform/WebGeofencingError.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 | 65 |
63 void GeofencingDispatcher::RegisterRegion( | 66 void GeofencingDispatcher::RegisterRegion( |
64 const blink::WebString& region_id, | 67 const blink::WebString& region_id, |
65 const blink::WebCircularGeofencingRegion& region, | 68 const blink::WebCircularGeofencingRegion& region, |
66 blink::WebServiceWorkerRegistration* service_worker_registration, | 69 blink::WebServiceWorkerRegistration* service_worker_registration, |
67 blink::WebGeofencingCallbacks* callbacks) { | 70 blink::WebGeofencingCallbacks* callbacks) { |
68 DCHECK(callbacks); | 71 DCHECK(callbacks); |
69 int request_id = region_registration_requests_.Add(callbacks); | 72 int request_id = region_registration_requests_.Add(callbacks); |
70 // TODO(mek): Immediately reject requests lacking a service worker | 73 // TODO(mek): Immediately reject requests lacking a service worker |
71 // registration, without bouncing through browser process. | 74 // registration, without bouncing through browser process. |
72 int64 serviceworker_registration_id = kInvalidServiceWorkerRegistrationId; | 75 int64_t serviceworker_registration_id = kInvalidServiceWorkerRegistrationId; |
73 if (service_worker_registration) { | 76 if (service_worker_registration) { |
74 serviceworker_registration_id = | 77 serviceworker_registration_id = |
75 static_cast<WebServiceWorkerRegistrationImpl*>( | 78 static_cast<WebServiceWorkerRegistrationImpl*>( |
76 service_worker_registration)->registration_id(); | 79 service_worker_registration)->registration_id(); |
77 } | 80 } |
78 Send(new GeofencingHostMsg_RegisterRegion(CurrentWorkerId(), | 81 Send(new GeofencingHostMsg_RegisterRegion(CurrentWorkerId(), |
79 request_id, | 82 request_id, |
80 region_id.utf8(), | 83 region_id.utf8(), |
81 region, | 84 region, |
82 serviceworker_registration_id)); | 85 serviceworker_registration_id)); |
83 } | 86 } |
84 | 87 |
85 void GeofencingDispatcher::UnregisterRegion( | 88 void GeofencingDispatcher::UnregisterRegion( |
86 const blink::WebString& region_id, | 89 const blink::WebString& region_id, |
87 blink::WebServiceWorkerRegistration* service_worker_registration, | 90 blink::WebServiceWorkerRegistration* service_worker_registration, |
88 blink::WebGeofencingCallbacks* callbacks) { | 91 blink::WebGeofencingCallbacks* callbacks) { |
89 DCHECK(callbacks); | 92 DCHECK(callbacks); |
90 int request_id = region_unregistration_requests_.Add(callbacks); | 93 int request_id = region_unregistration_requests_.Add(callbacks); |
91 // TODO(mek): Immediately reject requests lacking a service worker | 94 // TODO(mek): Immediately reject requests lacking a service worker |
92 // registration, without bouncing through browser process. | 95 // registration, without bouncing through browser process. |
93 int64 serviceworker_registration_id = kInvalidServiceWorkerRegistrationId; | 96 int64_t serviceworker_registration_id = kInvalidServiceWorkerRegistrationId; |
94 if (service_worker_registration) { | 97 if (service_worker_registration) { |
95 serviceworker_registration_id = | 98 serviceworker_registration_id = |
96 static_cast<WebServiceWorkerRegistrationImpl*>( | 99 static_cast<WebServiceWorkerRegistrationImpl*>( |
97 service_worker_registration)->registration_id(); | 100 service_worker_registration)->registration_id(); |
98 } | 101 } |
99 Send(new GeofencingHostMsg_UnregisterRegion(CurrentWorkerId(), | 102 Send(new GeofencingHostMsg_UnregisterRegion(CurrentWorkerId(), |
100 request_id, | 103 request_id, |
101 region_id.utf8(), | 104 region_id.utf8(), |
102 serviceworker_registration_id)); | 105 serviceworker_registration_id)); |
103 } | 106 } |
104 | 107 |
105 void GeofencingDispatcher::GetRegisteredRegions( | 108 void GeofencingDispatcher::GetRegisteredRegions( |
106 blink::WebServiceWorkerRegistration* service_worker_registration, | 109 blink::WebServiceWorkerRegistration* service_worker_registration, |
107 blink::WebGeofencingRegionsCallbacks* callbacks) { | 110 blink::WebGeofencingRegionsCallbacks* callbacks) { |
108 DCHECK(callbacks); | 111 DCHECK(callbacks); |
109 int request_id = get_registered_regions_requests_.Add(callbacks); | 112 int request_id = get_registered_regions_requests_.Add(callbacks); |
110 // TODO(mek): Immediately reject requests lacking a service worker | 113 // TODO(mek): Immediately reject requests lacking a service worker |
111 // registration, without bouncing through browser process. | 114 // registration, without bouncing through browser process. |
112 int64 serviceworker_registration_id = kInvalidServiceWorkerRegistrationId; | 115 int64_t serviceworker_registration_id = kInvalidServiceWorkerRegistrationId; |
113 if (service_worker_registration) { | 116 if (service_worker_registration) { |
114 serviceworker_registration_id = | 117 serviceworker_registration_id = |
115 static_cast<WebServiceWorkerRegistrationImpl*>( | 118 static_cast<WebServiceWorkerRegistrationImpl*>( |
116 service_worker_registration)->registration_id(); | 119 service_worker_registration)->registration_id(); |
117 } | 120 } |
118 Send(new GeofencingHostMsg_GetRegisteredRegions( | 121 Send(new GeofencingHostMsg_GetRegisteredRegions( |
119 CurrentWorkerId(), request_id, serviceworker_registration_id)); | 122 CurrentWorkerId(), request_id, serviceworker_registration_id)); |
120 } | 123 } |
121 | 124 |
122 void GeofencingDispatcher::SetMockProvider(bool service_available) { | 125 void GeofencingDispatcher::SetMockProvider(bool service_available) { |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 blink::WebString::fromUTF8(GeofencingStatusToString(status)))); | 218 blink::WebString::fromUTF8(GeofencingStatusToString(status)))); |
216 } | 219 } |
217 get_registered_regions_requests_.Remove(request_id); | 220 get_registered_regions_requests_.Remove(request_id); |
218 } | 221 } |
219 | 222 |
220 void GeofencingDispatcher::WillStopCurrentWorkerThread() { | 223 void GeofencingDispatcher::WillStopCurrentWorkerThread() { |
221 delete this; | 224 delete this; |
222 } | 225 } |
223 | 226 |
224 } // namespace content | 227 } // namespace content |
OLD | NEW |