| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 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 #ifndef CONTENT_BROWSER_GEOLOCATION_ARBITRATOR_DEPENDENCY_FACTORY_H_ | |
| 6 #define CONTENT_BROWSER_GEOLOCATION_ARBITRATOR_DEPENDENCY_FACTORY_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include "base/ref_counted.h" | |
| 10 #include "base/string16.h" | |
| 11 | |
| 12 class AccessTokenStore; | |
| 13 class GURL; | |
| 14 class LocationProviderBase; | |
| 15 class URLRequestContextGetter; | |
| 16 | |
| 17 namespace base { | |
| 18 class Time; | |
| 19 } | |
| 20 | |
| 21 // Allows injection of factory methods for creating the location providers. | |
| 22 // RefCounted for simplicity of writing tests. | |
| 23 class GeolocationArbitratorDependencyFactory | |
| 24 : public base::RefCounted<GeolocationArbitratorDependencyFactory> { | |
| 25 public: | |
| 26 // Defines a function that returns the current time. | |
| 27 typedef base::Time (*GetTimeNow)(); | |
| 28 | |
| 29 virtual GetTimeNow GetTimeFunction() = 0; | |
| 30 virtual URLRequestContextGetter* GetContextGetter() = 0; | |
| 31 virtual AccessTokenStore* NewAccessTokenStore() = 0; | |
| 32 virtual LocationProviderBase* NewNetworkLocationProvider( | |
| 33 AccessTokenStore* access_token_store, | |
| 34 URLRequestContextGetter* context, | |
| 35 const GURL& url, | |
| 36 const string16& access_token) = 0; | |
| 37 virtual LocationProviderBase* NewSystemLocationProvider() = 0; | |
| 38 | |
| 39 protected: | |
| 40 friend class base::RefCounted<GeolocationArbitratorDependencyFactory>; | |
| 41 virtual ~GeolocationArbitratorDependencyFactory(); | |
| 42 }; | |
| 43 | |
| 44 // The default dependency factory, exposed so that it is possible | |
| 45 // to override only certain parts (e.g. the location providers). | |
| 46 class DefaultGeolocationArbitratorDependencyFactory | |
| 47 : public GeolocationArbitratorDependencyFactory { | |
| 48 public: | |
| 49 // GeolocationArbitratorDependencyFactory | |
| 50 virtual URLRequestContextGetter* GetContextGetter(); | |
| 51 virtual GetTimeNow GetTimeFunction(); | |
| 52 virtual AccessTokenStore* NewAccessTokenStore(); | |
| 53 virtual LocationProviderBase* NewNetworkLocationProvider( | |
| 54 AccessTokenStore* access_token_store, | |
| 55 URLRequestContextGetter* context, | |
| 56 const GURL& url, | |
| 57 const string16& access_token); | |
| 58 virtual LocationProviderBase* NewSystemLocationProvider(); | |
| 59 }; | |
| 60 | |
| 61 #endif // CONTENT_BROWSER_GEOLOCATION_ARBITRATOR_DEPENDENCY_FACTORY_H_ | |
| OLD | NEW |