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

Side by Side Diff: chrome/browser/geolocation/location_provider_pool.h

Issue 552250: Port the gears geolocation network provider to Chromium... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2008, Google Inc. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // 2 // Use of this source code is governed by a BSD-style license that can be
3 // Redistribution and use in source and binary forms, with or without 3 // found in the LICENSE file.
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 4
26 #ifndef GEARS_GEOLOCATION_LOCATION_PROVIDER_POOL_H__ 5 #ifndef CHROME_BROWSER_GEOLOCATION_LOCATION_PROVIDER_POOL_H_
27 #define GEARS_GEOLOCATION_LOCATION_PROVIDER_POOL_H__ 6 #define CHROME_BROWSER_GEOLOCATION_LOCATION_PROVIDER_POOL_H_
28 7
29 // TODO(joth): port to chromium 8 // TODO(joth): port to chromium
30 #if 0 9 #if 0
31 10
32 #include <map> 11 #include <map>
33 #include "gears/base/common/common.h" 12 #include "gears/base/common/common.h"
34 #include "gears/base/common/mutex.h" 13 #include "gears/base/common/mutex.h"
35 #include "gears/base/common/scoped_refptr.h" // For RefCount 14 #include "gears/base/common/scoped_refptr.h" // For RefCount
36 #include "gears/base/common/string16.h" 15 #include "gears/base/common/string16.h"
37 #include "gears/geolocation/location_provider.h" 16 #include "gears/geolocation/location_provider.h"
38 17
39 class LocationProviderPool { 18 class LocationProviderPool {
40 public: 19 public:
41 LocationProviderPool(); 20 LocationProviderPool();
42 ~LocationProviderPool(); 21 ~LocationProviderPool();
43 22
44 static LocationProviderPool *GetInstance(); 23 static LocationProviderPool *GetInstance();
45 24
46 // Registers a listener with a given type of location provider. Creates the 25 // 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 26 // provider if the pool does not alrerady contain an instance of that
48 // provider. Returns the provider, or NULL if it cannot be created. 27 // provider. Returns the provider, or NULL if it cannot be created.
49 LocationProviderBase *Register( 28 LocationProviderBase* Register(
50 BrowsingContext *browsing_context, 29 BrowsingContext* browsing_context,
51 const std::string16 &type, 30 const string16& type,
52 const std::string16 &url, 31 const string16& url,
53 const std::string16 &host, 32 const string16& host,
54 bool request_address, 33 bool request_address,
55 const std::string16 &language, 34 const string16& language,
56 LocationProviderBase::ListenerInterface *listener); 35 LocationProviderBase::ListenerInterface *listener);
57 36
58 // Unregister a listener from a given location provider. Deletes the provider 37 // Unregister a listener from a given location provider. Deletes the provider
59 // if there are no remaining listeners registered with it. Return value 38 // if there are no remaining listeners registered with it. Return value
60 // indicates whether the provider was found in the pool. 39 // indicates whether the provider was found in the pool.
61 bool Unregister(LocationProviderBase *provider, 40 bool Unregister(LocationProviderBase* provider,
62 LocationProviderBase::ListenerInterface *listener); 41 LocationProviderBase::ListenerInterface* listener);
63 42
64 // Configures the pool to return a mock location provider for the type "MOCK". 43 // Configures the pool to return a mock location provider for the type "MOCK".
65 // This method is used only by the Gears test object. 44 // This method is used only by the Gears test object.
66 void UseMockLocationProvider(bool use_mock_location_provider); 45 void UseMockLocationProvider(bool use_mock_location_provider);
67 46
68 LocationProviderBase *NewProvider(BrowsingContext *browsing_context, 47 LocationProviderBase *NewProvider(BrowsingContext* browsing_context,
69 const std::string16 &type, 48 const string16& type,
70 const std::string16 &url, 49 const string16& url,
71 const std::string16 &host, 50 const string16& host,
72 const std::string16 &language); 51 const string16& language);
73 52
74 private: 53 private:
75 static LocationProviderPool instance_; 54 static LocationProviderPool instance_;
76 55
77 typedef std::pair<LocationProviderBase*, RefCount*> ProviderPair; 56 typedef std::pair<LocationProviderBase*, RefCount*> ProviderPair;
78 typedef std::map<std::string16, ProviderPair> ProviderMap; 57 typedef std::map<string16, ProviderPair> ProviderMap;
79 ProviderMap providers_; 58 ProviderMap providers_;
80 Mutex providers_mutex_; 59 Mutex providers_mutex_;
81 60
82 bool use_mock_location_provider_; 61 bool use_mock_location_provider_;
83 62
84 DISALLOW_EVIL_CONSTRUCTORS(LocationProviderPool); 63 DISALLOW_EVIL_CONSTRUCTORS(LocationProviderPool);
85 }; 64 };
86 65
87 #endif // if 0 66 #endif // if 0
88 67
89 #endif // GEARS_GEOLOCATION_LOCATION_PROVIDER_POOL_H__ 68 #endif // CHROME_BROWSER_GEOLOCATION_LOCATION_PROVIDER_POOL_H_
OLDNEW
« no previous file with comments | « chrome/browser/geolocation/location_provider.cc ('k') | chrome/browser/geolocation/location_provider_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698