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

Unified Diff: Source/core/page/PageLifecycleNotifier.cpp

Issue 18777003: Extract simpler classes for observing context lifecycle and observe Page lifecycle inNavigatorVibra… (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Use SimpleLifecycleObserver in addObserver / removeObserver. Created 7 years, 5 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: Source/core/page/PageLifecycleNotifier.cpp
diff --git a/Source/modules/geolocation/Coordinates.cpp b/Source/core/page/PageLifecycleNotifier.cpp
similarity index 59%
copy from Source/modules/geolocation/Coordinates.cpp
copy to Source/core/page/PageLifecycleNotifier.cpp
index 190a6ee3adf9f2925e1601238122bcf9522f9684..bd924b9d5cdc9781aa00a3d96984814029d27584 100644
--- a/Source/modules/geolocation/Coordinates.cpp
+++ b/Source/core/page/PageLifecycleNotifier.cpp
@@ -20,48 +20,38 @@
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
#include "config.h"
-#include "modules/geolocation/Coordinates.h"
+#include "core/page/PageLifecycleNotifier.h"
namespace WebCore {
-double Coordinates::altitude(bool& isNull) const
+PageLifecycleNotifier::PageLifecycleNotifier(SimpleLifecycleContext* context)
+ : SimpleLifecycleNotifier(context)
{
- if (m_canProvideAltitude)
- return m_altitude;
-
- isNull = true;
- return 0;
}
-double Coordinates::altitudeAccuracy(bool& isNull) const
+void PageLifecycleNotifier::addObserver(SimpleLifecycleObserver* observer, SimpleLifecycleObserver::Type type)
{
- if (m_canProvideAltitudeAccuracy)
- return m_altitudeAccuracy;
+ if (type == SimpleLifecycleObserver::PageLifecycleObserverType) {
+ RELEASE_ASSERT(m_iterating != IteratingOverPageObservers);
+ m_pageObservers.add(static_cast<PageLifecycleObserver*>(observer));
+ }
- isNull = true;
- return 0;
+ SimpleLifecycleNotifier::addObserver(observer, type);
}
-double Coordinates::heading(bool& isNull) const
+void PageLifecycleNotifier::removeObserver(SimpleLifecycleObserver* observer, SimpleLifecycleObserver::Type type)
{
- if (m_canProvideHeading)
- return m_heading;
+ if (type == SimpleLifecycleObserver::PageLifecycleObserverType) {
+ RELEASE_ASSERT(m_iterating != IteratingOverPageObservers);
+ m_pageObservers.remove(static_cast<PageLifecycleObserver*>(observer));
+ }
- isNull = true;
- return 0;
+ SimpleLifecycleNotifier::removeObserver(observer, type);
}
-double Coordinates::speed(bool& isNull) const
-{
- if (m_canProvideSpeed)
- return m_speed;
-
- isNull = true;
- return 0;
-}
-
} // namespace WebCore

Powered by Google App Engine
This is Rietveld 408576698