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 "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 int64 serviceworker_registration_id = kInvalidServiceWorkerRegistrationId; | 114 int64 serviceworker_registration_id = kInvalidServiceWorkerRegistrationId; |
115 if (service_worker_registration) { | 115 if (service_worker_registration) { |
116 serviceworker_registration_id = | 116 serviceworker_registration_id = |
117 static_cast<WebServiceWorkerRegistrationImpl*>( | 117 static_cast<WebServiceWorkerRegistrationImpl*>( |
118 service_worker_registration)->registration_id(); | 118 service_worker_registration)->registration_id(); |
119 } | 119 } |
120 Send(new GeofencingHostMsg_GetRegisteredRegions( | 120 Send(new GeofencingHostMsg_GetRegisteredRegions( |
121 CurrentWorkerId(), request_id, serviceworker_registration_id)); | 121 CurrentWorkerId(), request_id, serviceworker_registration_id)); |
122 } | 122 } |
123 | 123 |
| 124 void GeofencingDispatcher::SetMockProvider(bool service_available) { |
| 125 Send(new GeofencingHostMsg_SetMockProvider( |
| 126 service_available ? GeofencingMockState::SERVICE_AVAILABLE |
| 127 : GeofencingMockState::SERVICE_UNAVAILABLE)); |
| 128 } |
| 129 |
| 130 void GeofencingDispatcher::ClearMockProvider() { |
| 131 Send(new GeofencingHostMsg_SetMockProvider(GeofencingMockState::NONE)); |
| 132 } |
| 133 |
| 134 void GeofencingDispatcher::SetMockPosition(double latitude, double longitude) { |
| 135 Send(new GeofencingHostMsg_SetMockPosition(latitude, longitude)); |
| 136 } |
| 137 |
124 GeofencingDispatcher* GeofencingDispatcher::GetOrCreateThreadSpecificInstance( | 138 GeofencingDispatcher* GeofencingDispatcher::GetOrCreateThreadSpecificInstance( |
125 ThreadSafeSender* thread_safe_sender) { | 139 ThreadSafeSender* thread_safe_sender) { |
126 if (g_dispatcher_tls.Pointer()->Get() == kHasBeenDeleted) { | 140 if (g_dispatcher_tls.Pointer()->Get() == kHasBeenDeleted) { |
127 NOTREACHED() << "Re-instantiating TLS GeofencingDispatcher."; | 141 NOTREACHED() << "Re-instantiating TLS GeofencingDispatcher."; |
128 g_dispatcher_tls.Pointer()->Set(NULL); | 142 g_dispatcher_tls.Pointer()->Set(NULL); |
129 } | 143 } |
130 if (g_dispatcher_tls.Pointer()->Get()) | 144 if (g_dispatcher_tls.Pointer()->Get()) |
131 return g_dispatcher_tls.Pointer()->Get(); | 145 return g_dispatcher_tls.Pointer()->Get(); |
132 | 146 |
133 GeofencingDispatcher* dispatcher = | 147 GeofencingDispatcher* dispatcher = |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 blink::WebString::fromUTF8(GeofencingStatusToString(status)))); | 223 blink::WebString::fromUTF8(GeofencingStatusToString(status)))); |
210 } | 224 } |
211 get_registered_regions_requests_.Remove(request_id); | 225 get_registered_regions_requests_.Remove(request_id); |
212 } | 226 } |
213 | 227 |
214 void GeofencingDispatcher::OnWorkerRunLoopStopped() { | 228 void GeofencingDispatcher::OnWorkerRunLoopStopped() { |
215 delete this; | 229 delete this; |
216 } | 230 } |
217 | 231 |
218 } // namespace content | 232 } // namespace content |
OLD | NEW |