~ubuntu-branches/ubuntu/lucid/webkit/lucid-updates

« back to all changes in this revision

Viewing changes to WebCore/page/GeolocationController.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Gustavo Noronha Silva
  • Date: 2010-02-04 19:30:57 UTC
  • mfrom: (1.2.8 upstream) (4.3.9 sid)
  • Revision ID: james.westby@ubuntu.com-20100204193057-d3018lm1fipb0703
* New upstream release
* debian/copyright:
- Updated with changes since 1.1.19.

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
 
41
41
GeolocationController::~GeolocationController()
42
42
{
 
43
    if (m_client)
 
44
        m_client->geolocationDestroyed();
43
45
}
44
46
 
45
47
void GeolocationController::addObserver(Geolocation* observer)
48
50
 
49
51
    bool wasEmpty = m_observers.isEmpty();
50
52
    m_observers.add(observer);
51
 
    if (wasEmpty)
 
53
    if (wasEmpty && m_client)
52
54
        m_client->startUpdating();
53
55
}
54
56
 
58
60
        return;
59
61
 
60
62
    m_observers.remove(observer);
61
 
    if (m_observers.isEmpty())
 
63
    if (m_observers.isEmpty() && m_client)
62
64
        m_client->stopUpdating();
63
65
}
64
66
 
65
67
void GeolocationController::positionChanged(GeolocationPosition* position)
66
68
{
67
 
    HashSet<RefPtr<Geolocation> >::const_iterator end = m_observers.end();
68
 
    for (HashSet<RefPtr<Geolocation> >::const_iterator it = m_observers.begin(); it != end; ++it)
69
 
        (*it)->setPosition(position);
 
69
    Vector<RefPtr<Geolocation> > observersVector;
 
70
    copyToVector(m_observers, observersVector);
 
71
    for (size_t i = 0; i < observersVector.size(); ++i)
 
72
        observersVector[i]->setPosition(position);
70
73
}
71
74
 
72
75
void GeolocationController::errorOccurred(GeolocationError* error)
73
76
{
74
 
    HashSet<RefPtr<Geolocation> >::const_iterator end = m_observers.end();
75
 
    for (HashSet<RefPtr<Geolocation> >::const_iterator it = m_observers.begin(); it != end; ++it)
76
 
        (*it)->setError(error);
 
77
    Vector<RefPtr<Geolocation> > observersVector;
 
78
    copyToVector(m_observers, observersVector);
 
79
    for (size_t i = 0; i < observersVector.size(); ++i)
 
80
        observersVector[i]->setError(error);
77
81
}
78
82
 
79
83
GeolocationPosition* GeolocationController::lastPosition()
80
84
{
 
85
    if (!m_client)
 
86
        return 0;
 
87
 
81
88
    return m_client->lastPosition();
82
89
}
83
90