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

Unified Diff: content/child/geofencing/geofencing_dispatcher.h

Issue 476293002: Pass through geofencing API calls to the browser process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase and add region_id sanity check Created 6 years, 2 months 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 side-by-side diff with in-line comments
Download patch
Index: content/child/geofencing/geofencing_dispatcher.h
diff --git a/content/child/geofencing/geofencing_dispatcher.h b/content/child/geofencing/geofencing_dispatcher.h
new file mode 100644
index 0000000000000000000000000000000000000000..5784e4e48b83f7e553c11154e14313f9d5036fce
--- /dev/null
+++ b/content/child/geofencing/geofencing_dispatcher.h
@@ -0,0 +1,81 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_CHILD_GEOFENCING_GEOFENCING_DISPATCHER_H_
+#define CONTENT_CHILD_GEOFENCING_GEOFENCING_DISPATCHER_H_
+
+#include "base/id_map.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "content/child/worker_task_runner.h"
+#include "content/common/geofencing_status.h"
+#include "third_party/WebKit/public/platform/WebGeofencingProvider.h"
+
+namespace base {
+class MessageLoop;
+class TaskRunner;
+}
+
+namespace IPC {
+class Message;
+}
+
+namespace content {
+class ThreadSafeSender;
+
+class GeofencingDispatcher : public WorkerTaskRunner::Observer {
+ public:
+ explicit GeofencingDispatcher(ThreadSafeSender* sender);
+ virtual ~GeofencingDispatcher();
+
+ bool Send(IPC::Message* msg);
+ void OnMessageReceived(const IPC::Message& msg);
+
+ // Corresponding to WebGeofencingProvider methods.
+ void RegisterRegion(const blink::WebString& region_id,
+ const blink::WebCircularGeofencingRegion& region,
+ blink::WebGeofencingCallbacks* callbacks);
+ void UnregisterRegion(const blink::WebString& region_id,
+ blink::WebGeofencingCallbacks* callbacks);
+ void GetRegisteredRegions(blink::WebGeofencingRegionsCallbacks* callbacks);
+
+ // |thread_safe_sender| needs to be passed in because if the call leads to
+ // construction it will be needed.
+ static GeofencingDispatcher* GetOrCreateThreadSpecificInstance(
+ ThreadSafeSender* thread_safe_sender);
+
+ // Unlike GetOrCreateThreadSpecificInstance() this doesn't create a new
+ // instance if thread-local instance doesn't exist.
+ static GeofencingDispatcher* GetThreadSpecificInstance();
+
+ private:
+ void OnRegisterRegionComplete(int thread_id,
+ int request_id,
+ GeofencingStatus status);
+ void OnUnregisterRegionComplete(int thread_id,
+ int request_id,
+ GeofencingStatus status);
+ void OnGetRegisteredRegionsComplete(
+ int thread_id,
+ int request_id,
+ GeofencingStatus status,
+ const std::map<std::string, blink::WebCircularGeofencingRegion>& regions);
+
+ // WorkerTaskRunner::Observer implementation.
+ virtual void OnWorkerRunLoopStopped() OVERRIDE;
+
+ scoped_refptr<ThreadSafeSender> thread_safe_sender_;
+ IDMap<blink::WebGeofencingCallbacks, IDMapOwnPointer>
+ region_registration_requests_;
+ IDMap<blink::WebGeofencingCallbacks, IDMapOwnPointer>
+ region_unregistration_requests_;
+ IDMap<blink::WebGeofencingRegionsCallbacks, IDMapOwnPointer>
+ get_registered_regions_requests_;
+
+ DISALLOW_COPY_AND_ASSIGN(GeofencingDispatcher);
+};
+
+} // namespace content
+
+#endif // CONTENT_CHILD_GEOFENCING_GEOFENCING_DISPATCHER_H_

Powered by Google App Engine
This is Rietveld 408576698