Home | History | Annotate | Download | only in geolocation
      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
      3 // found in the LICENSE file.
      4 
      5 // This file declares a CoreLocation data provider class that allows the
      6 // CoreLocation framework to run on the UI thread, since the Geolocation API's
      7 // providers all live on the IO thread
      8 
      9 #ifndef CONTENT_BROWSER_GEOLOCATION_CORE_LOCATION_DATA_PROVIDER_H_
     10 #define CONTENT_BROWSER_GEOLOCATION_CORE_LOCATION_DATA_PROVIDER_H_
     11 
     12 #include "base/mac/scoped_nsobject.h"
     13 #include "base/memory/ref_counted.h"
     14 #include "content/public/browser/browser_thread.h"
     15 #include "content/public/common/geoposition.h"
     16 
     17 #import <Foundation/Foundation.h>
     18 
     19 @class CoreLocationWrapperMac;
     20 
     21 namespace content {
     22 class CoreLocationProviderMac;
     23 
     24 // Data provider class that allows CoreLocation to run in Chrome's UI thread
     25 // while existing on any of Chrome's threads (in this case the IO thread)
     26 class CoreLocationDataProviderMac
     27     : public base::RefCountedThreadSafe<CoreLocationDataProviderMac> {
     28  public:
     29   CoreLocationDataProviderMac();
     30 
     31   bool StartUpdating(CoreLocationProviderMac* provider);
     32   void StopUpdating();
     33 
     34   void UpdatePosition(Geoposition* position);
     35 
     36  private:
     37   friend class base::RefCountedThreadSafe<CoreLocationDataProviderMac>;
     38   ~CoreLocationDataProviderMac();
     39 
     40   // These must execute in BrowserThread::UI
     41   void StartUpdatingTask();
     42   void StopUpdatingTask();
     43   // This must execute in the origin thread (IO thread)
     44   void PositionUpdated(Geoposition position);
     45 
     46   // The wrapper class that supplies this class with position data
     47   base::scoped_nsobject<CoreLocationWrapperMac> wrapper_;
     48   // The LocationProvider class that should receive position data
     49   CoreLocationProviderMac* provider_;
     50 };
     51 
     52 }  // namespace content
     53 
     54 #endif  // CONTENT_BROWSER_GEOLOCATION_CORE_LOCATION_DATA_PROVIDER_H_
     55