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

Side by Side Diff: content/browser/geofencing/geofencing_dispatcher_host.cc

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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
5 #include "content/browser/geofencing/geofencing_dispatcher_host.h"
6
7 #include "content/common/geofencing_messages.h"
8 #include "content/common/geofencing_status.h"
9 #include "third_party/WebKit/public/platform/WebCircularGeofencingRegion.h"
10
11 namespace content {
12
13 static const int kMaxRegionIdLength = 200;
palmer 2014/10/02 18:24:00 Note that, in the future, if you need to increase
14
15 GeofencingDispatcherHost::GeofencingDispatcherHost()
16 : BrowserMessageFilter(GeofencingMsgStart) {
17 }
18
19 GeofencingDispatcherHost::~GeofencingDispatcherHost() {
20 }
21
22 bool GeofencingDispatcherHost::OnMessageReceived(const IPC::Message& message) {
23 bool handled = true;
24 IPC_BEGIN_MESSAGE_MAP(GeofencingDispatcherHost, message)
25 IPC_MESSAGE_HANDLER(GeofencingHostMsg_RegisterRegion, OnRegisterRegion)
26 IPC_MESSAGE_HANDLER(GeofencingHostMsg_UnregisterRegion, OnUnregisterRegion)
27 IPC_MESSAGE_HANDLER(GeofencingHostMsg_GetRegisteredRegions,
28 OnGetRegisteredRegions)
29 IPC_MESSAGE_UNHANDLED(handled = false)
30 IPC_END_MESSAGE_MAP()
31 return handled;
32 }
33
34 void GeofencingDispatcherHost::OnRegisterRegion(
35 int thread_id,
36 int request_id,
37 const std::string& region_id,
38 const blink::WebCircularGeofencingRegion& region) {
39 // Sanity check on region_id
40 if (region_id.length() > kMaxRegionIdLength) {
41 Send(new GeofencingMsg_RegisterRegionComplete(
42 thread_id, request_id, GeofencingStatus::GEOFENCING_STATUS_ERROR));
43 return;
44 }
45 // TODO(mek): Handle registration request.
46 Send(new GeofencingMsg_RegisterRegionComplete(
47 thread_id,
48 request_id,
49 GeofencingStatus::
50 GEOFENCING_STATUS_OPERATION_FAILED_SERVICE_NOT_AVAILABLE));
51 }
52
53 void GeofencingDispatcherHost::OnUnregisterRegion(
54 int thread_id,
55 int request_id,
56 const std::string& region_id) {
57 // Sanity check on region_id
58 if (region_id.length() > kMaxRegionIdLength) {
palmer 2014/10/02 18:24:00 At some point, a unit test for this would be good.
59 Send(new GeofencingMsg_UnregisterRegionComplete(
60 thread_id, request_id, GeofencingStatus::GEOFENCING_STATUS_ERROR));
61 return;
62 }
63 // TODO(mek): Handle unregistration request.
64 Send(new GeofencingMsg_UnregisterRegionComplete(
65 thread_id,
66 request_id,
67 GeofencingStatus::
68 GEOFENCING_STATUS_OPERATION_FAILED_SERVICE_NOT_AVAILABLE));
69 }
70
71 void GeofencingDispatcherHost::OnGetRegisteredRegions(int thread_id,
72 int request_id) {
73 GeofencingRegistrations result;
74 Send(new GeofencingMsg_GetRegisteredRegionsComplete(
75 thread_id,
76 request_id,
77 GeofencingStatus::
78 GEOFENCING_STATUS_OPERATION_FAILED_SERVICE_NOT_AVAILABLE,
79 result));
80 }
81
82 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/geofencing/geofencing_dispatcher_host.h ('k') | content/browser/renderer_host/render_process_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698