| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2008, Google Inc. |
| 2 // |
| 3 // Redistribution and use in source and binary forms, with or without |
| 4 // modification, are permitted provided that the following conditions are met: |
| 5 // |
| 6 // 1. Redistributions of source code must retain the above copyright notice, |
| 7 // this list of conditions and the following disclaimer. |
| 8 // 2. Redistributions in binary form must reproduce the above copyright notice, |
| 9 // this list of conditions and the following disclaimer in the documentation |
| 10 // and/or other materials provided with the distribution. |
| 11 // 3. Neither the name of Google Inc. nor the names of its contributors may be |
| 12 // used to endorse or promote products derived from this software without |
| 13 // specific prior written permission. |
| 14 // |
| 15 // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
| 16 // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 17 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
| 18 // EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 19 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 20 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
| 21 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 22 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
| 23 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
| 24 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 |
| 26 #ifndef GEARS_GEOLOCATION_LOCATION_PROVIDER_POOL_H__ |
| 27 #define GEARS_GEOLOCATION_LOCATION_PROVIDER_POOL_H__ |
| 28 |
| 29 // TODO(joth): port to chromium |
| 30 #if 0 |
| 31 |
| 32 #include <map> |
| 33 #include "gears/base/common/common.h" |
| 34 #include "gears/base/common/mutex.h" |
| 35 #include "gears/base/common/scoped_refptr.h" // For RefCount |
| 36 #include "gears/base/common/string16.h" |
| 37 #include "gears/geolocation/location_provider.h" |
| 38 |
| 39 class LocationProviderPool { |
| 40 public: |
| 41 LocationProviderPool(); |
| 42 ~LocationProviderPool(); |
| 43 |
| 44 static LocationProviderPool *GetInstance(); |
| 45 |
| 46 // Registers a listener with a given type of location provider. Creates the |
| 47 // provider if the pool does not alrerady contain an instance of that |
| 48 // provider. Returns the provider, or NULL if it cannot be created. |
| 49 LocationProviderBase *Register( |
| 50 BrowsingContext *browsing_context, |
| 51 const std::string16 &type, |
| 52 const std::string16 &url, |
| 53 const std::string16 &host, |
| 54 bool request_address, |
| 55 const std::string16 &language, |
| 56 LocationProviderBase::ListenerInterface *listener); |
| 57 |
| 58 // Unregister a listener from a given location provider. Deletes the provider |
| 59 // if there are no remaining listeners registered with it. Return value |
| 60 // indicates whether the provider was found in the pool. |
| 61 bool Unregister(LocationProviderBase *provider, |
| 62 LocationProviderBase::ListenerInterface *listener); |
| 63 |
| 64 // Configures the pool to return a mock location provider for the type "MOCK". |
| 65 // This method is used only by the Gears test object. |
| 66 void UseMockLocationProvider(bool use_mock_location_provider); |
| 67 |
| 68 LocationProviderBase *NewProvider(BrowsingContext *browsing_context, |
| 69 const std::string16 &type, |
| 70 const std::string16 &url, |
| 71 const std::string16 &host, |
| 72 const std::string16 &language); |
| 73 |
| 74 private: |
| 75 static LocationProviderPool instance_; |
| 76 |
| 77 typedef std::pair<LocationProviderBase*, RefCount*> ProviderPair; |
| 78 typedef std::map<std::string16, ProviderPair> ProviderMap; |
| 79 ProviderMap providers_; |
| 80 Mutex providers_mutex_; |
| 81 |
| 82 bool use_mock_location_provider_; |
| 83 |
| 84 DISALLOW_EVIL_CONSTRUCTORS(LocationProviderPool); |
| 85 }; |
| 86 |
| 87 #endif // if 0 |
| 88 |
| 89 #endif // GEARS_GEOLOCATION_LOCATION_PROVIDER_POOL_H__ |
| OLD | NEW |