| OLD | NEW |
| 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 17 matching lines...) Expand all Loading... |
| 28 #include "modules/geolocation/GeolocationController.h" | 28 #include "modules/geolocation/GeolocationController.h" |
| 29 #include "modules/geolocation/GeolocationError.h" | 29 #include "modules/geolocation/GeolocationError.h" |
| 30 #include "modules/geolocation/GeolocationPosition.h" | 30 #include "modules/geolocation/GeolocationPosition.h" |
| 31 #include "platform/heap/Handle.h" | 31 #include "platform/heap/Handle.h" |
| 32 #include "public/web/WebGeolocationError.h" | 32 #include "public/web/WebGeolocationError.h" |
| 33 #include "public/web/WebGeolocationPosition.h" | 33 #include "public/web/WebGeolocationPosition.h" |
| 34 #include "wtf/RefCounted.h" | 34 #include "wtf/RefCounted.h" |
| 35 | 35 |
| 36 namespace blink { | 36 namespace blink { |
| 37 | 37 |
| 38 #if ENABLE(OILPAN) | |
| 39 // TODO(Oilpan): once GeolocationController is always on the heap, | 38 // TODO(Oilpan): once GeolocationController is always on the heap, |
| 40 // shorten out this GeolocationControllerPrivate intermediary. | 39 // shorten out this GeolocationControllerPrivate intermediary. |
| 41 class GeolocationControllerPrivate : public GeolocationController { | 40 class GeolocationControllerPrivate final : public RefCountedWillBeGarbageCollect
ed<GeolocationControllerPrivate> { |
| 42 public: | 41 public: |
| 43 static GeolocationController& controller(const WebPrivatePtr<GeolocationCont
rollerPrivate>& controller) | 42 static PassRefPtrWillBeRawPtr<GeolocationControllerPrivate> create(Geolocati
onController* controller) |
| 44 { | 43 { |
| 45 ASSERT(!controller.isNull()); | 44 return adoptRefWillBeNoop(new GeolocationControllerPrivate(controller)); |
| 46 return *controller; | |
| 47 } | |
| 48 }; | |
| 49 #else | |
| 50 class GeolocationControllerPrivate final : public RefCounted<GeolocationControll
erPrivate> { | |
| 51 public: | |
| 52 static PassRefPtr<GeolocationControllerPrivate> create(GeolocationController
* controller) | |
| 53 { | |
| 54 return adoptRef(new GeolocationControllerPrivate(controller)); | |
| 55 } | 45 } |
| 56 | 46 |
| 57 static GeolocationController& controller(const WebPrivatePtr<GeolocationCont
rollerPrivate>& controller) | 47 static GeolocationController& controller(const WebPrivatePtr<GeolocationCont
rollerPrivate>& controller) |
| 58 { | 48 { |
| 59 ASSERT(!controller.isNull()); | 49 ASSERT(!controller.isNull()); |
| 60 ASSERT(controller->m_controller); | 50 ASSERT(controller->m_controller); |
| 61 return *controller->m_controller; | 51 return *controller->m_controller; |
| 62 } | 52 } |
| 63 | 53 |
| 54 DEFINE_INLINE_TRACE() |
| 55 { |
| 56 visitor->trace(m_controller); |
| 57 } |
| 58 |
| 64 private: | 59 private: |
| 65 explicit GeolocationControllerPrivate(GeolocationController* controller) | 60 explicit GeolocationControllerPrivate(GeolocationController* controller) |
| 66 : m_controller(controller) | 61 : m_controller(controller) |
| 67 { | 62 { |
| 68 } | 63 } |
| 69 | 64 |
| 70 // Non-Oilpan, this bare pointer is owned as a supplement and kept alive | 65 // Non-Oilpan, this bare pointer is owned as a supplement and kept alive |
| 71 // by the frame of the WebLocalFrame which creates the WebGeolocationControl
ler | 66 // by the frame of the WebLocalFrame which creates the WebGeolocationControl
ler |
| 72 // object that wraps it all up. | 67 // object that wraps it all up. |
| 73 GeolocationController* m_controller; | 68 RawPtrWillBeMember<GeolocationController> m_controller; |
| 74 }; | 69 }; |
| 75 #endif | |
| 76 | 70 |
| 77 WebGeolocationController::WebGeolocationController(GeolocationController* contro
ller) | 71 WebGeolocationController::WebGeolocationController(GeolocationController* contro
ller) |
| 78 #if ENABLE(OILPAN) | |
| 79 : m_private(static_cast<GeolocationControllerPrivate*>(controller)) | |
| 80 #else | |
| 81 : m_private(GeolocationControllerPrivate::create(controller)) | 72 : m_private(GeolocationControllerPrivate::create(controller)) |
| 82 #endif | |
| 83 { | 73 { |
| 84 } | 74 } |
| 85 | 75 |
| 86 void WebGeolocationController::reset() | 76 void WebGeolocationController::reset() |
| 87 { | 77 { |
| 88 m_private.reset(); | 78 m_private.reset(); |
| 89 } | 79 } |
| 90 | 80 |
| 91 void WebGeolocationController::positionChanged(const WebGeolocationPosition& web
Position) | 81 void WebGeolocationController::positionChanged(const WebGeolocationPosition& web
Position) |
| 92 { | 82 { |
| 93 GeolocationControllerPrivate::controller(m_private).positionChanged(static_c
ast<GeolocationPosition*>(webPosition)); | 83 GeolocationControllerPrivate::controller(m_private).positionChanged(static_c
ast<GeolocationPosition*>(webPosition)); |
| 94 } | 84 } |
| 95 | 85 |
| 96 void WebGeolocationController::errorOccurred(const WebGeolocationError& webError
) | 86 void WebGeolocationController::errorOccurred(const WebGeolocationError& webError
) |
| 97 { | 87 { |
| 98 GeolocationControllerPrivate::controller(m_private).errorOccurred(static_cas
t<GeolocationError*>(webError)); | 88 GeolocationControllerPrivate::controller(m_private).errorOccurred(static_cas
t<GeolocationError*>(webError)); |
| 99 } | 89 } |
| 100 | 90 |
| 101 } // namespace blink | 91 } // namespace blink |
| OLD | NEW |