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

Side by Side Diff: content/child/geofencing/geofencing_dispatcher.cc

Issue 701953007: Expose mock geofencing service via testRunner. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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 unified diff | Download patch
OLDNEW
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
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(
125 blink::WebServiceWorkerRegistration* service_worker_registration,
126 bool service_available) {
127 DCHECK(service_worker_registration);
128 int64 service_worker_registration_id =
129 static_cast<WebServiceWorkerRegistrationImpl*>(
130 service_worker_registration)->registration_id();
131 Send(new GeofencingHostMsg_SetMockProvider(
132 service_worker_registration_id,
133 service_available ? GeofencingMockState::SERVICE_AVAILABLE
134 : GeofencingMockState::SERVICE_UNAVAILABLE));
135 }
136
137 void GeofencingDispatcher::ClearMockProvider(
138 blink::WebServiceWorkerRegistration* service_worker_registration) {
139 DCHECK(service_worker_registration);
140 int64 service_worker_registration_id =
141 static_cast<WebServiceWorkerRegistrationImpl*>(
142 service_worker_registration)->registration_id();
143 Send(new GeofencingHostMsg_SetMockProvider(service_worker_registration_id,
144 GeofencingMockState::NONE));
145 }
146
147 void GeofencingDispatcher::SetMockPosition(
148 blink::WebServiceWorkerRegistration* service_worker_registration,
149 double latitude,
150 double longitude) {
151 DCHECK(service_worker_registration);
152 int64 service_worker_registration_id =
153 static_cast<WebServiceWorkerRegistrationImpl*>(
154 service_worker_registration)->registration_id();
155 Send(new GeofencingHostMsg_SetMockPosition(service_worker_registration_id,
156 latitude, longitude));
157 }
158
124 GeofencingDispatcher* GeofencingDispatcher::GetOrCreateThreadSpecificInstance( 159 GeofencingDispatcher* GeofencingDispatcher::GetOrCreateThreadSpecificInstance(
125 ThreadSafeSender* thread_safe_sender) { 160 ThreadSafeSender* thread_safe_sender) {
126 if (g_dispatcher_tls.Pointer()->Get() == kHasBeenDeleted) { 161 if (g_dispatcher_tls.Pointer()->Get() == kHasBeenDeleted) {
127 NOTREACHED() << "Re-instantiating TLS GeofencingDispatcher."; 162 NOTREACHED() << "Re-instantiating TLS GeofencingDispatcher.";
128 g_dispatcher_tls.Pointer()->Set(NULL); 163 g_dispatcher_tls.Pointer()->Set(NULL);
129 } 164 }
130 if (g_dispatcher_tls.Pointer()->Get()) 165 if (g_dispatcher_tls.Pointer()->Get())
131 return g_dispatcher_tls.Pointer()->Get(); 166 return g_dispatcher_tls.Pointer()->Get();
132 167
133 GeofencingDispatcher* dispatcher = 168 GeofencingDispatcher* dispatcher =
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 blink::WebString::fromUTF8(GeofencingStatusToString(status)))); 244 blink::WebString::fromUTF8(GeofencingStatusToString(status))));
210 } 245 }
211 get_registered_regions_requests_.Remove(request_id); 246 get_registered_regions_requests_.Remove(request_id);
212 } 247 }
213 248
214 void GeofencingDispatcher::OnWorkerRunLoopStopped() { 249 void GeofencingDispatcher::OnWorkerRunLoopStopped() {
215 delete this; 250 delete this;
216 } 251 }
217 252
218 } // namespace content 253 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698