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

Side by Side Diff: third_party/WebKit/Source/web/WebGeolocationController.cpp

Issue 1444333002: WebGeolocationController: improve handling of bare GeolocationController* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 11 matching lines...) Expand all
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #include "config.h" 26 #include "config.h"
27 #include "public/web/WebGeolocationController.h" 27 #include "public/web/WebGeolocationController.h"
28 28
29 #include "modules/geolocation/GeolocationController.h" 29 #include "modules/geolocation/GeolocationController.h"
30 #include "modules/geolocation/GeolocationError.h" 30 #include "modules/geolocation/GeolocationError.h"
31 #include "modules/geolocation/GeolocationPosition.h" 31 #include "modules/geolocation/GeolocationPosition.h"
32 #include "platform/heap/Handle.h"
32 #include "public/web/WebGeolocationError.h" 33 #include "public/web/WebGeolocationError.h"
33 #include "public/web/WebGeolocationPosition.h" 34 #include "public/web/WebGeolocationPosition.h"
35 #include "wtf/RefCounted.h"
34 36
35 namespace blink { 37 namespace blink {
36 38
39 #if ENABLE(OILPAN)
40 // TODO(Oilpan): once GeolocationController is always on the heap,
41 // shorten out this GeolocationControllerPrivate intermediary.
42 class GeolocationControllerPrivate : public GeolocationController {
43 public:
44 static GeolocationController& controller(const WebPrivatePtr<GeolocationCont rollerPrivate>& controller)
45 {
46 ASSERT(!controller.isNull());
47 return *controller;
48 }
49 };
50 #else
51 class GeolocationControllerPrivate final : public RefCounted<GeolocationControll erPrivate> {
52 public:
53 static PassRefPtr<GeolocationControllerPrivate> create(GeolocationController * controller)
54 {
55 return adoptRef(new GeolocationControllerPrivate(controller));
56 }
57
58 static GeolocationController& controller(const WebPrivatePtr<GeolocationCont rollerPrivate>& controller)
59 {
60 ASSERT(!controller.isNull());
61 ASSERT(controller->m_controller);
62 return *controller->m_controller;
63 }
64
65 private:
66 explicit GeolocationControllerPrivate(GeolocationController* controller)
67 : m_controller(controller)
68 {
69 }
70
71 // Non-Oilpan, this bare pointer is owned as a supplement and kept alive
72 // by the frame of the WebLocalFrame which creates the WebGeolocationControl ler
73 // object that wraps it all up.
74 GeolocationController* m_controller;
75 };
76 #endif
77
78 WebGeolocationController::WebGeolocationController(GeolocationController* contro ller)
79 #if ENABLE(OILPAN)
80 : m_private(static_cast<GeolocationControllerPrivate*>(controller))
81 #else
82 : m_private(GeolocationControllerPrivate::create(controller))
83 #endif
84 {
85 }
86
87 void WebGeolocationController::reset()
88 {
89 m_private.reset();
90 }
91
37 void WebGeolocationController::positionChanged(const WebGeolocationPosition& web Position) 92 void WebGeolocationController::positionChanged(const WebGeolocationPosition& web Position)
38 { 93 {
39 m_private->positionChanged(static_cast<GeolocationPosition*>(webPosition)); 94 GeolocationControllerPrivate::controller(m_private).positionChanged(static_c ast<GeolocationPosition*>(webPosition));
40 } 95 }
41 96
42 void WebGeolocationController::errorOccurred(const WebGeolocationError& webError ) 97 void WebGeolocationController::errorOccurred(const WebGeolocationError& webError )
43 { 98 {
44 m_private->errorOccurred(static_cast<GeolocationError*>(webError)); 99 GeolocationControllerPrivate::controller(m_private).errorOccurred(static_cas t<GeolocationError*>(webError));
45 } 100 }
46 101
47 } // namespace blink 102 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698