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

Side by Side Diff: content/browser/geolocation/geolocation_dispatcher_host.h

Issue 262753006: Merge GeolocationDispatcherHostImpl with GeolocationDispatcher. None of the other message filters h… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: reupload after revert with fix Created 6 years, 7 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
« no previous file with comments | « no previous file | content/browser/geolocation/geolocation_dispatcher_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_DISPATCHER_HOST_H_ 5 #ifndef CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_DISPATCHER_HOST_H_
6 #define CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_DISPATCHER_HOST_H_ 6 #define CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_DISPATCHER_HOST_H_
7 7
8 #include <map>
9 #include <set>
10
11 #include "content/browser/geolocation/geolocation_provider_impl.h"
8 #include "content/public/browser/browser_message_filter.h" 12 #include "content/public/browser/browser_message_filter.h"
9 13
14 class GURL;
15
10 namespace content { 16 namespace content {
11 17
12 class GeolocationPermissionContext; 18 class GeolocationPermissionContext;
13 19
14 // GeolocationDispatcherHost is a browser filter for Geolocation messages. 20 // GeolocationDispatcherHost is a browser filter for Geolocation messages.
15 // It's the complement of GeolocationDispatcher (owned by RenderView). 21 // It's the complement of GeolocationDispatcher (owned by RenderView).
16 class GeolocationDispatcherHost : public BrowserMessageFilter { 22 class GeolocationDispatcherHost : public BrowserMessageFilter {
17 public: 23 public:
18 static GeolocationDispatcherHost* New( 24 GeolocationDispatcherHost(
19 int render_process_id, 25 int render_process_id,
20 GeolocationPermissionContext* geolocation_permission_context); 26 GeolocationPermissionContext* geolocation_permission_context);
21 27
22 // Pause or resumes geolocation for the given |render_view_id|. Should 28 // Pause or resumes geolocation for the given |render_view_id|. Should
23 // be called on the IO thread. Resuming when nothing is paused is a no-op. 29 // be called on the IO thread. Resuming when nothing is paused is a no-op.
24 // If a renderer is paused while not currently using geolocation but 30 // If a renderer is paused while not currently using geolocation but
25 // then goes on to do so before being resumed, then that renderer will 31 // then goes on to do so before being resumed, then that renderer will
26 // not get geolocation updates until it is resumed. 32 // not get geolocation updates until it is resumed.
27 virtual void PauseOrResume(int render_view_id, bool should_pause) = 0; 33 void PauseOrResume(int render_view_id, bool should_pause);
28 34
29 protected: 35 private:
30 GeolocationDispatcherHost();
31 virtual ~GeolocationDispatcherHost(); 36 virtual ~GeolocationDispatcherHost();
32 37
38 // GeolocationDispatcherHost
39 virtual bool OnMessageReceived(const IPC::Message& msg,
40 bool* msg_was_ok) OVERRIDE;
41
42 // Message handlers:
43 void OnRequestPermission(int render_view_id,
44 int bridge_id,
45 const GURL& requesting_frame,
46 bool user_gesture);
47 void OnCancelPermissionRequest(int render_view_id,
48 int bridge_id,
49 const GURL& requesting_frame);
50 void OnStartUpdating(int render_view_id,
51 const GURL& requesting_frame,
52 bool enable_high_accuracy);
53 void OnStopUpdating(int render_view_id);
54
55 // Updates the |geolocation_provider_| with the currently required update
56 // options.
57 void RefreshGeolocationOptions();
58
59 void OnLocationUpdate(const Geoposition& position);
60
61 int render_process_id_;
62 scoped_refptr<GeolocationPermissionContext> geolocation_permission_context_;
63
64 struct RendererGeolocationOptions {
65 bool high_accuracy;
66 bool is_paused;
67 };
68
69 // Used to keep track of the renderers in this process that are using
70 // geolocation and the options associated with them. The map is iterated
71 // when a location update is available and the fan out to individual bridge
72 // IDs happens renderer side, in order to minimize context switches.
73 // Only used on the IO thread.
74 std::map<int, RendererGeolocationOptions> geolocation_renderers_;
75
76 // Used by Android WebView to support that case that a renderer is in the
77 // 'paused' state but not yet using geolocation. If the renderer does start
78 // using geolocation while paused, we move from this set into
79 // |geolocation_renderers_|. If the renderer doesn't end up wanting to use
80 // geolocation while 'paused' then we remove from this set. A renderer id
81 // can exist only in this set or |geolocation_renderers_|, never both.
82 std::set<int> pending_paused_geolocation_renderers_;
83
84 // Only set whilst we are registered with the geolocation provider.
85 GeolocationProviderImpl* geolocation_provider_;
86
87 GeolocationProviderImpl::LocationUpdateCallback callback_;
88
33 DISALLOW_COPY_AND_ASSIGN(GeolocationDispatcherHost); 89 DISALLOW_COPY_AND_ASSIGN(GeolocationDispatcherHost);
34 }; 90 };
35 91
36 } // namespace content 92 } // namespace content
37 93
38 #endif // CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_DISPATCHER_HOST_H_ 94 #endif // CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_DISPATCHER_HOST_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/geolocation/geolocation_dispatcher_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698