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

Unified Diff: chrome/browser/geolocation/network_location_provider.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, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/geolocation/network_location_provider.h
===================================================================
--- chrome/browser/geolocation/network_location_provider.h (revision 37842)
+++ chrome/browser/geolocation/network_location_provider.h (working copy)
@@ -1,144 +1,93 @@
-// Copyright 2008, Google Inc.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-//
-// 1. Redistributions of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-// 2. Redistributions in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-// 3. Neither the name of Google Inc. nor the names of its contributors may be
-// used to endorse or promote products derived from this software without
-// specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
-// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
-// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
-#ifndef GEARS_GEOLOCATION_NETWORK_LOCATION_PROVIDER_H__
-#define GEARS_GEOLOCATION_NETWORK_LOCATION_PROVIDER_H__
+#ifndef CHROME_BROWSER_GEOLOCATION_NETWORK_LOCATION_PROVIDER_H_
+#define CHROME_BROWSER_GEOLOCATION_NETWORK_LOCATION_PROVIDER_H_
-// TODO(joth): port to chromium
-#if 0
+#include <string>
-#include "gears/base/common/common.h"
-#include "gears/base/common/mutex.h"
-#include "gears/base/common/string16.h"
-#include "gears/base/common/thread.h"
-#include "gears/geolocation/device_data_provider.h"
-#include "gears/geolocation/location_provider.h"
-#include "gears/geolocation/network_location_request.h"
+#include "base/basictypes.h"
+#include "base/lock.h"
+#include "base/string16.h"
+#include "base/thread.h"
+#include "chrome/browser/geolocation/device_data_provider.h"
+#include "chrome/browser/geolocation/geoposition.h"
+#include "chrome/browser/geolocation/location_provider.h"
+#include "chrome/browser/geolocation/network_location_request.h"
-// PositionCache is an implementation detail of NetworkLocationProvider.
-class PositionCache;
+class URLFetcherProtectEntry;
class NetworkLocationProvider
: public LocationProviderBase,
public RadioDataProvider::ListenerInterface,
public WifiDataProvider::ListenerInterface,
- public NetworkLocationRequest::ListenerInterface,
- public Thread {
+ public NetworkLocationRequest::ListenerInterface {
public:
- NetworkLocationProvider(BrowsingContext *browsing_context,
- const std::string16 &url,
- const std::string16 &host_name,
- const std::string16 &language);
+ NetworkLocationProvider(AccessTokenStore* access_token_store,
+ URLRequestContextGetter* context,
+ const GURL& url,
+ const string16& host_name);
virtual ~NetworkLocationProvider();
- // Override LocationProviderBase implementation.
- virtual void RegisterListener(
- LocationProviderBase::ListenerInterface *listener,
- bool request_address);
- virtual void UnregisterListener(
- LocationProviderBase::ListenerInterface *listener);
-
// LocationProviderBase implementation
+ virtual bool StartProvider();
virtual void GetPosition(Position *position);
+ virtual void UpdatePosition();
private:
+ // PositionCache is an implementation detail of NetworkLocationProvider.
+ class PositionCache;
+
+ // Satisfies a position request from cache or network.
+ void RequestPosition();
+
+ // Internal helper used by DeviceDataUpdateAvailable
+ void OnDeviceDataUpdated();
+
// DeviceDataProvider::ListenerInterface implementation.
- virtual void DeviceDataUpdateAvailable(RadioDataProvider *provider);
- virtual void DeviceDataUpdateAvailable(WifiDataProvider *provider);
+ virtual void DeviceDataUpdateAvailable(RadioDataProvider* provider);
+ virtual void DeviceDataUpdateAvailable(WifiDataProvider* provider);
// NetworkLocationRequest::ListenerInterface implementation.
- virtual void LocationResponseAvailable(const Position &position,
+ virtual void LocationResponseAvailable(const Position& position,
bool server_error,
- const std::string16 &access_token);
+ const string16& access_token);
- // Thread implementation
- virtual void Run();
+ AccessTokenStore* access_token_store_;
- // Internal helper used by worker thread to make a network request
- bool MakeRequest();
+ // The device data providers, acquired via global factories.
+ RadioDataProvider* radio_data_provider_;
+ WifiDataProvider* wifi_data_provider_;
- // Internal helper used by DeviceDataUpdateAvailable
- void DeviceDataUpdateAvailableImpl();
-
- // The network location request object and the url and host name it will use.
- NetworkLocationRequest *request_;
- std::string16 url_;
- std::string16 host_name_;
-
- // The device data providers
- RadioDataProvider *radio_data_provider_;
- WifiDataProvider *wifi_data_provider_;
-
// The radio and wifi data, flags to indicate if each data set is complete,
// and their guarding mutex.
RadioData radio_data_;
WifiData wifi_data_;
bool is_radio_data_complete_;
bool is_wifi_data_complete_;
- Mutex data_mutex_;
+ Lock data_mutex_;
// The timestamp for the latest device data update.
- int64 timestamp_;
+ int64 device_data_updated_timestamp_;
- // Parameters for the network request
- bool request_address_;
- bool request_address_from_last_request_;
- std::string16 address_language_;
+ string16 access_token_;
// The current best position estimate and its guarding mutex
Position position_;
- Mutex position_mutex_;
+ Lock position_mutex_;
- // The event used to notify this object's (ie the network location provider)
- // worker thread about changes in available data, the network request status
- // and whether we're shutting down. The booleans are used to indicate what the
- // event signals.
- Event thread_notification_event_;
- bool is_shutting_down_;
bool is_new_data_available_;
- bool is_last_request_complete_;
- bool is_new_listener_waiting_;
- // When the last request did not request an address, this stores any new
- // listeners which have been added and require an address to be requested.
- typedef std::set<LocationProviderBase::ListenerInterface*> ListenerSet;
- ListenerSet new_listeners_requiring_address_;
- Mutex new_listeners_requiring_address_mutex_;
- // The earliest timestamp at which the next request can be made, in
- // milliseconds.
- int64 earliest_next_request_time_;
+ // The network location request object, and the url it uses.
+ scoped_ptr<NetworkLocationRequest> request_;
- BrowsingContext *browsing_context_;
-
+ ScopedRunnableMethodFactory<NetworkLocationProvider> delayed_start_task_;
// The cache of positions.
scoped_ptr<PositionCache> position_cache_;
- DISALLOW_EVIL_CONSTRUCTORS(NetworkLocationProvider);
+ DISALLOW_COPY_AND_ASSIGN(NetworkLocationProvider);
};
-#endif // if 0
-
-#endif // GEARS_GEOLOCATION_NETWORK_LOCATION_PROVIDER_H__
+#endif // CHROME_BROWSER_GEOLOCATION_NETWORK_LOCATION_PROVIDER_H_
« no previous file with comments | « chrome/browser/geolocation/location_provider_pool.cc ('k') | chrome/browser/geolocation/network_location_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698