Miscellaneous fixes for virtual/override/final specifiers to match style guide.
[chromium-blink-merge.git] / content / child / geofencing / geofencing_dispatcher.h
blob269dfe7c031f4b28fbfed0f63728ed8032dc0c13
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_CHILD_GEOFENCING_GEOFENCING_DISPATCHER_H_
6 #define CONTENT_CHILD_GEOFENCING_GEOFENCING_DISPATCHER_H_
8 #include "base/id_map.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "content/child/worker_task_runner.h"
12 #include "content/common/geofencing_types.h"
13 #include "third_party/WebKit/public/platform/WebGeofencingProvider.h"
15 namespace base {
16 class MessageLoop;
17 class TaskRunner;
20 namespace IPC {
21 class Message;
24 namespace content {
25 class ThreadSafeSender;
27 class GeofencingDispatcher : public WorkerTaskRunner::Observer {
28 public:
29 explicit GeofencingDispatcher(ThreadSafeSender* sender);
30 ~GeofencingDispatcher() override;
32 bool Send(IPC::Message* msg);
33 void OnMessageReceived(const IPC::Message& msg);
35 // Corresponding to WebGeofencingProvider methods.
36 void RegisterRegion(
37 const blink::WebString& region_id,
38 const blink::WebCircularGeofencingRegion& region,
39 blink::WebServiceWorkerRegistration* service_worker_registration,
40 blink::WebGeofencingCallbacks* callbacks);
41 void UnregisterRegion(
42 const blink::WebString& region_id,
43 blink::WebServiceWorkerRegistration* service_worker_registration,
44 blink::WebGeofencingCallbacks* callbacks);
45 void GetRegisteredRegions(
46 blink::WebServiceWorkerRegistration* service_worker_registration,
47 blink::WebGeofencingRegionsCallbacks* callbacks);
49 // Enables mock geofencing service. |service_available| indicates if the
50 // mock service should mock geofencing being available or not.
51 void SetMockProvider(bool service_available);
52 // Disables mock geofencing service.
53 void ClearMockProvider();
54 // Set the mock geofencing position.
55 void SetMockPosition(double latitude, double longitude);
57 // |thread_safe_sender| needs to be passed in because if the call leads to
58 // construction it will be needed.
59 static GeofencingDispatcher* GetOrCreateThreadSpecificInstance(
60 ThreadSafeSender* thread_safe_sender);
62 // Unlike GetOrCreateThreadSpecificInstance() this doesn't create a new
63 // instance if thread-local instance doesn't exist.
64 static GeofencingDispatcher* GetThreadSpecificInstance();
66 private:
67 void OnRegisterRegionComplete(int thread_id,
68 int request_id,
69 GeofencingStatus status);
70 void OnUnregisterRegionComplete(int thread_id,
71 int request_id,
72 GeofencingStatus status);
73 void OnGetRegisteredRegionsComplete(
74 int thread_id,
75 int request_id,
76 GeofencingStatus status,
77 const std::map<std::string, blink::WebCircularGeofencingRegion>& regions);
79 // WorkerTaskRunner::Observer implementation.
80 void OnWorkerRunLoopStopped() override;
82 scoped_refptr<ThreadSafeSender> thread_safe_sender_;
83 IDMap<blink::WebGeofencingCallbacks, IDMapOwnPointer>
84 region_registration_requests_;
85 IDMap<blink::WebGeofencingCallbacks, IDMapOwnPointer>
86 region_unregistration_requests_;
87 IDMap<blink::WebGeofencingRegionsCallbacks, IDMapOwnPointer>
88 get_registered_regions_requests_;
90 DISALLOW_COPY_AND_ASSIGN(GeofencingDispatcher);
93 } // namespace content
95 #endif // CONTENT_CHILD_GEOFENCING_GEOFENCING_DISPATCHER_H_